UNPKG

3.38 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 */
17var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18 return new (P || (P = Promise))(function (resolve, reject) {
19 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
22 step((generator = generator.apply(thisArg, _arguments || [])).next());
23 });
24};
25Object.defineProperty(exports, "__esModule", { value: true });
26const sdm_1 = require("@atomist/sdm");
27const DockerProgressReporter_1 = require("./DockerProgressReporter");
28const executeDockerBuild_1 = require("./executeDockerBuild");
29const DefaultDockerOptions = {
30 dockerImageNameCreator: executeDockerBuild_1.DefaultDockerImageNameCreator,
31 dockerfileFinder: () => __awaiter(this, void 0, void 0, function* () { return "Dockerfile"; }),
32 push: false,
33 builder: "docker",
34 builderArgs: [],
35};
36/**
37 * Goal that performs docker build and push depending on the provided options
38 */
39class DockerBuild extends sdm_1.FulfillableGoalWithRegistrations {
40 constructor(goalDetailsOrUniqueName = sdm_1.DefaultGoalNameGenerator.generateName("docker-build"), ...dependsOn) {
41 super(sdm_1.getGoalDefinitionFrom(goalDetailsOrUniqueName, sdm_1.DefaultGoalNameGenerator.generateName("docker-build"), DockerBuildDefinition), ...dependsOn);
42 this.goalDetailsOrUniqueName = goalDetailsOrUniqueName;
43 }
44 with(registration) {
45 const optsToUse = sdm_1.mergeOptions(DefaultDockerOptions, registration.options);
46 // Backwards compatibility
47 // tslint:disable:deprecation
48 if (!!registration.imageNameCreator && (!registration.options || !registration.options.dockerImageNameCreator)) {
49 optsToUse.dockerImageNameCreator = registration.imageNameCreator;
50 }
51 // tslint:enable:deprecation
52 this.addFulfillment(Object.assign({ goalExecutor: executeDockerBuild_1.executeDockerBuild(optsToUse), name: sdm_1.DefaultGoalNameGenerator.generateName("docker-builder"), progressReporter: DockerProgressReporter_1.DockerProgressReporter }, registration));
53 return this;
54 }
55}
56exports.DockerBuild = DockerBuild;
57const DockerBuildDefinition = {
58 uniqueName: "docker-build",
59 displayName: "docker build",
60 environment: sdm_1.IndependentOfEnvironment,
61 workingDescription: "Running docker build",
62 completedDescription: "Docker build successful",
63 failedDescription: "Docker build failed",
64 isolated: true,
65 retryFeasible: true,
66};
67//# sourceMappingURL=DockerBuild.js.map
\No newline at end of file