UNPKG

@adpt/cloud

Version:
134 lines 4.41 kB
import Adapt, { BuiltinProps, ChangeType, Handle, SFCDeclProps } from "@adpt/core"; import { Omit } from "@adpt/utils"; import { Action, ActionContext, ShouldAct } from "../action"; import { Environment } from "../env"; import { Config } from "./commands"; /** * Props for the {@link gcloud.CloudRun} component * * @public */ export interface CloudRunProps { /** Environment for the container in the deployment */ env?: Environment; /** Arguments for the container entrypoint */ args?: string[]; /** Image from which to start the container */ image: string; /** * Name of the Cloud Run service in gcloud * * @remarks * This is the absolute name of the service to use. If not specified * Adapt will automatically generate a name for the service. */ serviceName?: string; /** Region in which to create the cloud run deployment */ region: string; /** * Port on which the container will listen * * @remarks * The container must listen on this port. There is no port mapping * in CloudRun. However, this will set the `PORT` environment variable * for the container, and so the container can listen on this port * to get the effect of port mapping. */ port: number; /** * Percentage of traffic for the latest revision of the deployment * * @remarks * * CloudRun can send traffic to multiple revisions of the same * service. Every deploy to cloud run creates a new revision. After * health checks pass, the latest container will receive trafficPct/100 * of the total traffic. Set this to 100 to ensure that the * latest deployment gets all the traffic once up and running, set it to 0 * for the latest version to get no traffic. * * NOTE: This value ranges from 0 to 100, not 0.0 to 1.0 */ trafficPct: number; /** * CPU resources that can be consumed by this CloudRun deployment * * @remarks * This is a Kubernetes style cpu specification string. * 1 is 1 cpu, 2 is 2 cpus, 100m is 100minutes of CPU allocation, etc. * * Please look at Google's Cloud Run documentation for more information and any * restrictions vs. Kubernetes. */ cpu: string | number; /** * Memory allocated to this deployment * * @remarks * This is a Kubernetes style string. 128Mi is 128 Mibibytes, etc. * * Please look at Google's Cloud Run documentation for more information * and any restrictions vs. Kubernetes. */ memory: string | number; /** * Allow public access to this service * * @remarks * If set to `true`, the service will be public. Otherwise, * authentication will be required to access the service from outside * the project. */ allowUnauthenticated: boolean; /** * Specify a gcloud configuration to use * * @remarks * For unit test use only, functionality may change or disappear. * * @internal */ configuration?: string; } /** * Primitive Component for GCP Cloud Run deployments * @public */ export declare class CloudRun extends Action<CloudRunProps> { static defaultProps: { trafficPct: number; memory: string; cpu: number; allowUnauthenticated: boolean; }; config_: Config; constructor(props: CloudRunProps); validate(): "Resource elements cannot have children" | undefined; shouldAct(op: ChangeType, ctx: ActionContext): Promise<ShouldAct>; action(op: ChangeType, ctx: ActionContext): Promise<void>; deployedWhen: (goalStatus: Adapt.GoalStatus) => Promise<true | Adapt.Waiting>; private mountedElement; private config; } /** * Exported for testing only * * @internal */ export declare const makeCloudRunName: (elemKey: string, elemID: string, deployID: string) => string; /** * Props for the {@link gcloud.CloudRunAdapter} component * * @beta */ export declare type CloudRunAdapterProps = SFCDeclProps<Omit<CloudRunProps, "image"> & { image: Handle; registryUrl: string; } & Partial<BuiltinProps>, typeof CloudRun.defaultProps>; /** * Temporary adapter to allow handle for image * * @beta */ export declare function CloudRunAdapter(propsIn: CloudRunAdapterProps): Adapt.AdaptElement<Adapt.AnyProps>; //# sourceMappingURL=CloudRun.d.ts.map