@gati-framework/cli
Version:
CLI tool for Gati framework - create, develop, build and deploy cloud-native applications
37 lines • 1.82 kB
JavaScript
/**
* @module cli/deployment/manifest-generator
* @description Thin wrapper around Kubernetes manifest generators that also writes files
*/
import { mkdir, writeFile } from 'fs/promises';
import { join } from 'path';
import { generateCompleteManifests } from './kubernetes.js';
export function createManifests(appName, namespace, env, options = {}) {
return generateCompleteManifests(appName, namespace, env, options);
}
export async function writeManifests(outDir, manifests) {
await mkdir(outDir, { recursive: true });
const dockerfilePath = join(outDir, 'Dockerfile');
const deploymentPath = join(outDir, 'deployment.yaml');
const servicePath = join(outDir, 'service.yaml');
const hpaPath = manifests.hpa ? join(outDir, 'hpa.yaml') : undefined;
const ingressPath = manifests.ingress ? join(outDir, 'ingress.yaml') : undefined;
const chartDir = join(outDir, 'helm');
const chartPath = join(chartDir, 'Chart.yaml');
const valuesPath = join(chartDir, 'values.yaml');
await mkdir(chartDir, { recursive: true });
await writeFile(dockerfilePath, manifests.dockerfile, 'utf-8');
await writeFile(deploymentPath, manifests.deployment, 'utf-8');
await writeFile(servicePath, manifests.service, 'utf-8');
// Write HPA if present
if (manifests.hpa && hpaPath) {
await writeFile(hpaPath, manifests.hpa, 'utf-8');
}
// Write Ingress if present
if (manifests.ingress && ingressPath) {
await writeFile(ingressPath, manifests.ingress, 'utf-8');
}
await writeFile(chartPath, manifests.helm.chartYaml, 'utf-8');
await writeFile(valuesPath, manifests.helm.valuesYaml, 'utf-8');
return { dockerfilePath, deploymentPath, servicePath, hpaPath, ingressPath, valuesPath, chartPath };
}
//# sourceMappingURL=manifest-generator.js.map