@datadog/datadog-ci-plugin-deployment 3.21.1
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/LICENSE +201 -0
- package/README.md +109 -0
- package/dist/api.d.ts +2 -0
- package/dist/api.js +46 -0
- package/dist/api.js.map +1 -0
- package/dist/cli.d.ts +5 -0
- package/dist/cli.js +14 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/correlate-image.d.ts +7 -0
- package/dist/commands/correlate-image.js +109 -0
- package/dist/commands/correlate-image.js.map +1 -0
- package/dist/commands/correlate.d.ts +9 -0
- package/dist/commands/correlate.js +154 -0
- package/dist/commands/correlate.js.map +1 -0
- package/dist/commands/gate.d.ts +17 -0
- package/dist/commands/gate.js +269 -0
- package/dist/commands/gate.js.map +1 -0
- package/dist/commands/mark.d.ts +7 -0
- package/dist/commands/mark.js +78 -0
- package/dist/commands/mark.js.map +1 -0
- package/dist/constants.d.ts +8 -0
- package/dist/constants.js +12 -0
- package/dist/constants.js.map +1 -0
- package/dist/interfaces.d.ts +43 -0
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2020 Datadog, Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Deployment command
|
|
2
|
+
|
|
3
|
+
Contains helper commands related to CD Visibility.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Commands
|
|
8
|
+
|
|
9
|
+
#### `mark`
|
|
10
|
+
|
|
11
|
+
The `mark` command specifies that a CI job executes a deployment.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
datadog-ci deployment mark [--env] [--revision] [--service] [--is-rollback] [--tags] [--no-fail]
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
For example:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
datadog-ci deployment mark --env prod --service payment-service --revision v1.1.0 --tags team:backend --no-fail
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- `--env` is the environment to which this deployment is performed. For example, `prod`.
|
|
24
|
+
- `--revision` is the revision/version that is being deployed. For example, `1.0.0` or `v123-456`.
|
|
25
|
+
- `--service` the name of the service being deployed. For example, `payment-service`.
|
|
26
|
+
- `--is-rollback` specifies that the deployment is a rollback.
|
|
27
|
+
- `--tags` is an array of key value pairs in the format `key:value`. These tags are added to the deployment event shown in Datadog.
|
|
28
|
+
- `--no-fail` (default: `false`) prevents the deployment command from failing if there are issues submitting the data.
|
|
29
|
+
|
|
30
|
+
### `correlate`
|
|
31
|
+
|
|
32
|
+
**Note**: If you are using `datadog-ci deployment mark`, then you do not need to use this command, as the correlation is made automatically.
|
|
33
|
+
|
|
34
|
+
The `correlate` command connects a GitOps deployment with the CI pipeline of the application repository. Once they are connected, you can see in Datadog's UI which pipeline
|
|
35
|
+
triggered a deployment, and which deployments were triggered by a pipeline.
|
|
36
|
+
|
|
37
|
+
**Important**: This command does not work for every setup. Refer to the [documentation][3] for more details.
|
|
38
|
+
|
|
39
|
+
For example:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
datadog-ci deployment correlate --provider argocd
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
- `--provider` (**required**): the CD provider name. Currently, the only supported CD provider is `argocd`.
|
|
46
|
+
- `--config-repo`: configuration repository URL where the kubernetes manifests are stored. If empty, the command tries to get it using the git command `git ls-remote --get-url`.
|
|
47
|
+
- `--config-shas`: a list of the Git commit SHAs of the configuration repository. If empty, the command tries to get all local commits using a `git log` command.
|
|
48
|
+
- `--dry-run` (default: `false`): prevents the command from sending any data to Datadog. All the other checks are still performed.
|
|
49
|
+
|
|
50
|
+
### `correlate-image`
|
|
51
|
+
|
|
52
|
+
**Note**: This command replaces `datadog-ci deployment correlate`.
|
|
53
|
+
|
|
54
|
+
The `correlate-image` command connects an image generated on CI with a commit of the application repository. Then, when Datadog receives a deployment that deploys your image,
|
|
55
|
+
the deployment is correlated to the application commit. This allows for correlation between configuration and application repositories in GitOps scenarios.
|
|
56
|
+
|
|
57
|
+
**Important**: This command does not work for every setup. Refer to the [documentation][3] for more details.
|
|
58
|
+
|
|
59
|
+
For example:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
datadog-ci deployment correlate-image --commit-sha c9c4e93346652f426c91a2c41364679698bc492f --repository-url https://github.com/DataDog/datadog-ci --image datadog-ci:sha@038d890a9c01bc90a634fafedbd1c2fcd05cd95f
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- `--commit-sha` (**required**): Commit SHA to correlate with an image. Should be from the application repository.
|
|
66
|
+
- `--repository-url` (**required**): Repository URL for the commit SHA being correlated.
|
|
67
|
+
- `--image` (**required**): Image to correlate with the commit SHA.
|
|
68
|
+
|
|
69
|
+
### `gate`
|
|
70
|
+
|
|
71
|
+
The `gate` command evaluates a Deployment Gate and exits with code 0 if the gate passed or 1 if the gate failed. Refer to the [Deployment Gates documentation][4] for more details.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
datadog-ci deployment gate --service --env [--identifier] [--version] [--apm-primary-tag] [--timeout] [--fail-on-error]
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For example:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
datadog-ci deployment gate --service payments-backend --env prod
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
- `--service` (**required**): Service name. For example `payments-backend`.
|
|
84
|
+
- `--env` (**required**): Environment name. For example `prod`.
|
|
85
|
+
- `--identifier` (default: `default`): Deployment Gate identifier. For example, `pre`.
|
|
86
|
+
- `--version` (**required** if your gate has faulty deployment detection rules): Version that is being deployed. For example, `v1.0.3`.
|
|
87
|
+
- `--apm-primary-tag`: APM primary tag (only for gates with faulty deployment detection rules). For example, `region:us-central-1`.
|
|
88
|
+
- `--timeout` (default: 10800 = 3 hours): Maximum time to wait for the script execution in seconds. For example, `3600`.
|
|
89
|
+
- `--fail-on-error` (default: `false`): When false, the script will consider the gate as passed and exit with code 0 when timeout is reached or unexpected errors occur. Otherwise it will consider the gate failed and exit with code 1.
|
|
90
|
+
|
|
91
|
+
The command will exit with status 0 when the gate passes and status 1 otherwise.
|
|
92
|
+
|
|
93
|
+
### Environment variables
|
|
94
|
+
|
|
95
|
+
- `DD_API_KEY` (**required**): API key used to authenticate the requests.
|
|
96
|
+
- `DD_APP_KEY` (**required** for `correlate-image` and `gate`): APP key used to authenticate the requests.
|
|
97
|
+
- `DD_SITE`: choose your Datadog site. For example, datadoghq.com or datadoghq.eu.
|
|
98
|
+
|
|
99
|
+
## Further reading
|
|
100
|
+
|
|
101
|
+
Additional helpful documentation, links, and articles:
|
|
102
|
+
|
|
103
|
+
- [Monitor CI providers deployments][1]
|
|
104
|
+
- [Learn about Continuous Delivery][2]
|
|
105
|
+
|
|
106
|
+
[1]: https://docs.datadoghq.com/continuous_delivery/deployments/ciproviders
|
|
107
|
+
[2]: https://docs.datadoghq.com/continuous_delivery/
|
|
108
|
+
[3]: https://docs.datadoghq.com/continuous_delivery/deployments/argocd#correlate-deployments-with-ci-pipelines
|
|
109
|
+
[4]: https://docs.datadoghq.com/deployment_gates/
|
package/dist/api.d.ts
ADDED
package/dist/api.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
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 = void 0;
|
|
13
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
14
|
+
const requestGateEvaluation = (request) => (evaluationRequest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const payload = {
|
|
16
|
+
data: {
|
|
17
|
+
type: 'deployment_gates_evaluation_request',
|
|
18
|
+
attributes: Object.assign(Object.assign(Object.assign({ service: evaluationRequest.service, env: evaluationRequest.env, identifier: evaluationRequest.identifier }, (evaluationRequest.version && { version: evaluationRequest.version })), (evaluationRequest.apm_primary_tag && { apm_primary_tag: evaluationRequest.apm_primary_tag })), (evaluationRequest.monitors_query_variable && {
|
|
19
|
+
monitors_query_variable: evaluationRequest.monitors_query_variable,
|
|
20
|
+
})),
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return request({
|
|
24
|
+
data: JSON.stringify(payload),
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
},
|
|
28
|
+
method: 'POST',
|
|
29
|
+
url: '/api/unstable/deployments/gates/evaluation',
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
const getGateEvaluationResult = (request) => (evaluationId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
return request({
|
|
34
|
+
method: 'GET',
|
|
35
|
+
url: `/api/unstable/deployments/gates/evaluation/${evaluationId}`,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
const apiConstructor = (baseUrl, apiKey, appKey) => {
|
|
39
|
+
const requestBuilder = (0, utils_1.getRequestBuilder)({ baseUrl, apiKey, appKey });
|
|
40
|
+
return {
|
|
41
|
+
requestGateEvaluation: requestGateEvaluation(requestBuilder),
|
|
42
|
+
getGateEvaluationResult: getGateEvaluationResult(requestBuilder),
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
exports.apiConstructor = apiConstructor;
|
|
46
|
+
//# 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;AASxE,MAAM,qBAAqB,GACzB,CAAC,OAAkF,EAAE,EAAE,CACvF,CAAO,iBAAwC,EAAE,EAAE;IACjD,MAAM,OAAO,GAAG;QACd,IAAI,EAAE;YACJ,IAAI,EAAE,qCAAqC;YAC3C,UAAU,8CACR,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAClC,GAAG,EAAE,iBAAiB,CAAC,GAAG,EAC1B,UAAU,EAAE,iBAAiB,CAAC,UAAU,IACrC,CAAC,iBAAiB,CAAC,OAAO,IAAI,EAAC,OAAO,EAAE,iBAAiB,CAAC,OAAO,EAAC,CAAC,GACnE,CAAC,iBAAiB,CAAC,eAAe,IAAI,EAAC,eAAe,EAAE,iBAAiB,CAAC,eAAe,EAAC,CAAC,GAC3F,CAAC,iBAAiB,CAAC,uBAAuB,IAAI;gBAC/C,uBAAuB,EAAE,iBAAiB,CAAC,uBAAuB;aACnE,CAAC,CACH;SACF;KACF,CAAA;IAED,OAAO,OAAO,CAAC;QACb,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,4CAA4C;KAClD,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAEH,MAAM,uBAAuB,GAC3B,CAAC,OAAiF,EAAE,EAAE,CACtF,CAAO,YAAoB,EAAE,EAAE;IAC7B,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,8CAA8C,YAAY,EAAE;KAClE,CAAC,CAAA;AACJ,CAAC,CAAA,CAAA;AAEI,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,MAAc,EAAE,MAAc,EAAa,EAAE;IAC3F,MAAM,cAAc,GAAG,IAAA,yBAAiB,EAAC,EAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAA;IAEnE,OAAO;QACL,qBAAqB,EAAE,qBAAqB,CAAC,cAAc,CAAC;QAC5D,uBAAuB,EAAE,uBAAuB,CAAC,cAAc,CAAC;KACjE,CAAA;AACH,CAAC,CAAA;AAPY,QAAA,cAAc,kBAO1B"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PluginCommand as DeploymentCorrelateCommand } from './commands/correlate';
|
|
2
|
+
import { PluginCommand as DeploymentCorrelateImageCommand } from './commands/correlate-image';
|
|
3
|
+
import { PluginCommand as DeploymentGateCommand } from './commands/gate';
|
|
4
|
+
import { PluginCommand as DeploymentMarkCommand } from './commands/mark';
|
|
5
|
+
export declare const commands: (typeof DeploymentCorrelateCommand | typeof DeploymentCorrelateImageCommand | typeof DeploymentGateCommand | typeof DeploymentMarkCommand)[];
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.commands = void 0;
|
|
4
|
+
const correlate_1 = require("./commands/correlate");
|
|
5
|
+
const correlate_image_1 = require("./commands/correlate-image");
|
|
6
|
+
const gate_1 = require("./commands/gate");
|
|
7
|
+
const mark_1 = require("./commands/mark");
|
|
8
|
+
exports.commands = [
|
|
9
|
+
mark_1.PluginCommand,
|
|
10
|
+
correlate_1.PluginCommand,
|
|
11
|
+
correlate_image_1.PluginCommand,
|
|
12
|
+
gate_1.PluginCommand,
|
|
13
|
+
];
|
|
14
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAAA,oDAAgF;AAChF,gEAA2F;AAC3F,0CAAsE;AACtE,0CAAsE;AAEzD,QAAA,QAAQ,GAAG;IACtB,oBAAqB;IACrB,yBAA0B;IAC1B,+BAA+B;IAC/B,oBAAqB;CACtB,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DeploymentCorrelateImageCommand } from '@datadog/datadog-ci-base/commands/deployment/correlate-image-command';
|
|
2
|
+
export declare class PluginCommand extends DeploymentCorrelateImageCommand {
|
|
3
|
+
private logger;
|
|
4
|
+
private config;
|
|
5
|
+
execute(): Promise<number>;
|
|
6
|
+
private handleError;
|
|
7
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
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 correlate_image_command_1 = require("@datadog/datadog-ci-base/commands/deployment/correlate-image-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 logger_1 = require("@datadog/datadog-ci-base/helpers/logger");
|
|
21
|
+
const retry_1 = require("@datadog/datadog-ci-base/helpers/retry");
|
|
22
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
23
|
+
const axios_1 = require("axios");
|
|
24
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
25
|
+
class PluginCommand extends correlate_image_command_1.DeploymentCorrelateImageCommand {
|
|
26
|
+
constructor() {
|
|
27
|
+
var _a, _b;
|
|
28
|
+
super(...arguments);
|
|
29
|
+
this.logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO);
|
|
30
|
+
this.config = {
|
|
31
|
+
apiKey: process.env.DD_API_KEY,
|
|
32
|
+
appKey: process.env.DD_APP_KEY,
|
|
33
|
+
fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
|
|
34
|
+
fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
execute() {
|
|
38
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
(0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
|
|
40
|
+
if (!this.config.apiKey) {
|
|
41
|
+
this.logger.error(`Missing ${chalk_1.default.red.bold('DD_API_KEY')} in your environment.`);
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
if (!this.config.appKey) {
|
|
45
|
+
this.logger.error(`Missing ${chalk_1.default.red.bold('DD_APP_KEY')} in your environment.`);
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
if (!this.commitSha) {
|
|
49
|
+
this.logger.error('Missing commit SHA. It must be provided with --commit-sha');
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
if (!this.repositoryUrl) {
|
|
53
|
+
this.logger.error('Missing repository URL. It must be provided with --repository-url');
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
if (!this.image) {
|
|
57
|
+
this.logger.error('Missing image. It must be provided with --image');
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
const site = process.env.DD_SITE || 'datadoghq.com';
|
|
61
|
+
const baseAPIURL = `https://${(0, utils_1.getApiHostForSite)(site)}`;
|
|
62
|
+
const request = (0, utils_1.getRequestBuilder)({ baseUrl: baseAPIURL, apiKey: this.config.apiKey, appKey: this.config.appKey });
|
|
63
|
+
const correlateEvent = {
|
|
64
|
+
type: 'ci_deployment_correlate_image',
|
|
65
|
+
attributes: {
|
|
66
|
+
commit_sha: this.commitSha,
|
|
67
|
+
repository_url: this.repositoryUrl,
|
|
68
|
+
image: this.image,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
if (this.dryRun) {
|
|
72
|
+
this.logger.info(`[DRYRUN] Sending correlation event\n data: ` + JSON.stringify(correlateEvent, undefined, 2));
|
|
73
|
+
return 0;
|
|
74
|
+
}
|
|
75
|
+
const doRequest = () => request({
|
|
76
|
+
data: {
|
|
77
|
+
data: correlateEvent,
|
|
78
|
+
},
|
|
79
|
+
method: 'post',
|
|
80
|
+
url: '/api/v2/ci/deployments/correlate-image',
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
yield (0, retry_1.retryRequest)(doRequest, {
|
|
84
|
+
maxTimeout: 30000,
|
|
85
|
+
minTimeout: 5000,
|
|
86
|
+
onRetry: (e, attempt) => {
|
|
87
|
+
this.logger.warn(`[attempt ${attempt}] Could not send correlation event. Retrying...: ${e.message}\n`);
|
|
88
|
+
},
|
|
89
|
+
retries: 5,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
this.handleError(error);
|
|
94
|
+
}
|
|
95
|
+
return 0;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
handleError(error) {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
this.context.stderr.write(`${chalk_1.default.red.bold('[ERROR]')} Could not send deployment correlation data: ${(0, axios_1.isAxiosError)(error)
|
|
101
|
+
? JSON.stringify({
|
|
102
|
+
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
103
|
+
response: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
|
|
104
|
+
}, undefined, 2)
|
|
105
|
+
: error.message}\n`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.PluginCommand = PluginCommand;
|
|
109
|
+
//# sourceMappingURL=correlate-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlate-image.js","sourceRoot":"","sources":["../../src/commands/correlate-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kHAAoH;AACpH,kEAA0F;AAC1F,8DAA8D;AAC9D,gEAAgE;AAChE,oEAAwE;AACxE,kEAAmE;AACnE,kEAA2F;AAC3F,iCAAkC;AAClC,kDAAyB;AAEzB,MAAa,aAAc,SAAQ,yDAA+B;IAAlE;;;QACU,WAAM,GAAW,IAAI,eAAM,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAQ,CAAC,IAAI,CAAC,CAAA;QAEvF,WAAM,GAAG;YACf,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;YAC9B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;YAC9B,IAAI,EAAE,MAAA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,CAAC,CAAA;aACjC;YAED,OAAO,CAAC,CAAA;QACV,CAAC;KAAA;IAEO,WAAW,CAAC,KAAY;;QAC9B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACvB,GAAG,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,gDAC1B,IAAA,oBAAY,EAAC,KAAK,CAAC;YACjB,CAAC,CAAC,IAAI,CAAC,SAAS,CACZ;gBACE,MAAM,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM;gBAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAe;aAC1C,EACD,SAAS,EACT,CAAC,CACF;YACH,CAAC,CAAC,KAAK,CAAC,OACZ,IAAI,CACL,CAAA;IACH,CAAC;CACF;AAvGD,sCAuGC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DeploymentCorrelateCommand } from '@datadog/datadog-ci-base/commands/deployment/correlate-command';
|
|
2
|
+
export declare class PluginCommand extends DeploymentCorrelateCommand {
|
|
3
|
+
private config;
|
|
4
|
+
private logger;
|
|
5
|
+
execute(): Promise<1 | undefined>;
|
|
6
|
+
private sendCorrelationData;
|
|
7
|
+
private validateTags;
|
|
8
|
+
private handleError;
|
|
9
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
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 correlate_command_1 = require("@datadog/datadog-ci-base/commands/deployment/correlate-command");
|
|
17
|
+
const constants_1 = require("@datadog/datadog-ci-base/constants");
|
|
18
|
+
const ci_1 = require("@datadog/datadog-ci-base/helpers/ci");
|
|
19
|
+
const env_1 = require("@datadog/datadog-ci-base/helpers/env");
|
|
20
|
+
const fips_1 = require("@datadog/datadog-ci-base/helpers/fips");
|
|
21
|
+
const get_git_data_1 = require("@datadog/datadog-ci-base/helpers/git/get-git-data");
|
|
22
|
+
const logger_1 = require("@datadog/datadog-ci-base/helpers/logger");
|
|
23
|
+
const retry_1 = require("@datadog/datadog-ci-base/helpers/retry");
|
|
24
|
+
const tags_1 = require("@datadog/datadog-ci-base/helpers/tags");
|
|
25
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
26
|
+
const axios_1 = require("axios");
|
|
27
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
28
|
+
const simple_git_1 = __importDefault(require("simple-git"));
|
|
29
|
+
class PluginCommand extends correlate_command_1.DeploymentCorrelateCommand {
|
|
30
|
+
constructor() {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
super(...arguments);
|
|
33
|
+
this.config = {
|
|
34
|
+
apiKey: process.env.DATADOG_API_KEY || process.env.DD_API_KEY,
|
|
35
|
+
fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
|
|
36
|
+
fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
|
|
37
|
+
};
|
|
38
|
+
this.logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO);
|
|
39
|
+
}
|
|
40
|
+
execute() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
(0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
|
|
43
|
+
if (!this.config.apiKey) {
|
|
44
|
+
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.`);
|
|
45
|
+
return 1;
|
|
46
|
+
}
|
|
47
|
+
if (!this.cdProviderParam) {
|
|
48
|
+
this.logger.error('Missing CD provider. It must be provided with --provider');
|
|
49
|
+
return 1;
|
|
50
|
+
}
|
|
51
|
+
this.cdProviderParam = this.cdProviderParam.toLowerCase();
|
|
52
|
+
const tags = (0, ci_1.getCISpanTags)() || {};
|
|
53
|
+
if (!this.validateTags(tags)) {
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
let envVars = {};
|
|
57
|
+
if (tags[tags_1.CI_ENV_VARS]) {
|
|
58
|
+
envVars = JSON.parse(tags[tags_1.CI_ENV_VARS]);
|
|
59
|
+
delete tags[tags_1.CI_ENV_VARS];
|
|
60
|
+
}
|
|
61
|
+
const ciEnv = Object.assign(Object.assign({}, tags), envVars);
|
|
62
|
+
const git = (0, simple_git_1.default)({
|
|
63
|
+
baseDir: process.cwd(),
|
|
64
|
+
binary: 'git',
|
|
65
|
+
maxConcurrentProcesses: 2, // max 2 git commands at the same time
|
|
66
|
+
});
|
|
67
|
+
if (!this.configurationRepo) {
|
|
68
|
+
this.configurationRepo = yield (0, get_git_data_1.gitRepositoryURL)(git);
|
|
69
|
+
}
|
|
70
|
+
if (this.configurationRepo === undefined || this.configurationRepo === '') {
|
|
71
|
+
this.logger.error('Could not retrieve repository URL, check out a repository or provide it with --config-repo');
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
if (!this.configurationShas) {
|
|
75
|
+
this.logger.info('Retrieving local git commits');
|
|
76
|
+
const currentBranch = yield (0, get_git_data_1.gitCurrentBranch)(git);
|
|
77
|
+
if (!currentBranch) {
|
|
78
|
+
this.logger.error('Could not get current branch');
|
|
79
|
+
return 1;
|
|
80
|
+
}
|
|
81
|
+
this.configurationShas = yield (0, get_git_data_1.gitLocalCommitShas)(git, currentBranch);
|
|
82
|
+
}
|
|
83
|
+
if (this.configurationShas.length === 0) {
|
|
84
|
+
this.logger.error('Could not retrieve commit SHAs, commit changes and then call this command or provide them with --config-shas');
|
|
85
|
+
return 1;
|
|
86
|
+
}
|
|
87
|
+
yield this.sendCorrelationData(ciEnv[tags_1.CI_PROVIDER_NAME], ciEnv, this.config.apiKey);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
sendCorrelationData(ciProvider, ciEnv, apiKey) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
+
const correlateEvent = {
|
|
93
|
+
type: 'ci_app_deployment_correlate',
|
|
94
|
+
attributes: {
|
|
95
|
+
ci_provider: ciProvider,
|
|
96
|
+
cd_provider: this.cdProviderParam,
|
|
97
|
+
config_repo_url: this.configurationRepo,
|
|
98
|
+
config_commit_shas: this.configurationShas,
|
|
99
|
+
ci_env: ciEnv,
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
if (this.dryRun) {
|
|
103
|
+
this.logger.info(`[DRYRUN] Sending correlation event\n data: ` + JSON.stringify(correlateEvent, undefined, 2));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const site = process.env.DATADOG_SITE || process.env.DD_SITE || 'datadoghq.com';
|
|
107
|
+
const baseAPIURL = `https://${(0, utils_1.getApiHostForSite)(site)}`;
|
|
108
|
+
const request = (0, utils_1.getRequestBuilder)({ baseUrl: baseAPIURL, apiKey });
|
|
109
|
+
const doRequest = () => request({
|
|
110
|
+
data: {
|
|
111
|
+
data: correlateEvent,
|
|
112
|
+
},
|
|
113
|
+
method: 'post',
|
|
114
|
+
url: '/api/v2/ci/deployments/correlate',
|
|
115
|
+
});
|
|
116
|
+
try {
|
|
117
|
+
yield (0, retry_1.retryRequest)(doRequest, {
|
|
118
|
+
maxTimeout: 30000,
|
|
119
|
+
minTimeout: 5000,
|
|
120
|
+
onRetry: (e, attempt) => {
|
|
121
|
+
this.logger.warn(`[attempt ${attempt}] Could not send deployment correlation data. Retrying...: ${e.message}\n`);
|
|
122
|
+
},
|
|
123
|
+
retries: 5,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
// TODO: use `coerceError()`
|
|
128
|
+
this.handleError(error);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
validateTags(tags) {
|
|
133
|
+
if (!tags[tags_1.GIT_REPOSITORY_URL]) {
|
|
134
|
+
this.logger.error('Could not extract the source code repository URL from the CI environment variables');
|
|
135
|
+
return false;
|
|
136
|
+
}
|
|
137
|
+
if (!tags[tags_1.GIT_SHA]) {
|
|
138
|
+
this.logger.error('Could not extract the commit SHA from the CI environment variables');
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
handleError(error) {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
this.context.stderr.write(`${chalk_1.default.red.bold('[ERROR]')} Could not send deployment correlation data: ${(0, axios_1.isAxiosError)(error)
|
|
146
|
+
? JSON.stringify({
|
|
147
|
+
status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
|
|
148
|
+
response: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
|
|
149
|
+
}, undefined, 2)
|
|
150
|
+
: error.message}\n`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.PluginCommand = PluginCommand;
|
|
154
|
+
//# sourceMappingURL=correlate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correlate.js","sourceRoot":"","sources":["../../src/commands/correlate.ts"],"names":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ACE,MAAM,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM;gBAC9B,QAAQ,EAAE,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAe;aAC1C,EACD,SAAS,EACT,CAAC,CACF;YACH,CAAC,CAAC,KAAK,CAAC,OACZ,IAAI,CACL,CAAA;IACH,CAAC;CACF;AA/JD,sCA+JC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DeploymentGateCommand } from '@datadog/datadog-ci-base/commands/deployment/gate-command';
|
|
2
|
+
export declare class PluginCommand extends DeploymentGateCommand {
|
|
3
|
+
private config;
|
|
4
|
+
private logger;
|
|
5
|
+
private evaluationRequestTimeout;
|
|
6
|
+
private pollingInterval;
|
|
7
|
+
private startTime;
|
|
8
|
+
execute(): Promise<1 | 0>;
|
|
9
|
+
private getApiHelper;
|
|
10
|
+
private buildEvaluationRequest;
|
|
11
|
+
private requestGateEvaluation;
|
|
12
|
+
private pollForEvaluationResults;
|
|
13
|
+
private getEvaluationResult;
|
|
14
|
+
private renderEvaluationSummary;
|
|
15
|
+
private getResultForDatadogError;
|
|
16
|
+
private getRetryOptions;
|
|
17
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
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 gate_command_1 = require("@datadog/datadog-ci-base/commands/deployment/gate-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 formatting_1 = require("@datadog/datadog-ci-base/helpers/formatting");
|
|
21
|
+
const logger_1 = require("@datadog/datadog-ci-base/helpers/logger");
|
|
22
|
+
const retry_1 = require("@datadog/datadog-ci-base/helpers/retry");
|
|
23
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
24
|
+
const axios_1 = require("axios");
|
|
25
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
26
|
+
const api_1 = require("../api");
|
|
27
|
+
class PluginCommand extends gate_command_1.DeploymentGateCommand {
|
|
28
|
+
constructor() {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.config = {
|
|
32
|
+
apiKey: process.env.DATADOG_API_KEY || process.env.DD_API_KEY,
|
|
33
|
+
appKey: process.env.DATADOG_APP_KEY || process.env.DD_APP_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
|
+
this.evaluationRequestTimeout = 60000; // 1 minute
|
|
39
|
+
this.pollingInterval = 15000; // 15 seconds
|
|
40
|
+
this.startTime = Date.now();
|
|
41
|
+
}
|
|
42
|
+
execute() {
|
|
43
|
+
var _a;
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
(0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
|
|
46
|
+
if (!this.service) {
|
|
47
|
+
this.logger.error(chalk_1.default.red(`${formatting_1.ICONS.FAILED} Missing required parameter: ${chalk_1.default.bold('--service')}`));
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
if (!this.env) {
|
|
51
|
+
this.logger.error(chalk_1.default.red(`${formatting_1.ICONS.FAILED} Missing required parameter: ${chalk_1.default.bold('--env')}`));
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
const timeoutSeconds = parseInt(this.timeout, 10);
|
|
55
|
+
if (isNaN(timeoutSeconds) || timeoutSeconds <= 0) {
|
|
56
|
+
this.logger.error(chalk_1.default.red(`${formatting_1.ICONS.FAILED} Invalid ${chalk_1.default.bold('--timeout')} value. Must be a positive integer.`));
|
|
57
|
+
return 1;
|
|
58
|
+
}
|
|
59
|
+
const timeoutMilliseconds = timeoutSeconds * 1000;
|
|
60
|
+
if (!this.config.apiKey) {
|
|
61
|
+
this.logger.error(`${formatting_1.ICONS.FAILED} Neither ${chalk_1.default.red.bold('DATADOG_API_KEY')} nor ${chalk_1.default.red.bold('DD_API_KEY')} are in your environment.`);
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
if (!this.config.appKey) {
|
|
65
|
+
this.logger.error(`${formatting_1.ICONS.FAILED} Neither ${chalk_1.default.red.bold('DATADOG_APP_KEY')} nor ${chalk_1.default.red.bold('DD_APP_KEY')} are in your environment.`);
|
|
66
|
+
return 1;
|
|
67
|
+
}
|
|
68
|
+
this.logger.info('Starting deployment gate evaluation with parameters:');
|
|
69
|
+
this.logger.info(`\tService: ${this.service}`);
|
|
70
|
+
this.logger.info(`\tEnvironment: ${this.env}`);
|
|
71
|
+
if (this.identifier) {
|
|
72
|
+
this.logger.info(`\tIdentifier: ${this.identifier}`);
|
|
73
|
+
}
|
|
74
|
+
if (this.version) {
|
|
75
|
+
this.logger.info(`\tVersion: ${this.version}`);
|
|
76
|
+
}
|
|
77
|
+
if (this.apmPrimaryTag) {
|
|
78
|
+
this.logger.info(`\tAPM Primary Tag: ${this.apmPrimaryTag}`);
|
|
79
|
+
}
|
|
80
|
+
this.logger.info(`\tTimeout: ${timeoutSeconds} seconds`);
|
|
81
|
+
this.logger.info(`\tFail on error: ${this.failOnError ? 'true' : 'false'}\n`);
|
|
82
|
+
let result;
|
|
83
|
+
try {
|
|
84
|
+
const api = this.getApiHelper(this.config.apiKey, this.config.appKey);
|
|
85
|
+
const evaluationRequest = this.buildEvaluationRequest();
|
|
86
|
+
const evaluationId = yield this.requestGateEvaluation(api, evaluationRequest, this.evaluationRequestTimeout);
|
|
87
|
+
result = yield this.pollForEvaluationResults(api, evaluationId, timeoutMilliseconds);
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
91
|
+
this.logger.error(`Deployment gate evaluation failed due to a non-retryable error: ${errorMessage}`);
|
|
92
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
93
|
+
if (error.response.status >= 400 && error.response.status < 500) {
|
|
94
|
+
this.logger.error(`${formatting_1.ICONS.FAILED} Request failed with client error, exiting with status 1`);
|
|
95
|
+
return 1;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
result = this.getResultForDatadogError();
|
|
99
|
+
}
|
|
100
|
+
return result === 'PASS' ? 0 : 1;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
getApiHelper(apiKey, appKey) {
|
|
104
|
+
const site = process.env.DATADOG_SITE || process.env.DD_SITE || 'datadoghq.com';
|
|
105
|
+
const baseAPIURL = `https://${(0, utils_1.getApiHostForSite)(site)}`;
|
|
106
|
+
return (0, api_1.apiConstructor)(baseAPIURL, apiKey, appKey);
|
|
107
|
+
}
|
|
108
|
+
buildEvaluationRequest() {
|
|
109
|
+
const request = {
|
|
110
|
+
service: this.service || '',
|
|
111
|
+
env: this.env || '',
|
|
112
|
+
};
|
|
113
|
+
if (this.identifier) {
|
|
114
|
+
request.identifier = this.identifier;
|
|
115
|
+
}
|
|
116
|
+
if (this.version) {
|
|
117
|
+
request.version = this.version;
|
|
118
|
+
}
|
|
119
|
+
if (this.apmPrimaryTag) {
|
|
120
|
+
request.apm_primary_tag = this.apmPrimaryTag;
|
|
121
|
+
}
|
|
122
|
+
if (this.monitorsQueryVariable) {
|
|
123
|
+
request.monitors_query_variable = this.monitorsQueryVariable;
|
|
124
|
+
}
|
|
125
|
+
return request;
|
|
126
|
+
}
|
|
127
|
+
requestGateEvaluation(api, request, timeout) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
this.logger.info('Requesting gate evaluation...');
|
|
130
|
+
const doRequest = () => __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
var _a;
|
|
132
|
+
try {
|
|
133
|
+
const response = yield api.requestGateEvaluation(request);
|
|
134
|
+
const id = response.data.data.attributes.evaluation_id;
|
|
135
|
+
this.logger.info(chalk_1.default.green(`Gate evaluation started successfully. Evaluation ID: ${id}\n`));
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
140
|
+
this.logger.error(`Request failed with error: ${error.response.status} ${error.response.statusText}`);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
144
|
+
this.logger.error(`Could not start gate evaluation with unknown error: ${errorMessage}`);
|
|
145
|
+
}
|
|
146
|
+
throw error;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const evaluationId = yield (0, retry_1.retryRequest)(doRequest, Object.assign(Object.assign({}, this.getRetryOptions(timeout)), { onRetry: (e, attempt) => {
|
|
150
|
+
this.logger.info(`Retrying gate evaluation request (${attempt} attempts)...`);
|
|
151
|
+
} }));
|
|
152
|
+
return evaluationId;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
pollForEvaluationResults(api, evaluationId, timeout) {
|
|
156
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
157
|
+
this.logger.info('Waiting for gate evaluation results...');
|
|
158
|
+
let timePassed = Date.now() - this.startTime;
|
|
159
|
+
let result;
|
|
160
|
+
while (timePassed < timeout) {
|
|
161
|
+
const remainingTime = timeout - timePassed;
|
|
162
|
+
const waitTime = Math.min(this.pollingInterval, remainingTime);
|
|
163
|
+
const waitTimeInSeconds = Math.floor(waitTime / 1000);
|
|
164
|
+
result = yield this.getEvaluationResult(api, evaluationId);
|
|
165
|
+
if (result) {
|
|
166
|
+
return result;
|
|
167
|
+
}
|
|
168
|
+
this.logger.info(`\tRetrying in ${waitTimeInSeconds}s...`);
|
|
169
|
+
yield new Promise((resolve) => setTimeout(resolve, waitTime));
|
|
170
|
+
timePassed = Date.now() - this.startTime;
|
|
171
|
+
}
|
|
172
|
+
// The block above may not have run the last time, so we need to check again
|
|
173
|
+
result = yield this.getEvaluationResult(api, evaluationId);
|
|
174
|
+
if (result) {
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
this.logger.warn(`${formatting_1.ICONS.WARNING} Timeout reached (${timeout / 1000} seconds). Gate evaluation did not complete in time.`);
|
|
178
|
+
return this.getResultForDatadogError();
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
getEvaluationResult(api, evaluationId) {
|
|
182
|
+
var _a;
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
try {
|
|
185
|
+
const response = yield api.getGateEvaluationResult(evaluationId);
|
|
186
|
+
const status = response.data.data.attributes.gate_status;
|
|
187
|
+
switch (status) {
|
|
188
|
+
case 'pass':
|
|
189
|
+
this.renderEvaluationSummary(response.data);
|
|
190
|
+
return 'PASS';
|
|
191
|
+
case 'fail':
|
|
192
|
+
this.renderEvaluationSummary(response.data);
|
|
193
|
+
return 'FAIL';
|
|
194
|
+
case 'in_progress': {
|
|
195
|
+
const rules = response.data.data.attributes.rules;
|
|
196
|
+
const totalRules = rules.length;
|
|
197
|
+
const completedRules = rules.filter((rule) => rule.status !== 'in_progress').length;
|
|
198
|
+
this.logger.info(`\tGate evaluation in progress (${completedRules}/${totalRules} rules completed)`);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
default:
|
|
202
|
+
this.logger.warn(`Unknown gate evaluation status: ${status}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
if ((0, axios_1.isAxiosError)(error) && ((_a = error.response) === null || _a === void 0 ? void 0 : _a.status)) {
|
|
207
|
+
const status = error.response.status;
|
|
208
|
+
const statusText = error.response.statusText;
|
|
209
|
+
if (status === 404 || status >= 500) {
|
|
210
|
+
this.logger.error(`Error polling for gate evaluation results: ${status} ${statusText}`);
|
|
211
|
+
// We want to retry in this case, so we return undefined to trigger the retry
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
this.logger.error(`Error polling for gate evaluation results: ${status} ${statusText}`);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
220
|
+
this.logger.error(`Error polling for gate evaluation results: ${errorMessage}`);
|
|
221
|
+
}
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
renderEvaluationSummary(result) {
|
|
227
|
+
const attributes = result.data.attributes;
|
|
228
|
+
if (attributes.gate_status === 'pass') {
|
|
229
|
+
this.logger.info(chalk_1.default.green(`\n${formatting_1.ICONS.SUCCESS} Gate evaluation passed`));
|
|
230
|
+
}
|
|
231
|
+
else if (attributes.gate_status === 'fail') {
|
|
232
|
+
this.logger.info(chalk_1.default.red(`\n${formatting_1.ICONS.FAILED} Gate evaluation failed`));
|
|
233
|
+
}
|
|
234
|
+
this.logger.info(` Evaluation mode: ${attributes.dry_run ? 'Dry run' : 'Active'}`);
|
|
235
|
+
this.logger.info(` Evaluation URL: ${attributes.evaluation_url}`);
|
|
236
|
+
this.logger.info(` Rules evaluated:`);
|
|
237
|
+
attributes.rules.forEach((rule) => {
|
|
238
|
+
var _a;
|
|
239
|
+
const ruleName = ` - Rule: ${rule.name}`;
|
|
240
|
+
const evaluationMode = `\n Evaluation mode: ${rule.dry_run ? 'Dry run' : 'Active'}`;
|
|
241
|
+
const status = `\n Status: ${rule.status.toUpperCase()}`;
|
|
242
|
+
const reason = rule.status === 'fail' ? `\n Reason: ${(_a = rule.reason) !== null && _a !== void 0 ? _a : 'Unknown'}` : '';
|
|
243
|
+
this.logger.info(`${ruleName}${evaluationMode}${status}${reason}`);
|
|
244
|
+
});
|
|
245
|
+
this.logger.info('\n');
|
|
246
|
+
}
|
|
247
|
+
getResultForDatadogError() {
|
|
248
|
+
if (this.failOnError) {
|
|
249
|
+
this.logger.warn('Unexpected error happened, exiting with status 1 because --fail-on-error is enabled');
|
|
250
|
+
return 'FAIL';
|
|
251
|
+
}
|
|
252
|
+
this.logger.warn('Unexpected error happened, exiting with status 0');
|
|
253
|
+
return 'PASS';
|
|
254
|
+
}
|
|
255
|
+
getRetryOptions(timeout) {
|
|
256
|
+
const timeElapsed = Date.now() - this.startTime;
|
|
257
|
+
const maxRetryTime = timeout - timeElapsed;
|
|
258
|
+
return {
|
|
259
|
+
forever: true,
|
|
260
|
+
randomize: false,
|
|
261
|
+
factor: 1.5,
|
|
262
|
+
minTimeout: 5000,
|
|
263
|
+
maxTimeout: 30000,
|
|
264
|
+
maxRetryTime,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.PluginCommand = PluginCommand;
|
|
269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AAM,GAAG,MAAM,EAAE,CAAC,CAAA;QACpE,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACxB,CAAC;IAEO,wBAAwB;QAC9B,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qFAAqF,CAAC,CAAA;YAEvG,OAAO,MAAM,CAAA;SACd;QAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kDAAkD,CAAC,CAAA;QAEpE,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,eAAe,CAAC,OAAe;QACrC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,SAAS,CAAA;QAC/C,MAAM,YAAY,GAAG,OAAO,GAAG,WAAW,CAAA;QAE1C,OAAO;YACL,OAAO,EAAE,IAAI;YACb,SAAS,EAAE,KAAK;YAChB,MAAM,EAAE,GAAG;YACX,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,KAAK;YACjB,YAAY;SACb,CAAA;IACH,CAAC;CACF;AAhTD,sCAgTC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DeploymentMarkCommand } from '@datadog/datadog-ci-base/commands/deployment/mark-command';
|
|
2
|
+
export declare class PluginCommand extends DeploymentMarkCommand {
|
|
3
|
+
private config;
|
|
4
|
+
execute(): Promise<number>;
|
|
5
|
+
createJobDeploymentTags(): string[];
|
|
6
|
+
createPipelineDeploymentTags(): string[];
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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.PluginCommand = void 0;
|
|
13
|
+
const mark_command_1 = require("@datadog/datadog-ci-base/commands/deployment/mark-command");
|
|
14
|
+
const tag_command_1 = require("@datadog/datadog-ci-base/commands/tag/tag-command");
|
|
15
|
+
const constants_1 = require("@datadog/datadog-ci-base/constants");
|
|
16
|
+
const env_1 = require("@datadog/datadog-ci-base/helpers/env");
|
|
17
|
+
const fips_1 = require("@datadog/datadog-ci-base/helpers/fips");
|
|
18
|
+
const constants_2 = require("../constants");
|
|
19
|
+
class PluginCommand extends mark_command_1.DeploymentMarkCommand {
|
|
20
|
+
constructor() {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
super(...arguments);
|
|
23
|
+
this.config = {
|
|
24
|
+
fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
|
|
25
|
+
fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
execute() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
(0, fips_1.enableFips)(this.fips || this.config.fips, this.fipsIgnoreError || this.config.fipsIgnoreError);
|
|
31
|
+
const tagJobCommand = new tag_command_1.TagCommand();
|
|
32
|
+
tagJobCommand.setLevel('job');
|
|
33
|
+
tagJobCommand.setTags(this.createJobDeploymentTags());
|
|
34
|
+
tagJobCommand.context = this.context;
|
|
35
|
+
tagJobCommand.setSilent(false);
|
|
36
|
+
const tagPipelineCommand = new tag_command_1.TagCommand();
|
|
37
|
+
tagPipelineCommand.setLevel('pipeline');
|
|
38
|
+
tagPipelineCommand.setTags(this.createPipelineDeploymentTags());
|
|
39
|
+
tagPipelineCommand.context = this.context;
|
|
40
|
+
tagPipelineCommand.setSilent(true);
|
|
41
|
+
if (this.noFail) {
|
|
42
|
+
tagJobCommand.setNoFail(true);
|
|
43
|
+
tagPipelineCommand.setNoFail(true);
|
|
44
|
+
}
|
|
45
|
+
const tagJobCommandExitCode = yield tagJobCommand.execute();
|
|
46
|
+
if (tagJobCommandExitCode === 0) {
|
|
47
|
+
return tagPipelineCommand.execute();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return tagJobCommandExitCode;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
createJobDeploymentTags() {
|
|
55
|
+
const tags = [constants_2.IS_DEPLOYMENT_TAG];
|
|
56
|
+
if (this.env) {
|
|
57
|
+
tags.push(constants_2.ENV_TAG + this.env);
|
|
58
|
+
}
|
|
59
|
+
if (this.revision) {
|
|
60
|
+
tags.push(constants_2.REVISION_TAG + this.revision);
|
|
61
|
+
}
|
|
62
|
+
if (this.service) {
|
|
63
|
+
tags.push(constants_2.SERVICE_TAG + this.service);
|
|
64
|
+
}
|
|
65
|
+
if (this.isRollback) {
|
|
66
|
+
tags.push(constants_2.IS_ROLLBACK_TAG);
|
|
67
|
+
}
|
|
68
|
+
if (this.tags) {
|
|
69
|
+
tags.push(constants_2.CUSTOM_TAGS_TAG + this.tags.join(','));
|
|
70
|
+
}
|
|
71
|
+
return tags;
|
|
72
|
+
}
|
|
73
|
+
createPipelineDeploymentTags() {
|
|
74
|
+
return [constants_2.CONTAINS_DEPLOYMENT_TAG];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.PluginCommand = PluginCommand;
|
|
78
|
+
//# sourceMappingURL=mark.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mark.js","s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AAC,CAAA;gBAC7B,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;aACnC;YAED,MAAM,qBAAqB,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,CAAA;YAE3D,IAAI,qBAAqB,KAAK,CAAC,EAAE;gBAC/B,OAAO,kBAAkB,CAAC,OAAO,EAAE,CAAA;aACpC;iBAAM;gBACL,OAAO,qBAAqB,CAAA;aAC7B;QACH,CAAC;KAAA;IAEM,uBAAuB;QAC5B,MAAM,IAAI,GAAG,CAAC,6BAAiB,CAAC,CAAA;QAEhC,IAAI,IAAI,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,IAAI,CAAC,mBAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;SAC9B;QAED,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,wBAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;SACxC;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,IAAI,CAAC,IAAI,CAAC,uBAAW,GAAG,IAAI,CAAC,OAAO,CAAC,CAAA;SACtC;QAED,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,IAAI,CAAC,IAAI,CAAC,2BAAe,CAAC,CAAA;SAC3B;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,IAAI,CAAC,2BAAe,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;SACjD;QAED,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,4BAA4B;QACjC,OAAO,CAAC,mCAAuB,CAAC,CAAA;IAClC,CAAC;CACF;AAhED,sCAgEC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const CD_VIS_PREFIX = "datadog_cd_visibility.";
|
|
2
|
+
export declare const IS_DEPLOYMENT_TAG: string;
|
|
3
|
+
export declare const ENV_TAG: string;
|
|
4
|
+
export declare const REVISION_TAG: string;
|
|
5
|
+
export declare const SERVICE_TAG: string;
|
|
6
|
+
export declare const IS_ROLLBACK_TAG: string;
|
|
7
|
+
export declare const CUSTOM_TAGS_TAG: string;
|
|
8
|
+
export declare const CONTAINS_DEPLOYMENT_TAG = "ci.pipeline.contains_deployment:true";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONTAINS_DEPLOYMENT_TAG = exports.CUSTOM_TAGS_TAG = exports.IS_ROLLBACK_TAG = exports.SERVICE_TAG = exports.REVISION_TAG = exports.ENV_TAG = exports.IS_DEPLOYMENT_TAG = exports.CD_VIS_PREFIX = void 0;
|
|
4
|
+
exports.CD_VIS_PREFIX = 'datadog_cd_visibility.';
|
|
5
|
+
exports.IS_DEPLOYMENT_TAG = exports.CD_VIS_PREFIX + 'is_deployment:true';
|
|
6
|
+
exports.ENV_TAG = exports.CD_VIS_PREFIX + 'env:';
|
|
7
|
+
exports.REVISION_TAG = exports.CD_VIS_PREFIX + 'revision:';
|
|
8
|
+
exports.SERVICE_TAG = exports.CD_VIS_PREFIX + 'service:';
|
|
9
|
+
exports.IS_ROLLBACK_TAG = exports.CD_VIS_PREFIX + 'is_rollback:true';
|
|
10
|
+
exports.CUSTOM_TAGS_TAG = exports.CD_VIS_PREFIX + 'custom_tags:';
|
|
11
|
+
exports.CONTAINS_DEPLOYMENT_TAG = 'ci.pipeline.contains_deployment:true';
|
|
12
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG,wBAAwB,CAAA;AACxC,QAAA,iBAAiB,GAAG,qBAAa,GAAG,oBAAoB,CAAA;AACxD,QAAA,OAAO,GAAG,qBAAa,GAAG,MAAM,CAAA;AAChC,QAAA,YAAY,GAAG,qBAAa,GAAG,WAAW,CAAA;AAC1C,QAAA,WAAW,GAAG,qBAAa,GAAG,UAAU,CAAA;AACxC,QAAA,eAAe,GAAG,qBAAa,GAAG,kBAAkB,CAAA;AACpD,QAAA,eAAe,GAAG,qBAAa,GAAG,cAAc,CAAA;AAChD,QAAA,uBAAuB,GAAG,sCAAsC,CAAA"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AxiosPromise } from 'axios';
|
|
2
|
+
export interface GateEvaluationRequest {
|
|
3
|
+
service: string;
|
|
4
|
+
env: string;
|
|
5
|
+
identifier?: string;
|
|
6
|
+
version?: string;
|
|
7
|
+
apm_primary_tag?: string;
|
|
8
|
+
monitors_query_variable?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface GateEvaluationRequestResponse {
|
|
11
|
+
data: {
|
|
12
|
+
id: string;
|
|
13
|
+
type: string;
|
|
14
|
+
attributes: {
|
|
15
|
+
evaluation_id: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface GateEvaluationStatusResponse {
|
|
20
|
+
data: {
|
|
21
|
+
id: string;
|
|
22
|
+
type: string;
|
|
23
|
+
attributes: {
|
|
24
|
+
dry_run: boolean;
|
|
25
|
+
evaluation_id: string;
|
|
26
|
+
evaluation_url: string;
|
|
27
|
+
gate_id: string;
|
|
28
|
+
gate_status: 'pass' | 'fail' | 'in_progress';
|
|
29
|
+
rules: [
|
|
30
|
+
{
|
|
31
|
+
name: string;
|
|
32
|
+
status: 'pass' | 'fail' | 'in_progress';
|
|
33
|
+
reason: string;
|
|
34
|
+
dry_run: boolean;
|
|
35
|
+
}
|
|
36
|
+
];
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface APIHelper {
|
|
41
|
+
requestGateEvaluation(request: GateEvaluationRequest): AxiosPromise<GateEvaluationRequestResponse>;
|
|
42
|
+
getGateEvaluationResult(evaluationId: string): AxiosPromise<GateEvaluationStatusResponse>;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datadog/datadog-ci-plugin-deployment",
|
|
3
|
+
"version": "3.21.1",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "Datadog CI plugin for `deployment` commands",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"datadog",
|
|
8
|
+
"datadog-ci",
|
|
9
|
+
"plugin"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/plugin-deployment",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/DataDog/datadog-ci.git",
|
|
15
|
+
"directory": "packages/plugin-deployment"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
"./commands/*": {
|
|
20
|
+
"development": "./src/commands/*.ts",
|
|
21
|
+
"default": "./dist/commands/*.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/**/*",
|
|
26
|
+
"README",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "yarn package:clean; yarn package:build",
|
|
34
|
+
"lint": "yarn package:lint",
|
|
35
|
+
"prepack": "yarn package:clean-dist"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"@datadog/datadog-ci": "3.21.1"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@datadog/datadog-ci-base": "3.21.1",
|
|
42
|
+
"axios": "^1.11.0",
|
|
43
|
+
"chalk": "3.0.0",
|
|
44
|
+
"clipanion": "^3.2.1",
|
|
45
|
+
"simple-git": "3.16.0",
|
|
46
|
+
"typanion": "^3.14.0"
|
|
47
|
+
}
|
|
48
|
+
}
|