UNPKG

@atomist/sdm-core

Version:

Atomist Software Delivery Machine - Implementation

192 lines 6.51 kB
import { GitProject } from "@atomist/automation-client"; import { FulfillableGoal, FulfillableGoalDetails, FulfillableGoalWithRegistrations, Fulfillment, Goal, GoalFulfillmentCallback, ImplementationRegistration, RepoContext, SdmGoalEvent, SoftwareDeliveryMachine } from "@atomist/sdm"; import { CacheEntry } from "../cache/goalCaching"; export declare const ContainerRegistrationGoalDataKey = "@atomist/sdm/container"; /** * Create and return a container goal with the provided container * specification. * * @param displayName Goal display name * @param registration Goal containers, volumes, cache details, etc. * @return SDM container goal */ export declare function container<T extends ContainerRegistration>(displayName: string, registration: T): FulfillableGoal; export declare const ContainerProgressReporter: import("@atomist/sdm").ReportProgress; /** * Ports to expose from container. */ export interface ContainerPort { /** * Number of port to expose from the container. This must be * a valid port number, 0 < x < 65536. */ containerPort: number; } /** * Volumes to mount in container. */ export interface ContainerVolumeMount { /** Path to mount point of volume. */ mountPath: string; /** Name of volume from [[GoalContainer.volumes]]. */ name: string; } export interface ContainerSecrets { env?: Array<{ name: string; } & GoalContainerSecret>; fileMounts?: Array<{ mountPath: string; } & GoalContainerSecret>; } /** * Simplified container abstraction for goals. */ export interface GoalContainer { /** Unique name for this container within this goal. */ name: string; /** Full Docker image name, i.e., `registry/name:tag`. */ image: string; /** * Docker command and arguments. We call this `args` rather than * `command` because we think k8s got it right. */ args?: string[]; /** * Docker image entrypoint. We call this `command` rather than * `entrypoint` because we think k8s got it right. */ command?: string[]; /** * Environment variables to set in Docker container. */ env?: Array<{ name: string; value: string; }>; /** * Ports to expose from container. */ ports?: ContainerPort[]; /** * Volumes to mount in container. */ volumeMounts?: ContainerVolumeMount[]; /** * Provider secrets that should be made available to the container */ secrets?: ContainerSecrets; } export interface GoalContainerProviderSecret { provider: { type: "docker" | "npm" | "maven2" | "scm" | "atomist"; names?: string[]; }; } export interface GoalContainerEncryptedSecret { encrypted: string; } export interface GoalContainerSecret { value: GoalContainerProviderSecret | GoalContainerEncryptedSecret; } /** * Volumes that containers in goal can mount. */ export interface GoalContainerVolume { /** Volume to be created from local host file system location. */ hostPath: { /** Absolute path on host to volume. */ path: string; }; /** Unique name of volume, referenced by [[ContainerVolumeMount.name]]. */ name: string; } /** * File system location of goal project in containers. */ export declare const ContainerProjectHome = "/atm/home"; /** * File system location for goal container input. */ export declare const ContainerInput = "/atm/input"; /** * File system location for goal container output. */ export declare const ContainerOutput = "/atm/output"; /** * Goal execution result file */ export declare const ContainerResult: string; /** * Specification of containers and volumes for a container goal. */ export interface GoalContainerSpec { /** * 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. The working directory of the first container is set * to [[ContainerProjectHome]], which contains the project upon * which the goal should operate. */ containers: GoalContainer[]; /** * Volumes available to mount in containers. */ volumes?: GoalContainerVolume[]; } /** * Function signature for callback that can modify and return the * [[ContainerRegistration]] object. */ export declare type ContainerSpecCallback = (r: ContainerRegistration, p: GitProject, g: Container, e: SdmGoalEvent, c: RepoContext) => Promise<GoalContainerSpec>; /** * Container goal artifacts and implementations information. */ export interface ContainerRegistration extends Partial<ImplementationRegistration>, GoalContainerSpec { /** * Callback function to dynamically modify the goal container spec * when goal is executed. */ callback?: ContainerSpecCallback; /** * Cache classifiers to retrieve from cache before starting goal * execution. The values must correspond to output classifiers * from previously executed container goals in the same goal set. */ input?: Array<{ classifier: string; }>; /** * File path globs to store in cache after goal execution. * They values should be glob paths relative to the root of * the project directory. */ output?: CacheEntry[]; } /** * Container goal scheduler implementation. The goal execution is * handled as part of the execution of the container. */ export declare type ContainerScheduler = (goal: Container, registration: ContainerRegistration) => void; export interface ContainerGoalDetails extends FulfillableGoalDetails { /** * Container goal scheduler. If no scheduler is provided, the k8s * scheduler is used if the SDM is running in a Kubernetes * cluster, otherwise the Docker scheduler is used. */ scheduler?: ContainerScheduler; } /** * Goal run as a container, as seen on TV. */ export declare class Container extends FulfillableGoalWithRegistrations<ContainerRegistration> { readonly details: ContainerGoalDetails; constructor(details?: ContainerGoalDetails, ...dependsOn: Goal[]); register(sdm: SoftwareDeliveryMachine): void; with(registration: ContainerRegistration): this; addFulfillment(fulfillment: Fulfillment): this; addFulfillmentCallback(cb: GoalFulfillmentCallback): this; } //# sourceMappingURL=container.d.ts.map