1 | ;
|
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 | */
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const sdm_1 = require("@atomist/sdm");
|
19 | const _ = require("lodash");
|
20 | const kubernetesUndeploy_1 = require("./commands/kubernetesUndeploy");
|
21 | const kubernetesDeploy_1 = require("./events/kubernetesDeploy");
|
22 | const minikube_1 = require("./support/minikube");
|
23 | /**
|
24 | * Register Kubernetes deployment support for provided goals. Any
|
25 | * provided `options` are merged with any found in the SDM
|
26 | * configuration at `sdm.k8s.options`, i.e.,
|
27 | * `sdm.configuration.sdm.k8s.options` if accessing from the SDM
|
28 | * object, with those passed in taking precedence.
|
29 | *
|
30 | * If the merged options result in a truthy `addCommands`, then the
|
31 | * [[kubernetesUndeploy]] command is added to the SDM.
|
32 | *
|
33 | * The [[kubernetesDeployHandler]] event handler for this SDM is added
|
34 | * to the SDM.
|
35 | *
|
36 | * The [[minikubeStartupListener]] is added to the SDM to assist
|
37 | * running in local mode against a
|
38 | * [minikube](https://kubernetes.io/docs/setup/minikube/) cluster.
|
39 | *
|
40 | * @param options SDM Pack K8s options, see [[SdmPackK8sOptions]].
|
41 | * @returns SDM extension pack.
|
42 | */
|
43 | function k8sSupport(options = {}) {
|
44 | return Object.assign({}, sdm_1.metadata(), { configure: sdm => {
|
45 | const k8sOptions = {
|
46 | configuration: {
|
47 | sdm: {
|
48 | k8s: {
|
49 | options,
|
50 | },
|
51 | },
|
52 | },
|
53 | };
|
54 | _.merge(sdm, k8sOptions);
|
55 | if (sdm.configuration.sdm.k8s.options.addCommands) {
|
56 | sdm.addCommand(kubernetesUndeploy_1.kubernetesUndeploy);
|
57 | }
|
58 | sdm.addEvent(kubernetesDeploy_1.kubernetesDeployHandler(sdm.configuration.name));
|
59 | sdm.addStartupListener(minikube_1.minikubeStartupListener);
|
60 | } });
|
61 | }
|
62 | exports.k8sSupport = k8sSupport;
|
63 | //# sourceMappingURL=k8s.js.map |
\ | No newline at end of file |