UNPKG

@atomist/sdm-core

Version:

Atomist Software Delivery Machine - Implementation

65 lines 2.97 kB
import { GitProject, HandlerContext } from "@atomist/automation-client"; import { ExecuteGoal, RepoContext, SdmGoalEvent } from "@atomist/sdm"; import * as k8s from "@kubernetes/client-node"; import { DeepPartial, Merge } from "ts-essentials"; import { Container, ContainerRegistration, ContainerScheduler, GoalContainer, GoalContainerVolume } from "./container"; /** * Specification of containers and volumes for a container goal. */ export interface K8sGoalContainerSpec { /** * 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: Array<Merge<DeepPartial<k8s.V1Container>, GoalContainer>>; /** * Volumes available to mount in containers. */ volumes?: Array<Merge<DeepPartial<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, c: HandlerContext) => Promise<K8sGoalContainerSpec>; /** * Additional options for Kubernetes implementation of container goals. */ export interface K8sContainerRegistration extends ContainerRegistration { /** * Replace generic containers in [[ContainerRegistration]] with * Kubernetes containers. */ containers: Array<Merge<DeepPartial<k8s.V1Container>, GoalContainer>>; /** * Replace generic callback in [[ContainerRegistration]] with * Kubernetes-specific callback. */ callback?: K8sContainerSpecCallback; /** * Replace generic volumes in [[ContainerRegistration]] with * Kubernetes volumes. */ volumes?: Array<Merge<DeepPartial<k8s.V1Volume>, GoalContainerVolume>>; } export declare const k8sContainerScheduler: 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>; /** * Wait for first container to exit and stream its logs to the * progress log. */ export declare function executeK8sJob(goal: Container, registration: K8sContainerRegistration): ExecuteGoal; //# sourceMappingURL=k8s.d.ts.map