UNPKG

@atomist/sdm

Version:

Atomist Software Delivery Machine SDK

54 lines 1.66 kB
"use strict"; /* * Copyright © 2020 Atomist, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.appMetadata = exports.metadataTemplate = void 0; const labels_1 = require("./labels"); /** * Use to be a workaround for * https://github.com/kubernetes-client/javascript/issues/52 , now * it is a no-op. */ function metadataTemplate(partial = {}) { return partial; } exports.metadataTemplate = metadataTemplate; /** * Generate the minimal metadata for the provided Kubernetes * application. * * @param app Kubernetes application object * @param opts optional tweaks to returned metadata * @return valid Kubernetes resource metadata */ function appMetadata(app, opts = {}) { const md = { labels: labels_1.matchLabels(app), }; if (opts.ns === "cluster") { md.name = app.name; } else if (opts.ns === "namespace") { md.name = app.ns; } else { md.name = app.name; md.namespace = app.ns; } return metadataTemplate(md); } exports.appMetadata = appMetadata; //# sourceMappingURL=metadata.js.map