@catladder/cli
Version:
Panter cli tool for cloud CI/CD and DevOps
45 lines • 1.49 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKubeEnv = void 0;
const types_1 = require("../types");
const shouldGoIntoSecrets = (key, value) => {
var _a;
if (!value)
return false;
if ((_a = String(value)) === null || _a === void 0 ? void 0 : _a.includes("$CL_")) {
return true;
}
return false;
};
/**
* separate by secrets and public.
* we evalulate the actual values later, but want to store the secrets in kubernetes secrets
*/
const createKubeEnv = (context) => {
var _a;
if (!(0, types_1.isOfDeployType)((_a = context.deploy) === null || _a === void 0 ? void 0 : _a.config, "kubernetes")) {
// should not happen
throw new Error("deploy config is not kubernetes");
}
const allEnvVars = context.environment.envVars;
const env = Object.entries(allEnvVars).reduce((acc, [key, value]) => {
if (shouldGoIntoSecrets(key, value === null || value === void 0 ? void 0 : value.toString())) {
acc.secret = {
...acc.secret,
[key]: value !== null && value !== void 0 ? value : "",
};
return acc;
}
acc.public = {
...acc.public,
[key]: value !== null && value !== void 0 ? value : "",
};
return acc;
}, {
secret: {},
public: {},
});
return env;
};
exports.createKubeEnv = createKubeEnv;
//# sourceMappingURL=kubeEnv.js.map