UNPKG

@adpt/cloud

Version:
327 lines 8.65 kB
import { AdaptElement, Handle, PrimitiveComponent } from "@adpt/core"; import { FIXME_NeedsProperType } from "@adpt/utils"; import { DockerImageInstance } from "./docker"; import { Environment } from "./env"; /** * Description of a network port for a {@link Container}. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export declare type PortDescription = string | number; /** * An image for a {@link Container}. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export declare type ImageId = string | Handle<DockerImageInstance>; /** * A command to be used when creating a {@link Container}. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export declare type Command = string | string[]; /** * A set of ports to be bound for a {@link Container}. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export interface PortBinding { [ctrPort: number]: number; [ctrPort: string]: number; } /** * Network links to create for a {@link Container}. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export interface Links { [internalName: string]: string; } /** * The behavior to apply when the container exits. * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export interface RestartPolicy { /** The type of behavior to apply */ name: RestartPolicyName; /** If `OnFailure` is used, the number of times to retry before giving up */ maximumRetryCount?: number; } /** * Names for {@link RestartPolicy} * * @remarks * - `Always` - Always restart the container. * - `Never` - Do not automatically restart the container. * - `OnFailure` - Restart only when the container exit code is non-zero. * - `UnlessStopped` - Always restart the container, except if it has been * manually stopped by user intervention. * * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export declare type RestartPolicyName = "Always" | "Never" | "OnFailure" | "UnlessStopped"; /** * Props for the {@link Container} component. * * @remarks * See the * {@link https://docs.docker.com/engine/api/v1.40/#operation/ContainerCreate | Docker API Reference} * for more information. * @public */ export interface ContainerProps { name: string; dockerHost: string; image: ImageId; autoRemove?: boolean; ports?: PortDescription[]; stdinOpen?: boolean; stopSignal?: string; tty?: boolean; command?: Command; portBindings?: PortBinding; environment?: Environment; links?: Links; entrypoint?: Command; /** * The behavior to apply when the container exits. * @remarks * See {@link RestartPolicy} and {@link RestartPolicyName} for the * possible values and corresponding behavior. * @defaultValue The default is `{ name: "Never" }`, which does not * restart the container. */ restartPolicy?: RestartPolicy; workingDir?: string; imagePullPolicy?: "Always" | "Never" | "IfNotPresent"; } /** * State information for a {@link Container}. * @public */ export interface ContainerState { Status: string; Running: boolean; Paused: boolean; Restarting: boolean; OOMKilled: boolean; Dead: boolean; Pid: number; ExitCode: number; Error: string; StartedAt: string; FinishedAt: string; } /** * Status of a {@link Container}. * @public */ export interface ContainerStatus { Id: string; Created: string; Path: string; Args: string[]; State: ContainerState; Image: string; ResolvConfPath: string; HostnamePath: string; HostsPath: string; Node: FIXME_NeedsProperType; Name: string; RestartCount: number; Driver: string; MountLabel: string; ProcessLabel: string; AppArmorProfile: string; ExecIDs: string; HostConfig: HostConfigStatus; GraphDriver: FIXME_NeedsProperType; SizeRw: number; SizeRootFs: number; Mounts: MountStatus[]; Config: Config; NetworkSettings: ContainerNetworkSettings; } /** * Config for {@link ContainerStatus} * @public */ export interface Config { Hostname: string; Domainname: string; User: string; AttachStdin: boolean; AttachStdout: boolean; AttachStderr: boolean; Tty: boolean; OpenStdin: boolean; StdinOnce: boolean; Env: string[]; Cmd: string[]; ArgsEscaped: boolean; Image: string; Volumes: FIXME_NeedsProperType; WorkingDir: string; Entrypoint: FIXME_NeedsProperType; OnBuild: FIXME_NeedsProperType; Labels: ContainerLabels; StopSignal: FIXME_NeedsProperType; ExposedPorts: null | { [port: string]: {}; }; } /** * Labels for a {@link Container} * @public */ export interface ContainerLabels { [name: string]: string; } /** * NetworkSettings for {@link ContainerStatus} * @public */ export interface ContainerNetworkSettings { Bridge: FIXME_NeedsProperType; SandboxID: string; HairpinMode: boolean; LinkLocalIPv6Address: string; LinkLocalIPv6PrefixLen: number; Ports: FIXME_NeedsProperType; SandboxKey: string; SecondaryIPAddresses: FIXME_NeedsProperType; SecondaryIPv6Addresses: FIXME_NeedsProperType; EndpointID: string; Gateway: string; GlobalIPv6Address: string; GlobalIPv6PrefixLen: number; IPAddress: string; IPPrefixLen: number; IPv6Gateway: string; MacAddress: string; Networks: { [name: string]: ContainerNetwork; }; } /** * Network for {@link ContainerStatus} * @public */ export interface ContainerNetwork { IPAMConfig: FIXME_NeedsProperType; Links: FIXME_NeedsProperType; Aliases: FIXME_NeedsProperType; NetworkID: string; EndpointID: string; Gateway: string; IPAddress: string; IPPrefixLen: number; IPv6Gateway: string; GlobalIPv6Address: string; GlobalIPv6PrefixLen: number; MacAddress: string; DriverOpts: FIXME_NeedsProperType; } /** * HostConfig for {@link ContainerStatus} * @public */ export interface HostConfigStatus { PortBindings: PortBindingsStatus; RestartPolicy: RestartPolicyStatus; Binds: string[] | null; } /** * Restart policy status for {@link ContainerStatus} * @public */ export interface RestartPolicyStatus { Name: "no" | "always" | "on-failure" | "unless-stopped"; MaximumRetryCount: number; } /** * PortBindings for {@link ContainerStatus} * @public */ export interface PortBindingsStatus { [ctrPort: string]: PortBindingStatus[]; } /** * PortBinding information for {@link ContainerStatus} * @public */ export interface PortBindingStatus { HostIp: string; HostPort: string; } /** * Mount information for {@link ContainerStatus} * @public */ export interface MountStatus { Type: "bind" | "volume" | "tmpfs"; Source?: string; Destination: string; Mode: string; RW: boolean; Propagation: "shared" | "slave" | "private" | "rshared" | "rslave" | "rprivate"; } /** * Abstract component representing a container. * @public */ export declare abstract class Container extends PrimitiveComponent<ContainerProps> { static defaultProps: { dockerHost: string; autoRemove: boolean; ports: never[]; stdinOpen: boolean; tty: boolean; portBindings: {}; environment: {}; links: {}; imagePullPolicy: string; }; static displayName: string; } export default Container; /** * Function to check whether an {@link @adpt/core#AdaptElement} is an * abstract {@link Container}. * @public */ export declare function isContainerElement(el: AdaptElement): el is AdaptElement<ContainerProps>; /** * Hook function to translate an {@link ImageId} (which can be either a * Handle or an image name string) into an image name string. * @beta */ export declare function useLatestImageFrom(source: ImageId): string | undefined; //# sourceMappingURL=Container.d.ts.map