@atomist/sdm
Version:
Atomist Software Delivery Machine SDK
88 lines • 4.13 kB
TypeScript
import { GitProject } from "@atomist/automation-client/lib/project/git/GitProject";
import * as k8s from "@kubernetes/client-node";
import { Merge } from "ts-essentials";
import { RepoContext } from "../../api/context/SdmContext";
import { ExecuteGoal } from "../../api/goal/GoalInvocation";
import { GoalWithFulfillment } from "../../api/goal/GoalWithFulfillment";
import { SdmGoalEvent } from "../../api/goal/SdmGoalEvent";
import { Container, ContainerRegistration, ContainerScheduler, GoalContainer, GoalContainerVolume } from "../../core/goal/container/container";
/** Merge of base and Kubernetes goal container interfaces. */
export declare type K8sGoalContainer = Merge<GoalContainer, k8s.V1Container> & Pick<GoalContainer, "name" | "image">;
/** Merge of base and Kubernetes goal container volume interfaces. */
export declare type K8sGoalContainerVolume = Merge<k8s.V1Volume, GoalContainerVolume>;
/**
* Function signature for callback that can modify and return the
* [[ContainerRegistration]] object.
*/
export declare type K8sContainerSpecCallback = (r: K8sContainerRegistration, p: GitProject, g: Container, e: SdmGoalEvent, ctx: RepoContext) => Promise<Omit<K8sContainerRegistration, "callback">>;
/**
* Additional options for Kubernetes implementation of container goals.
*/
export interface K8sContainerRegistration extends ContainerRegistration {
/**
* Replace generic containers in [[ContainerRegistration]] with
* Kubernetes containers.
*
* Containers to run for this goal. The goal result is based on
* the exit status of the first element of the `containers` array.
* The other containers are considered "sidecar" containers
* provided functionality that the main container needs to
* function. If not set, the working directory of the first
* container is set to [[ContainerProjectHome]], which contains
* the project upon which the goal should operate. If
* `workingDir` is set, it is not changed. If `workingDir` is set
* to the empty string, the `workingDir` property is deleted from
* the main container spec, meaning the container default working
* directory will be used.
*/
containers: K8sGoalContainer[];
/**
* Replace generic callback in [[ContainerRegistration]] with
* Kubernetes-specific callback.
*/
callback?: K8sContainerSpecCallback;
/**
* Init containers to run for this goal. Any containers provided
* here will run after the one inserted by the SDM to manage the
* cloned repository.
*/
initContainers?: k8s.V1Container[];
/**
* Replace generic volumes in [[ContainerRegistration]] with
* Kubernetes volumes available to mount in containers.
*/
volumes?: K8sGoalContainerVolume[];
}
/**
* Container scheduler to use when running in Kubernetes.
*/
export declare const k8sContainerScheduler: ContainerScheduler;
/**
* Container scheduler to use when running in Google Cloud Functions.
*/
export declare const k8sSkillContainerScheduler: ContainerScheduler;
/**
* Add Kubernetes job scheduling information to SDM goal event data
* for use by the [[KubernetesGoalScheduler]].
*/
export declare function k8sFulfillmentCallback(goal: Container, registration: K8sContainerRegistration): (sge: SdmGoalEvent, rc: RepoContext) => Promise<SdmGoalEvent>;
/**
* Get container registration from goal event data, use
* [[k8sFulfillmentcallback]] to get a goal event schedulable by a
* [[KubernetesGoalScheduler]], then schedule the goal using that
* scheduler.
*/
export declare const scheduleK8sJob: ExecuteGoal;
/**
* Wait for first container to exit and stream its logs to the
* progress log.
*/
export declare function executeK8sJob(): ExecuteGoal;
/** Deterministic name for Kubernetes container goal fulfiller. */
export declare const K8sContainerFulfillerName = "Kubernetes Container Goal Fulfiller";
/**
* Goal that fulfills requested container goals by scheduling them as
* Kubernetes jobs.
*/
export declare function k8sContainerFulfiller(): GoalWithFulfillment;
//# sourceMappingURL=container.d.ts.map