"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.mergeK8sOptions = exports.validSyncOptions = void 0;
const _ = require("lodash");
/** Validate the the partial SyncOptions contains a repo property. */
function validSyncOptions(o) {
    return !!o && !!o.repo;
}
exports.validSyncOptions = validSyncOptions;
/**
 * Safely merge the the provided Kubernetes options with those already
 * existing in the SDM.  The values in the SDM take precedence over
 * those in the passed in options.  The passed in SDM is modified in
 * place and returned.
 *
 * @param sdm Software Delivery Machine that may or may not have any Kubernetes pack options
 * @param options Kubernetes pack options
 * @return Modified SDM object
 */
function mergeK8sOptions(sdm, options) {
    _.defaultsDeep(sdm, { configuration: { sdm: { k8s: { options: {} } } } });
    sdm.configuration.sdm.k8s.options = _.merge({}, options, sdm.configuration.sdm.k8s.options);
    return sdm;
}
exports.mergeK8sOptions = mergeK8sOptions;
//# sourceMappingURL=config.js.map