UNPKG

2.81 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright © 2019 Atomist, Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17Object.defineProperty(exports, "__esModule", { value: true });
18const sdm_1 = require("@atomist/sdm");
19const kubernetesUndeploy_1 = require("./commands/kubernetesUndeploy");
20const config_1 = require("./config");
21const kubernetesDeploy_1 = require("./events/kubernetesDeploy");
22const kubernetesCluster_1 = require("./provider/kubernetesCluster");
23const minikube_1 = require("./support/minikube");
24const goals_1 = require("./sync/goals");
25const startup_1 = require("./sync/startup");
26const sync_1 = require("./sync/sync");
27/**
28 * Register Kubernetes deployment support for provided goals. Any
29 * provided `options` are merged with any found in the SDM
30 * configuration at `sdm.k8s.options`, i.e.,
31 * `sdm.configuration.sdm.k8s.options` if accessing from the SDM
32 * object, with those passed in taking precedence.
33 *
34 * If the merged options result in a truthy `addCommands`, then the
35 * [[kubernetesUndeploy]] and [[kubernetesSync]] commands are added to
36 * the SDM with intents.
37 *
38 * The [[kubernetesDeployHandler]] event handler for this SDM is added
39 * to the SDM.
40 *
41 * If `sync.repo` is a valid repo ref, synchronizing Kubernetes
42 * resources with a Git repository is enabled.
43 *
44 * The [[minikubeStartupListener]] is added to the SDM to assist
45 * running in local mode against a
46 * [minikube](https://kubernetes.io/docs/setup/minikube/) cluster.
47 *
48 * @param options SDM Pack K8s options, see [[SdmPackK8sOptions]].
49 * @returns SDM extension pack.
50 */
51function k8sSupport(options = {}) {
52 return Object.assign(Object.assign({}, sdm_1.metadata()), { configure: sdm => {
53 config_1.mergeK8sOptions(sdm, options);
54 sdm.addCommand(kubernetesUndeploy_1.kubernetesUndeploy(sdm));
55 sdm.addCommand(sync_1.kubernetesSync(sdm));
56 sdm.addEvent(kubernetesDeploy_1.kubernetesDeployHandler(sdm.configuration.name));
57 sdm.addStartupListener(kubernetesCluster_1.providerStartupListener);
58 sdm.addStartupListener(startup_1.syncRepoStartupListener);
59 goals_1.syncGoals(sdm);
60 sdm.addStartupListener(minikube_1.minikubeStartupListener);
61 } });
62}
63exports.k8sSupport = k8sSupport;
64//# sourceMappingURL=k8s.js.map
\No newline at end of file