mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 22:47:17 +00:00
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import * as k8s from '@pulumi/kubernetes';
|
|
import * as kx from '@pulumi/kubernetesx';
|
|
import * as pulumi from '@pulumi/pulumi';
|
|
|
|
export function normalizeEnv(env: kx.types.Container['env']): any[] {
|
|
if (env == null) {
|
|
return [];
|
|
}
|
|
|
|
if (Array.isArray(env)) {
|
|
return env;
|
|
}
|
|
|
|
return Object.keys(env).map(name => ({
|
|
name,
|
|
value: (env as kx.types.EnvMap)[name],
|
|
}));
|
|
}
|
|
|
|
export class PodBuilder extends kx.PodBuilder {
|
|
public asExtendedDeploymentSpec(
|
|
args?: kx.types.PodBuilderDeploymentSpec,
|
|
metadata?: k8s.types.input.meta.v1.ObjectMeta,
|
|
): pulumi.Output<k8s.types.input.apps.v1.DeploymentSpec> {
|
|
const podName = this.podSpec.containers.apply((containers: any) => {
|
|
return pulumi.output(containers[0].name);
|
|
});
|
|
const appLabels = { app: podName };
|
|
|
|
const _args = args || {};
|
|
const deploymentSpec: k8s.types.input.apps.v1.DeploymentSpec = {
|
|
..._args,
|
|
selector: { matchLabels: appLabels },
|
|
replicas: _args.replicas ?? 1,
|
|
template: {
|
|
metadata: { labels: appLabels, ...metadata },
|
|
spec: this.podSpec,
|
|
},
|
|
};
|
|
return pulumi.output(deploymentSpec);
|
|
}
|
|
}
|