import K8sApi from './k8s-apply';

const k8sApi = new K8sApi(clusterUrl, authToken);

const manifestYaml = await fs.promises.readFile(filePath, {
	encoding: 'utf-8',
});

yaml.loadAll(manifestYaml, (doc) => {
	try {
		const response = k8sApi.applyObject(doc);
		ctx.logger.info(
			`Deployment response for ${filePath}: ${JSON.stringify(response)}`
		);
	} catch (error) {
		ctx.logger.error(
			`Error applying Kubernetes object from ${filePath}`,
			error
		);
	}
});
