@datadog/datadog-ci-plugin-dora 3.21.0 → 3.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.ts +8 -0
- package/dist/api.js +58 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +5 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/deployment.d.ts +12 -0
- package/dist/commands/deployment.js +143 -0
- package/dist/commands/deployment.js.map +1 -0
- package/dist/interfaces.d.ts +18 -0
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/renderer.d.ts +8 -0
- package/dist/renderer.js +24 -0
- package/dist/renderer.js.map +1 -0
- package/package.json +10 -3
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { DeploymentEvent } from './interfaces';
|
|
3
|
+
export declare const datadogSite: string;
|
|
4
|
+
export declare const apiUrl: string;
|
|
5
|
+
export declare const sendDeploymentEvent: (request: (args: AxiosRequestConfig) => AxiosPromise<AxiosResponse>) => (deployment: DeploymentEvent) => Promise<AxiosResponse<AxiosResponse<any, any>, any>>;
|
|
6
|
+
export declare const apiConstructor: (apiKey: string) => {
|
|
7
|
+
sendDeploymentEvent: (deployment: DeploymentEvent) => Promise<AxiosResponse<AxiosResponse<any, any>, any>>;
|
|
8
|
+
};
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.apiConstructor = exports.sendDeploymentEvent = exports.apiUrl = exports.datadogSite = void 0;
|
|
13
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
14
|
+
exports.datadogSite = process.env.DD_SITE || 'datadoghq.com';
|
|
15
|
+
exports.apiUrl = `https://api.${exports.datadogSite}`;
|
|
16
|
+
const sendDeploymentEvent = (request) => (deployment) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const attrs = {
|
|
18
|
+
service: deployment.service,
|
|
19
|
+
started_at: deployment.startedAt.getTime() * 1e6,
|
|
20
|
+
finished_at: deployment.finishedAt.getTime() * 1e6, // ms to ns
|
|
21
|
+
};
|
|
22
|
+
if (deployment.env) {
|
|
23
|
+
attrs.env = deployment.env;
|
|
24
|
+
}
|
|
25
|
+
if (deployment.version) {
|
|
26
|
+
attrs.version = deployment.version;
|
|
27
|
+
}
|
|
28
|
+
if (deployment.git) {
|
|
29
|
+
attrs.git = {
|
|
30
|
+
repository_url: deployment.git.repoURL,
|
|
31
|
+
commit_sha: deployment.git.commitSHA,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (deployment.team) {
|
|
35
|
+
attrs.team = deployment.team;
|
|
36
|
+
}
|
|
37
|
+
if (deployment.customTags) {
|
|
38
|
+
attrs.custom_tags = deployment.customTags;
|
|
39
|
+
}
|
|
40
|
+
return request({
|
|
41
|
+
method: 'POST',
|
|
42
|
+
url: 'api/v2/dora/deployment',
|
|
43
|
+
data: {
|
|
44
|
+
data: {
|
|
45
|
+
attributes: attrs,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
exports.sendDeploymentEvent = sendDeploymentEvent;
|
|
51
|
+
const apiConstructor = (apiKey) => {
|
|
52
|
+
const requestAPI = (0, utils_1.getRequestBuilder)({ baseUrl: exports.apiUrl, apiKey });
|
|
53
|
+
return {
|
|
54
|
+
sendDeploymentEvent: (0, exports.sendDeploymentEvent)(requestAPI),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
exports.apiConstructor = apiConstructor;
|
|
58
|
+
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,kEAAwE;AAI3D,QAAA,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,eAAe,CAAA;AACpD,QAAA,MAAM,GAAG,eAAe,mBAAW,EAAE,CAAA;AAE3C,MAAM,mBAAmB,GAC9B,CAAC,OAAkE,EAAE,EAAE,CAAC,CAAO,UAA2B,EAAE,EAAE;IAC5G,MAAM,KAAK,GAAwB;QACjC,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,GAAG;QAChD,WAAW,EAAE,UAAU,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,GAAG,EAAE,WAAW;KAChE,CAAA;IACD,IAAI,UAAU,CAAC,GAAG,EAAE;QAClB,KAAK,CAAC,GAAG,GAAG,UAAU,CAAC,GAAG,CAAA;KAC3B;IACD,IAAI,UAAU,CAAC,OAAO,EAAE;QACtB,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,OAAO,CAAA;KACnC;IACD,IAAI,UAAU,CAAC,GAAG,EAAE;QAClB,KAAK,CAAC,GAAG,GAAG;YACV,cAAc,EAAE,UAAU,CAAC,GAAG,CAAC,OAAO;YACtC,UAAU,EAAE,UAAU,CAAC,GAAG,CAAC,SAAS;SACrC,CAAA;KACF;IACD,IAAI,UAAU,CAAC,IAAI,EAAE;QACnB,KAAK,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,CAAA;KAC7B;IACD,IAAI,UAAU,CAAC,UAAU,EAAE;QACzB,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,UAAU,CAAA;KAC1C;IAED,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,wBAAwB;QAC7B,IAAI,EAAE;YACJ,IAAI,EAAE;gBACJ,UAAU,EAAE,KAAK;aAClB;SACF;KACF,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAnCU,QAAA,mBAAmB,uBAmC7B;AAEI,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,EAAE;IAC/C,MAAM,UAAU,GAAG,IAAA,yBAAiB,EAAC,EAAC,OAAO,EAAE,cAAM,EAAE,MAAM,EAAC,CAAC,CAAA;IAE/D,OAAO;QACL,mBAAmB,EAAE,IAAA,2BAAmB,EAAC,UAAU,CAAC;KACrD,CAAA;AACH,CAAC,CAAA;AANY,QAAA,cAAc,kBAM1B"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/cli.js
ADDED
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;AAAA,sDAA4E;AAE5E,MAAM,CAAC,OAAO,GAAG,CAAC,0BAAqB,CAAC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DORADeploymentCommand } from '@datadog/datadog-ci-base/commands/dora/deployment-command';
|
|
2
|
+
export declare class PluginCommand extends DORADeploymentCommand {
|
|
3
|
+
private config;
|
|
4
|
+
private logger;
|
|
5
|
+
private service;
|
|
6
|
+
private gitInfo?;
|
|
7
|
+
execute(): Promise<1 | undefined>;
|
|
8
|
+
private getGitInfo;
|
|
9
|
+
private getApiHelper;
|
|
10
|
+
private buildDeploymentEvent;
|
|
11
|
+
private sendDeploymentEvent;
|
|
12
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.PluginCommand = void 0;
|
|
16
|
+
const deployment_command_1 = require("@datadog/datadog-ci-base/commands/dora/deployment-command");
|
|
17
|
+
const constants_1 = require("@datadog/datadog-ci-base/constants");
|
|
18
|
+
const env_1 = require("@datadog/datadog-ci-base/helpers/env");
|
|
19
|
+
const fips_1 = require("@datadog/datadog-ci-base/helpers/fips");
|
|
20
|
+
const get_git_data_1 = require("@datadog/datadog-ci-base/helpers/git/get-git-data");
|
|
21
|
+
const logger_1 = require("@datadog/datadog-ci-base/helpers/logger");
|
|
22
|
+
const retry_1 = require("@datadog/datadog-ci-base/helpers/retry");
|
|
23
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
24
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
25
|
+
const api_1 = require("../api");
|
|
26
|
+
const renderer_1 = require("../renderer");
|
|
27
|
+
const nonRetriableErrorCodes = [400, 403];
|
|
28
|
+
class PluginCommand extends deployment_command_1.DORADeploymentCommand {
|
|
29
|
+
constructor() {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.config = {
|
|
33
|
+
apiKey: process.env.DATADOG_API_KEY || process.env.DD_API_KEY,
|
|
34
|
+
fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
|
|
35
|
+
fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
|
|
36
|
+
};
|
|
37
|
+
this.logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO);
|
|
38
|
+
}
|
|
39
|
+
execute() {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
(0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
|
|
42
|
+
this.logger.setLogLevel(this.verbose ? logger_1.LogLevel.DEBUG : logger_1.LogLevel.INFO);
|
|
43
|
+
this.logger.setShouldIncludeTime(this.verbose);
|
|
44
|
+
if (this.serviceParam) {
|
|
45
|
+
this.service = this.serviceParam;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.logger.error('Missing service. It must be provided with --service or the DD_SERVICE env var');
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
if (this.startedAt > (this.finishedAt || new Date())) {
|
|
52
|
+
this.logger.error('--started-at cannot be after --finished-at');
|
|
53
|
+
return 1;
|
|
54
|
+
}
|
|
55
|
+
if (this.skipGit) {
|
|
56
|
+
this.gitInfo = undefined;
|
|
57
|
+
}
|
|
58
|
+
else if (this.gitRepoURL && this.gitCommitSHA) {
|
|
59
|
+
this.gitInfo = { repoURL: this.gitRepoURL, commitSHA: this.gitCommitSHA };
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.gitInfo = yield this.getGitInfo();
|
|
63
|
+
this.logger.warn((0, renderer_1.renderGitWarning)(this.gitInfo));
|
|
64
|
+
}
|
|
65
|
+
const api = this.getApiHelper();
|
|
66
|
+
yield this.sendDeploymentEvent(api, this.buildDeploymentEvent());
|
|
67
|
+
if (!this.dryRun) {
|
|
68
|
+
this.logger.info((0, renderer_1.renderSuccessfulRequest)(this.service));
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
getGitInfo() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const git = (0, simple_git_1.default)({
|
|
75
|
+
baseDir: process.cwd(),
|
|
76
|
+
binary: 'git',
|
|
77
|
+
// We are invoking at most 5 git commands at the same time.
|
|
78
|
+
maxConcurrentProcesses: 5,
|
|
79
|
+
});
|
|
80
|
+
const [repoURL, commitSHA] = yield Promise.all([(0, get_git_data_1.gitRepositoryURL)(git), (0, get_git_data_1.gitHash)(git)]);
|
|
81
|
+
return { repoURL, commitSHA };
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
getApiHelper() {
|
|
85
|
+
if (!this.config.apiKey) {
|
|
86
|
+
this.logger.error(`Neither ${chalk_1.default.red.bold('DATADOG_API_KEY')} nor ${chalk_1.default.red.bold('DD_API_KEY')} is in your environment.`);
|
|
87
|
+
throw new Error('API key is missing');
|
|
88
|
+
}
|
|
89
|
+
return (0, api_1.apiConstructor)(this.config.apiKey);
|
|
90
|
+
}
|
|
91
|
+
buildDeploymentEvent() {
|
|
92
|
+
const deployment = {
|
|
93
|
+
service: this.service,
|
|
94
|
+
startedAt: this.startedAt,
|
|
95
|
+
finishedAt: this.finishedAt || new Date(),
|
|
96
|
+
};
|
|
97
|
+
if (this.env) {
|
|
98
|
+
deployment.env = this.env;
|
|
99
|
+
}
|
|
100
|
+
if (this.gitInfo) {
|
|
101
|
+
deployment.git = this.gitInfo;
|
|
102
|
+
}
|
|
103
|
+
if (this.version) {
|
|
104
|
+
deployment.version = this.version;
|
|
105
|
+
}
|
|
106
|
+
if (this.team) {
|
|
107
|
+
deployment.team = this.team;
|
|
108
|
+
}
|
|
109
|
+
if (this.customTags) {
|
|
110
|
+
deployment.customTags = this.customTags;
|
|
111
|
+
}
|
|
112
|
+
return deployment;
|
|
113
|
+
}
|
|
114
|
+
sendDeploymentEvent(api, deployment) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
if (this.dryRun) {
|
|
117
|
+
this.logger.info((0, renderer_1.renderDryRun)(deployment));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
try {
|
|
121
|
+
this.logger.info((0, renderer_1.renderRequest)(this.service));
|
|
122
|
+
yield (0, retry_1.retryRequest)(() => api.sendDeploymentEvent(deployment), {
|
|
123
|
+
onRetry: (e, attempt) => {
|
|
124
|
+
this.logger.warn((0, renderer_1.renderRetriedRequest)(this.service, e, attempt));
|
|
125
|
+
},
|
|
126
|
+
retries: 5,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
this.logger.error((0, renderer_1.renderFailedRequest)(this.service, error));
|
|
131
|
+
if (error.response) {
|
|
132
|
+
// If it's an axios error
|
|
133
|
+
if (!nonRetriableErrorCodes.includes(error.response.status)) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.PluginCommand = PluginCommand;
|
|
143
|
+
//# sourceMappingURL=deployment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deployment.js","sourceRoot":"","sources":["../../src/commands/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kGAA+F;AAC/F,kEAA0F;AAC1F,8DAA8D;AAC9D,gEAAgE;AAChE,oFAA2F;AAC3F,oEAAwE;AACxE,kEAAmE;AAEnE,kDAAyB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BAAmB,CAAC,GAAc,EAAE,UAA2B;;YAC3E,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,uBAAY,EAAC,UAAU,CAAC,CAAC,CAAA;gBAE1C,OAAM;aACP;YAED,IAAI;gBACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,wBAAa,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;gBAC7C,MAAM,IAAA,oBAAY,EAAC,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,UAAU,CAAC,EAAE;oBAC5D,OAAO,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE;wBACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAA,+BAAoB,EAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;oBAClE,CAAC;oBACD,OAAO,EAAE,CAAC;iBACX,CAAC,CAAA;aACH;YAAC,OAAO,KAAK,EAAE;gBACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,8BAAmB,EAAC,IAAI,CAAC,OAAO,EAAE,KAAmB,CAAC,CAAC,CAAA;gBACzE,IAAI,KAAK,CAAC,QAAQ,EAAE;oBAClB,yBAAyB;oBACzB,IAAI,CAAC,sBAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;wBAC3D,OAAM;qBACP;iBACF;gBACD,MAAM,KAAK,CAAA;aACZ;QACH,CAAC;KAAA;CACF;AA3HD,sCA2HC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AxiosPromise, AxiosResponse } from 'axios';
|
|
2
|
+
export interface DeploymentEvent {
|
|
3
|
+
service: string;
|
|
4
|
+
env?: string;
|
|
5
|
+
startedAt: Date;
|
|
6
|
+
finishedAt: Date;
|
|
7
|
+
git?: GitInfo;
|
|
8
|
+
version?: string;
|
|
9
|
+
team?: string;
|
|
10
|
+
customTags?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface GitInfo {
|
|
13
|
+
repoURL: string;
|
|
14
|
+
commitSHA: string;
|
|
15
|
+
}
|
|
16
|
+
export interface APIHelper {
|
|
17
|
+
sendDeploymentEvent(deployment: DeploymentEvent): AxiosPromise<AxiosResponse>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosError } from 'axios';
|
|
2
|
+
import { DeploymentEvent, GitInfo } from './interfaces';
|
|
3
|
+
export declare const renderFailedRequest: (service: string, error: AxiosError) => string;
|
|
4
|
+
export declare const renderRetriedRequest: (service: string, error: Error, attempt: number) => string;
|
|
5
|
+
export declare const renderSuccessfulRequest: (service: string) => string;
|
|
6
|
+
export declare const renderDryRun: (deployment: DeploymentEvent) => string;
|
|
7
|
+
export declare const renderRequest: (service: string) => string;
|
|
8
|
+
export declare const renderGitWarning: (git: GitInfo) => string;
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderGitWarning = exports.renderRequest = exports.renderDryRun = exports.renderSuccessfulRequest = exports.renderRetriedRequest = exports.renderFailedRequest = void 0;
|
|
4
|
+
const ICONS = {
|
|
5
|
+
FAILED: '❌',
|
|
6
|
+
SUCCESS: '✅',
|
|
7
|
+
WARNING: '⚠️',
|
|
8
|
+
};
|
|
9
|
+
const renderFailedRequest = (service, error) => `${ICONS.FAILED} Failed to send DORA deployment event for service: ${service}: ` +
|
|
10
|
+
(error.response ? JSON.stringify(error.response.data, undefined, 2) : '');
|
|
11
|
+
exports.renderFailedRequest = renderFailedRequest;
|
|
12
|
+
const renderRetriedRequest = (service, error, attempt) => `[attempt ${attempt}] Retrying to send DORA deployment event for service: ${service}: ${error.message}`;
|
|
13
|
+
exports.renderRetriedRequest = renderRetriedRequest;
|
|
14
|
+
const renderSuccessfulRequest = (service) => `${ICONS.SUCCESS} Successfully sent DORA deployment event for service: ${service}`;
|
|
15
|
+
exports.renderSuccessfulRequest = renderSuccessfulRequest;
|
|
16
|
+
const renderDryRun = (deployment) => `[DRYRUN] ${(0, exports.renderRequest)(deployment.service)}\n data: ` + JSON.stringify(deployment, undefined, 2);
|
|
17
|
+
exports.renderDryRun = renderDryRun;
|
|
18
|
+
const renderRequest = (service) => `Sending DORA deployment event for service: ${service}`;
|
|
19
|
+
exports.renderRequest = renderRequest;
|
|
20
|
+
const renderGitWarning = (git) => `${ICONS.WARNING} --git-repository-url or --git-commit-sha not provided.\n` +
|
|
21
|
+
`Assuming deployment of the current HEAD commit: ${git.repoURL} ${git.commitSHA}\n` +
|
|
22
|
+
`This warning can be disabled with --skip-git but git data is required for Change Lead Time.`;
|
|
23
|
+
exports.renderGitWarning = renderGitWarning;
|
|
24
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":";;;AAIA,MAAM,KAAK,GAAG;IACZ,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,IAAI;CACd,CAAA;AAEM,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,KAAiB,EAAE,EAAE,CACxE,GAAG,KAAK,CAAC,MAAM,sDAAsD,OAAO,IAAI;IAChF,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAF9D,QAAA,mBAAmB,uBAE2C;AAEpE,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,KAAY,EAAE,OAAe,EAAE,EAAE,CACrF,YAAY,OAAO,yDAAyD,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAA;AAD5F,QAAA,oBAAoB,wBACwE;AAElG,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAE,EAAE,CACzD,GAAG,KAAK,CAAC,OAAO,yDAAyD,OAAO,EAAE,CAAA;AADvE,QAAA,uBAAuB,2BACgD;AAE7E,MAAM,YAAY,GAAG,CAAC,UAA2B,EAAU,EAAE,CAClE,YAAY,IAAA,qBAAa,EAAC,UAAU,CAAC,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;AADxF,QAAA,YAAY,gBAC4E;AAE9F,MAAM,aAAa,GAAG,CAAC,OAAe,EAAU,EAAE,CAAC,8CAA8C,OAAO,EAAE,CAAA;AAApG,QAAA,aAAa,iBAAuF;AAE1G,MAAM,gBAAgB,GAAG,CAAC,GAAY,EAAU,EAAE,CACvD,GAAG,KAAK,CAAC,OAAO,2DAA2D;IAC3E,mDAAmD,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,SAAS,IAAI;IACnF,6FAA6F,CAAA;AAHlF,QAAA,gBAAgB,oBAGkE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datadog/datadog-ci-plugin-dora",
|
|
3
|
-
"version": "3.21.
|
|
3
|
+
"version": "3.21.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
+
"description": "Datadog CI plugin for `dora` commands",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"datadog",
|
|
8
|
+
"datadog-ci",
|
|
9
|
+
"plugin"
|
|
10
|
+
],
|
|
5
11
|
"homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/plugin-dora",
|
|
6
12
|
"repository": {
|
|
7
13
|
"type": "git",
|
|
@@ -9,6 +15,7 @@
|
|
|
9
15
|
"directory": "packages/plugin-dora"
|
|
10
16
|
},
|
|
11
17
|
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
12
19
|
"./commands/*": {
|
|
13
20
|
"development": "./src/commands/*.ts",
|
|
14
21
|
"default": "./dist/commands/*.js"
|
|
@@ -28,10 +35,10 @@
|
|
|
28
35
|
"prepack": "yarn package:clean-dist"
|
|
29
36
|
},
|
|
30
37
|
"peerDependencies": {
|
|
31
|
-
"@datadog/datadog-ci": "3.21.
|
|
38
|
+
"@datadog/datadog-ci": "3.21.2"
|
|
32
39
|
},
|
|
33
40
|
"dependencies": {
|
|
34
|
-
"@datadog/datadog-ci-base": "3.21.
|
|
41
|
+
"@datadog/datadog-ci-base": "3.21.2",
|
|
35
42
|
"axios": "^1.11.0",
|
|
36
43
|
"chalk": "3.0.0",
|
|
37
44
|
"simple-git": "3.16.0"
|