@adpt/cloud
Version:
AdaptJS cloud component library
140 lines • 5.02 kB
TypeScript
import Adapt, { AdaptElement, BuiltinProps, PrimitiveComponent, SFCDeclProps } from "@adpt/core";
import { ReplaceT } from "type-ops";
import { ContainerProps as AbsContainerProps } from "../Container";
/**
* Resource spec for a Kubernetes container.
* See the Kubernetes
* {@link https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.18/#container-v1-core | API docs }
* for more details.
* @public
*/
export interface ContainerSpec {
name: string;
image: string;
args?: string[];
command?: string[];
env?: EnvVar[];
imagePullPolicy?: "Always" | "Never" | "IfNotPresent";
tty?: boolean;
ports?: ContainerPort[];
workingDir?: string;
}
/**
* Props for the Kubernetes-specific {@link k8s.K8sContainer} component.
* @public
*/
export interface K8sContainerProps extends ContainerSpec {
}
/** @public */
export interface ContainerPort {
/**
* Number of port to expose on the pod's IP address.
* @remarks
* This must be a valid integer port number, `0 < x < 65536`.
*/
containerPort: number;
/** What host IP to bind the external port to. */
hostIP?: string;
/**
* Number of port to expose on the host.
* @remarks
* If specified, this must be a valid integer port number,
* `0 < x < 65536`. If HostNetwork is specified,
* this must match ContainerPort. Most containers do not need this.
*/
hostPort?: number;
/**
* A unique-within-pod name for the container
* @remarks
* If specified, this must be an IANA_SVC_NAME and unique within the pod.
* Each named port in a pod must have a unique name. Name for the port
* that can be referred to by services.
*/
name?: string;
/** Protocol for port. Must be UDP or TCP. Defaults to "TCP". */
protocol?: string;
}
/** @public */
export declare type EnvVar = EnvVarSimple | EnvVarFrom;
/** @public */
export interface EnvVarSimple {
/** Name of the environment variable. Must be a C_IDENTIFIER. */
name: string;
/**
* Variable references $(VAR_NAME) are expanded using the previous defined
* environment variables in the container and any service environment
* variables. If a variable cannot be resolved, the reference in the input
* string will be unchanged. The $(VAR_NAME) syntax can be escaped with a
* double $$, ie: $$(VAR_NAME). Escaped references will never be expanded,
* regardless of whether the variable exists or not. Defaults to "".
*/
value: string;
}
/** @public */
export interface EnvVarFrom {
/** Source for the environment variable's value. Cannot be used if value is not empty. */
valueFrom?: any;
}
/**
* See {@link k8s.k8sContainerProps}.
* @public
*/
export declare type FromContainerProps = ReplaceT<AbsContainerProps, {
image: string;
}> & BuiltinProps;
/**
* Low level utility function to translate from the abstract {@link Container}
* component props ({@link ContainerProps}) to {@link k8s.K8sContainerProps}
* to be used in a {@link k8s.K8sContainer}.
* @remarks
* Note: The `image` property in the passed in {@link ContainerProps} must
* be a `string`, not a `Handle`.
* In most cases, it is preferable to use the {@link k8s.Container} component
* instead, which is designed specifically to deal with this issue.
*
* @param abstractProps - The abstract {@link ContainerProps} to translate from.
* @param k8sProps - Props that are specific to the {@link k8s.K8sContainer}
* component that should be merged into the resulting returned
* {@link k8s.K8sContainerProps} object.
* @public
*/
export declare function k8sContainerProps(abstractProps: FromContainerProps, k8sProps?: Partial<K8sContainerProps>): K8sContainerProps;
/**
* Tests whether an element is a {@link k8s.K8sContainer} element
* @param x - element to test
* @returns `true` if element is a {@link k8s.K8sContainer}, `false` otherwise
*
* @remarks
* Acts as a TypeScript type assertion that will assert that `x` is `AdaptElement<K8sContainerProps>`
*
* @public
*/
export declare function isK8sContainerElement(x: AdaptElement): x is AdaptElement<K8sContainerProps>;
/**
* Kubernetes-specific container.
* @public
*/
export declare class K8sContainer extends PrimitiveComponent<K8sContainerProps> {
static defaultProps: {
imagePullPolicy: string;
};
validate(): undefined;
}
/**
* Props for {@link k8s.Container}.
* @public
*/
export interface ContainerProps extends SFCDeclProps<AbsContainerProps> {
/**
* Additional {@link k8s.K8sContainerProps}-specific props that should be
* added to the instantiated {@link k8s.K8sContainer}.
*/
k8sContainerProps?: Partial<K8sContainerProps>;
}
/**
* Component that implements the abstract {@link Container} interface and
* translates to a Kubernetes-specific {@link k8s.K8sContainer}.
* @public
*/
export declare function Container(props: ContainerProps): Adapt.AdaptElementOrNull;
//# sourceMappingURL=Container.d.ts.map