1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var __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 | };
|
25 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | const sdm_1 = require("@atomist/sdm");
|
27 | const DockerPerBranchDeployer_1 = require("./DockerPerBranchDeployer");
|
28 |
|
29 |
|
30 |
|
31 | exports.DockerDeployGoal = new sdm_1.Goal({
|
32 | uniqueName: "docker-deploy",
|
33 | displayName: "docker deploy",
|
34 | environment: sdm_1.IndependentOfEnvironment,
|
35 | workingDescription: "Deploying using Docker",
|
36 | completedDescription: "Deployed with Docker",
|
37 | failedDescription: "Docker deployment failed",
|
38 | });
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | class DockerDeploy extends sdm_1.FulfillableGoalWithRegistrations {
|
44 | constructor(goalDetailsOrUniqueName = sdm_1.DefaultGoalNameGenerator.generateName("docker-deploy"), ...dependsOn) {
|
45 | super(Object.assign({}, exports.DockerDeployGoal.definition, sdm_1.getGoalDefinitionFrom(goalDetailsOrUniqueName, sdm_1.DefaultGoalNameGenerator.generateName("docker-deploy")), { displayName: "version" }), ...dependsOn);
|
46 | this.goalDetailsOrUniqueName = goalDetailsOrUniqueName;
|
47 | }
|
48 | with(registration) {
|
49 | this.addFulfillment(Object.assign({ goalExecutor: executeDockerRun({
|
50 | successPatterns: registration.successPatterns,
|
51 | lowerPort: registration.lowerPort ? registration.lowerPort : 9090,
|
52 | baseUrl: registration.baseUrl ? registration.baseUrl : "http://127.0.0.1",
|
53 | sourcePort: registration.sourcePort,
|
54 | }), name: sdm_1.DefaultGoalNameGenerator.generateName("docker-runner") }, registration));
|
55 | return this;
|
56 | }
|
57 | }
|
58 | exports.DockerDeploy = DockerDeploy;
|
59 | function executeDockerRun(options) {
|
60 | const deployer = new DockerPerBranchDeployer_1.DockerPerBranchDeployer(options);
|
61 | return (goalInvocation) => __awaiter(this, void 0, void 0, function* () {
|
62 | return deployer.deployProject(goalInvocation).then(deployment => {
|
63 | return {
|
64 | code: 0,
|
65 | targetUrl: deployment.endpoint,
|
66 | };
|
67 | }).catch(reason => {
|
68 | return {
|
69 | code: 1,
|
70 | message: reason,
|
71 | };
|
72 | });
|
73 | });
|
74 | }
|
75 |
|
\ | No newline at end of file |