UNPKG

@atomist/sample-sdm

Version:

Sample Atomist automation for software delivery

76 lines 5.17 kB
"use strict"; /* * Copyright © 2018 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 }); const sdm_1 = require("@atomist/sdm"); const build = require("@atomist/sdm/dsl/buildDsl"); const commonGoals_1 = require("@atomist/sdm/goal/common/commonGoals"); const httpServiceGoals_1 = require("@atomist/sdm/goal/common/httpServiceGoals"); const libraryGoals_1 = require("@atomist/sdm/goal/common/libraryGoals"); const npmGoals_1 = require("@atomist/sdm/goal/common/npmGoals"); const SetDeployEnablement_1 = require("@atomist/sdm/handlers/commands/SetDeployEnablement"); const RequestK8sDeploys_1 = require("@atomist/sdm/handlers/events/delivery/deploy/k8s/RequestK8sDeploys"); const K8AutomationBuilder_1 = require("@atomist/sdm/internal/delivery/build/k8s/K8AutomationBuilder"); const machineFactory_1 = require("@atomist/sdm/machine/machineFactory"); const jvmPushTests_1 = require("@atomist/sdm/mapping/pushtest/jvm/jvmPushTests"); const nodePushTests_1 = require("@atomist/sdm/mapping/pushtest/node/nodePushTests"); const toPublicRepo_1 = require("@atomist/sdm/mapping/pushtest/toPublicRepo"); const lookFor200OnEndpointRootGet_1 = require("@atomist/sdm/util/verify/lookFor200OnEndpointRootGet"); const addK8sSpec_1 = require("../commands/editors/k8s/addK8sSpec"); const k8sSpecPushTest_1 = require("../commands/editors/k8s/k8sSpecPushTest"); const k8sDeploy_1 = require("../deploy/k8sDeploy"); const localDeploymentGoals_1 = require("../deploy/localDeploymentGoals"); const suggestAddingK8sSpec_1 = require("../listener/channel-link/suggestAddingK8sSpec"); const demoEditors_1 = require("../pack/demo-editors/demoEditors"); const javaSupport_1 = require("../pack/java/javaSupport"); const materialChangeToJavaRepo_1 = require("../pack/spring/pushtest/materialChangeToJavaRepo"); const springPushTests_1 = require("../pack/spring/pushtest/springPushTests"); const springSupport_1 = require("../pack/spring/springSupport"); const teamPolicies_1 = require("./teamPolicies"); function k8sMachine(configuration) { const sdm = machineFactory_1.createSoftwareDeliveryMachine({ name: "K8s software delivery machine", configuration, }, sdm_1.whenPushSatisfies(jvmPushTests_1.IsMaven, sdm_1.not(materialChangeToJavaRepo_1.MaterialChangeToJavaRepo)) .itMeans("Immaterial change") .setGoals(commonGoals_1.NoGoals), sdm_1.whenPushSatisfies(sdm_1.ToDefaultBranch, jvmPushTests_1.IsMaven, springPushTests_1.HasSpringBootApplicationClass, k8sSpecPushTest_1.HasK8Spec, toPublicRepo_1.ToPublicRepo, sdm_1.IsDeployEnabled) .itMeans("Spring Boot service to deploy") .setGoals(httpServiceGoals_1.HttpServiceGoals), sdm_1.whenPushSatisfies(sdm_1.not(sdm_1.FromAtomist), jvmPushTests_1.IsMaven, springPushTests_1.HasSpringBootApplicationClass) .itMeans("Spring Boot service local deploy") .setGoals(localDeploymentGoals_1.LocalDeploymentGoals), sdm_1.whenPushSatisfies(jvmPushTests_1.IsMaven, materialChangeToJavaRepo_1.MaterialChangeToJavaRepo) .itMeans("Build Java") .setGoals(libraryGoals_1.LibraryGoals), sdm_1.whenPushSatisfies(nodePushTests_1.IsNode, sdm_1.IsDeployEnabled, sdm_1.ToDefaultBranch) .itMeans("Build and deploy node") .setGoals(npmGoals_1.NpmDeployGoals), sdm_1.whenPushSatisfies(nodePushTests_1.IsNode) .itMeans("Build with npm") .setGoals(npmGoals_1.NpmBuildGoals)); sdm.addBuildRules(build.setDefault(new K8AutomationBuilder_1.K8sAutomationBuilder())) .addGoalImplementation("K8TestDeploy", sdm_1.StagingDeploymentGoal, RequestK8sDeploys_1.requestDeployToK8s(k8sDeploy_1.K8sTestingDomain)) .addGoalImplementation("K8ProductionDeploy", sdm_1.ProductionDeploymentGoal, RequestK8sDeploys_1.requestDeployToK8s(k8sDeploy_1.K8sProductionDomain)) .addChannelLinkListeners(suggestAddingK8sSpec_1.SuggestAddingK8sSpec) .addSupportingCommands(() => addK8sSpec_1.AddK8sSpec, SetDeployEnablement_1.enableDeploy, SetDeployEnablement_1.disableDeploy) .addSupportingEvents(() => k8sDeploy_1.NoticeK8sTestDeployCompletion, () => k8sDeploy_1.noticeK8sProdDeployCompletion(sdm.configuration.sdm.repoRefResolver)) .addEndpointVerificationListeners(lookFor200OnEndpointRootGet_1.lookFor200OnEndpointRootGet({ retries: 15, maxTimeout: 5000, minTimeout: 3000, })); sdm.addExtensionPacks(demoEditors_1.DemoEditors, javaSupport_1.JavaSupport, springSupport_1.SpringSupport); teamPolicies_1.addTeamPolicies(sdm); return sdm; } exports.k8sMachine = k8sMachine; //# sourceMappingURL=k8sMachine.js.map