UNPKG

@atomist/sdm-core

Version:

Atomist Software Delivery Machine - Implementation

61 lines 2.72 kB
"use strict"; /* * Copyright © 2019 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 automation_client_1 = require("@atomist/automation-client"); const sdm_1 = require("@atomist/sdm"); const cluster = require("cluster"); const _ = require("lodash"); const modes_1 = require("../../internal/machine/modes"); const cancelGoals_1 = require("./cancelGoals"); const manageGoalSets_1 = require("./manageGoalSets"); const resetGoals_1 = require("./resetGoals"); const setGoalState_1 = require("./setGoalState"); /** * Allow goal setting */ function goalStateSupport(options) { return Object.assign(Object.assign({}, sdm_1.metadata("goal-state")), { configure: sdm => { if (modes_1.isInLocalMode()) { automation_client_1.logger.warn("Setting goal state is not available in local mode."); automation_client_1.logger.warn("Resetting goals does not work in local mode. Use `atomist trigger post-commit` instead."); } else { sdm.addCommand(setGoalState_1.setGoalStateCommand(sdm)); sdm.addCommand(resetGoals_1.resetGoalsCommand(sdm)); sdm.addCommand(cancelGoals_1.cancelGoalSetsCommand(sdm)); sdm.addCommand(cancelGoals_1.listPendingGoalSetsCommand(sdm)); if ((cluster.isMaster || !_.get(sdm.configuration, "cluster.enabled")) && !process.env.ATOMIST_ISOLATED_GOAL && !!options && !!options.cancellation && !!options.cancellation.enabled) { automation_client_1.logger.debug(`Timeout based goal cancellation enabled for this SDM`); sdm.addTriggeredListener({ trigger: { interval: 1000 * 30 }, listener: manageGoalSets_1.manageGoalSetsTrigger(options.cancellation), }); } } } }); } exports.goalStateSupport = goalStateSupport; /** * @deprecated use goalStateSupport */ function goalState() { return goalStateSupport(); } exports.goalState = goalState; //# sourceMappingURL=goalState.js.map