@catladder/pipeline
Version:
Panter workflow for cloud CI/CD and DevOps
41 lines (40 loc) • 1.58 kB
JavaScript
;
var __assign = this && this.__assign || function () {
__assign = Object.assign || function (t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = this && this.__importDefault || function (mod) {
return mod && mod.__esModule ? mod : {
"default": mod
};
};
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getLabels = void 0;
var slugify_1 = __importDefault(require("slugify"));
var sanitize = function (value) {
if (!value) return value;
//"The value can only contain lowercase letters, numeric characters, underscores and dashes. The value can be at most 63 characters long. International characters are allowed."
// slugify should do the job
return (0, slugify_1.default)(value).toLowerCase();
};
var getLabels = function (context) {
var _a, _b;
var labels = __assign({
"customer-name": sanitize(context.fullConfig.customerName),
"component-name": sanitize(context.name),
"app-name": sanitize(context.fullConfig.appName),
"env-type": sanitize(context.environment.envType),
"env-name": sanitize(context.env),
"build-type": context.build.type === "disabled" ? "disabled" : sanitize(context.build.buildType)
}, (_b = (_a = context.fullConfig.meta) === null || _a === void 0 ? void 0 : _a.labels) !== null && _b !== void 0 ? _b : {});
return labels;
};
exports.getLabels = getLabels;