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 kubernetesCluster_1 = require("./provider/kubernetesCluster");
|
23 | const minikube_1 = require("./support/minikube");
|
24 | const goals_1 = require("./sync/goals");
|
25 | const startup_1 = require("./sync/startup");
|
26 | /**
|
27 | * Register Kubernetes deployment support for provided goals. Any
|
28 | * provided `options` are merged with any found in the SDM
|
29 | * configuration at `sdm.k8s.options`, i.e.,
|
30 | * `sdm.configuration.sdm.k8s.options` if accessing from the SDM
|
31 | * object, with those passed in taking precedence.
|
32 | *
|
33 | * If the merged options result in a truthy `addCommands`, then the
|
34 | * [[kubernetesUndeploy]] command is added to the SDM.
|
35 | *
|
36 | * The [[kubernetesDeployHandler]] event handler for this SDM is added
|
37 | * to the SDM.
|
38 | *
|
39 | * If `sync.repo` is a valid repo ref, synchronizing Kubernetes
|
40 | * resources with a Git repository is enabled.
|
41 | *
|
42 | * The [[minikubeStartupListener]] is added to the SDM to assist
|
43 | * running in local mode against a
|
44 | * [minikube](https://kubernetes.io/docs/setup/minikube/) cluster.
|
45 | *
|
46 | * @param options SDM Pack K8s options, see [[SdmPackK8sOptions]].
|
47 | * @returns SDM extension pack.
|
48 | */
|
49 | function k8sSupport(options = {}) {
|
50 | return Object.assign({}, sdm_1.metadata(), { configure: sdm => {
|
51 | const k8sOptions = {
|
52 | configuration: {
|
53 | sdm: {
|
54 | k8s: {
|
55 | options,
|
56 | },
|
57 | },
|
58 | },
|
59 | };
|
60 | _.merge(sdm, k8sOptions);
|
61 | if (sdm.configuration.sdm.k8s.options.addCommands) {
|
62 | sdm.addCommand(kubernetesUndeploy_1.kubernetesUndeploy);
|
63 | }
|
64 | sdm.addEvent(kubernetesDeploy_1.kubernetesDeployHandler(sdm.configuration.name));
|
65 | sdm.addStartupListener(kubernetesCluster_1.providerStartupListener);
|
66 | sdm.addStartupListener(startup_1.syncRepoStartupListener);
|
67 | goals_1.syncGoals(sdm);
|
68 | sdm.addStartupListener(minikube_1.minikubeStartupListener);
|
69 | } });
|
70 | }
|
71 | exports.k8sSupport = k8sSupport;
|
72 | //# sourceMappingURL=k8s.js.map |
\ | No newline at end of file |