@datadog/datadog-ci-plugin-container-app 4.1.3
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 +208 -0
- package/dist/commands/instrument.d.ts +16 -0
- package/dist/commands/instrument.js +184 -0
- package/dist/commands/instrument.js.map +1 -0
- package/dist/common.d.ts +4 -0
- package/dist/common.js +18 -0
- package/dist/common.js.map +1 -0
- package/package.json +47 -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,208 @@
|
|
|
1
|
+
## Azure Container Apps
|
|
2
|
+
|
|
3
|
+
> **BETA**: This feature is in beta. To use it, you must set the environment variable `DD_BETA_COMMANDS_ENABLED=true`.
|
|
4
|
+
|
|
5
|
+
You can use the CLI to instrument your Azure Container Apps with Datadog. The CLI enables instrumentation by modifying existing Container App configurations to include the Datadog sidecar to enable tracing, log collection, and custom metrics.
|
|
6
|
+
|
|
7
|
+
See [the docs](https://docs.datadoghq.com/serverless/azure_container_apps/sidecar/) for language-specific application steps needed in addition to these commands.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
### `instrument`
|
|
12
|
+
|
|
13
|
+
Run `datadog-ci container-app instrument` to apply Datadog instrumentation to an Azure Container App. This command configures your Container App with the necessary environment variables and settings for Datadog monitoring.
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
# Instrument a Container App using subscription ID, resource group, and name
|
|
17
|
+
datadog-ci container-app instrument \
|
|
18
|
+
--subscription-id <subscription-id> \
|
|
19
|
+
--resource-group <resource-group> \
|
|
20
|
+
--name <container-app-name>
|
|
21
|
+
|
|
22
|
+
# Instrument a Container App using a full resource ID
|
|
23
|
+
datadog-ci container-app instrument \
|
|
24
|
+
--resource-id "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{containerAppName}"
|
|
25
|
+
|
|
26
|
+
# Instrument multiple Container Apps using resource IDs
|
|
27
|
+
datadog-ci container-app instrument \
|
|
28
|
+
--resource-id <resource-id-1> \
|
|
29
|
+
--resource-id <resource-id-2>
|
|
30
|
+
|
|
31
|
+
# Instrument with configuration
|
|
32
|
+
datadog-ci container-app instrument \
|
|
33
|
+
--subscription-id <subscription-id> \
|
|
34
|
+
--resource-group <resource-group> \
|
|
35
|
+
--name <container-app-name> \
|
|
36
|
+
--service my-service \
|
|
37
|
+
--env prod \
|
|
38
|
+
--version 1.0.0
|
|
39
|
+
|
|
40
|
+
# Dry run to preview changes
|
|
41
|
+
datadog-ci container-app instrument \
|
|
42
|
+
--subscription-id <subscription-id> \
|
|
43
|
+
--resource-group <resource-group> \
|
|
44
|
+
--name <container-app-name> \
|
|
45
|
+
--dry-run
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Configuration
|
|
49
|
+
|
|
50
|
+
### Azure Credentials
|
|
51
|
+
|
|
52
|
+
You must have valid Azure credentials configured with access to the Container Apps where you are running any `datadog-ci container-app` command. The CLI uses the Azure SDK's default credential chain, which includes:
|
|
53
|
+
|
|
54
|
+
- Environment variables
|
|
55
|
+
- Managed Identity (when running in Azure)
|
|
56
|
+
- Azure CLI credentials (`az login`)
|
|
57
|
+
- Visual Studio Code credentials
|
|
58
|
+
- Azure PowerShell credentials
|
|
59
|
+
|
|
60
|
+
For local development, ensure you're authenticated via the Azure CLI:
|
|
61
|
+
```bash
|
|
62
|
+
az login
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Environment variables
|
|
66
|
+
|
|
67
|
+
You must expose these environment variables in the environment where you are running `datadog-ci container-app instrument`:
|
|
68
|
+
|
|
69
|
+
| Environment Variable | Description | Example |
|
|
70
|
+
| -------------------- | ----------- | ------- |
|
|
71
|
+
| `DD_BETA_COMMANDS_ENABLED` | **Required**. Must be set to `true` to enable beta commands. | `export DD_BETA_COMMANDS_ENABLED=true` |
|
|
72
|
+
| `DD_API_KEY` | **Required**. Datadog API Key. Sets the `DD_API_KEY` environment variable on your Container App. For more information about getting a Datadog API key, see the [API key documentation][1]. | `export DD_API_KEY=<API_KEY>` |
|
|
73
|
+
| `DD_SITE` | Set which Datadog site to send data. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, `ap1.datadoghq.com`, `ap2.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. | `export DD_SITE=datadoghq.com` |
|
|
74
|
+
|
|
75
|
+
### Arguments
|
|
76
|
+
|
|
77
|
+
Configuration can be done using command-line arguments or a JSON configuration file (see the next section).
|
|
78
|
+
|
|
79
|
+
#### `instrument`
|
|
80
|
+
You can pass the following arguments to `instrument` to specify its behavior. These arguments will override the values set in the configuration file, if any.
|
|
81
|
+
|
|
82
|
+
| Argument | Shorthand | Description | Default |
|
|
83
|
+
| -------- | --------- | ----------- | ------- |
|
|
84
|
+
| `--subscription-id` | `-s` | Azure Subscription ID containing the Container App. Must be used with `--resource-group` and `--name`. | |
|
|
85
|
+
| `--resource-group` | `-g` | Name of the Azure Resource Group containing the Container App. Must be used with `--subscription-id` and `--name`. | |
|
|
86
|
+
| `--name` | `-n` | Name of the Azure Container App to instrument. Must be used with `--subscription-id` and `--resource-group`. | |
|
|
87
|
+
| `--resource-id` | `-r` | Full Azure resource ID to instrument. Can be specified multiple times. Format: `/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{containerAppName}` | |
|
|
88
|
+
| `--service` | | The value for the service tag. Use this to group related Container Apps belonging to similar workloads. For example, `my-service` | |
|
|
89
|
+
| `--env` or `--environment` | | The value for the env tag. Use this to separate out your staging, development, and production environments. For example, `prod` | |
|
|
90
|
+
| `--version` | | The value for the version tag. Use this to correlate spikes in latency, load, or errors to new versions. For example, `1.0.0` | |
|
|
91
|
+
| `--instance-logging` | | When enabled, log collection is automatically configured for an additional file path: `/home/LogFiles/*$COMPUTERNAME*.log` | `false` |
|
|
92
|
+
| `--shared-volume-name` | | (Not recommended) Specify a custom shared volume name. | `shared-volume` |
|
|
93
|
+
| `--shared-volume-path` | | (Not recommended) Specify a custom shared volume path. | `/shared-volume` |
|
|
94
|
+
| `--logs-path` | | (Not recommended) Specify a custom log file path. Must begin with the shared volume path. | `/shared-volume/logs/*.log` |
|
|
95
|
+
| `--source-code-integration` or `--sourceCodeIntegration` | | Enable source code integration to add git metadata as tags. Specify `--no-source-code-integration` to disable. | `true` |
|
|
96
|
+
| `--upload-git-metadata` or `--uploadGitMetadata` | | Upload git metadata to Datadog. Only required if you don't have the Datadog GitHub Integration installed. Specify `--no-upload-git-metadata` to disable. | `true` |
|
|
97
|
+
| `--extra-tags` or `--extraTags` | | Additional tags to add to the service in the format `key1:value1,key2:value2` | |
|
|
98
|
+
| `--env-vars` | `-e` | Additional environment variables to set for the Container App. Can specify multiple in the form `--env-vars VAR1=VALUE1 --env-vars VAR2=VALUE2` | |
|
|
99
|
+
| `--dry-run` | `-d` | Run the command in dry-run mode, without making any changes. Preview the changes that running the command would apply. | `false` |
|
|
100
|
+
| `--config` | | Path to a configuration file. See the configuration file section below. | |
|
|
101
|
+
| `--fips` | | Enable FIPS support for the Container App. | `false` |
|
|
102
|
+
| `--fips-ignore-error` | | Ignore errors when enabling FIPS support. | `false` |
|
|
103
|
+
|
|
104
|
+
### Configuration file
|
|
105
|
+
|
|
106
|
+
Instead of supplying arguments, you can create a configuration file in your project and simply run the `datadog-ci container-app instrument --config datadog-ci.json` command. Specify the `datadog-ci.json` using the `--config` argument, and use this configuration file structure:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"containerApp": {
|
|
111
|
+
"subscriptionId": "your-subscription-id",
|
|
112
|
+
"resourceGroup": "your-resource-group",
|
|
113
|
+
"containerAppName": "your-container-app-name",
|
|
114
|
+
"service": "my-service",
|
|
115
|
+
"environment": "prod",
|
|
116
|
+
"version": "1.0.0",
|
|
117
|
+
"logPath": "/home/LogFiles/*.log",
|
|
118
|
+
"isInstanceLoggingEnabled": false,
|
|
119
|
+
"sourceCodeIntegration": true,
|
|
120
|
+
"uploadGitMetadata": true,
|
|
121
|
+
"extraTags": "team:backend,project:api",
|
|
122
|
+
"envVars": [
|
|
123
|
+
"CUSTOM_VAR1=value1",
|
|
124
|
+
"CUSTOM_VAR2=value2"
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Alternatively, you can use resource IDs:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"containerApp": {
|
|
135
|
+
"resourceIds": [
|
|
136
|
+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{containerAppName1}",
|
|
137
|
+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.App/containerApps/{containerAppName2}"
|
|
138
|
+
],
|
|
139
|
+
"service": "my-service",
|
|
140
|
+
"environment": "prod"
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Examples
|
|
146
|
+
|
|
147
|
+
### Basic instrumentation
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
export DD_BETA_COMMANDS_ENABLED=true
|
|
151
|
+
export DD_API_KEY=your-api-key
|
|
152
|
+
export DD_SITE=datadoghq.com
|
|
153
|
+
|
|
154
|
+
datadog-ci container-app instrument \
|
|
155
|
+
--subscription-id 12345678-1234-1234-1234-123456789012 \
|
|
156
|
+
--resource-group my-resource-group \
|
|
157
|
+
--name my-container-app
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Instrumentation with tags and version
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
export DD_BETA_COMMANDS_ENABLED=true
|
|
164
|
+
export DD_API_KEY=your-api-key
|
|
165
|
+
|
|
166
|
+
datadog-ci container-app instrument \
|
|
167
|
+
--subscription-id 12345678-1234-1234-1234-123456789012 \
|
|
168
|
+
--resource-group my-resource-group \
|
|
169
|
+
--name my-container-app \
|
|
170
|
+
--service my-web-api \
|
|
171
|
+
--env production \
|
|
172
|
+
--version v2.5.0 \
|
|
173
|
+
--extra-tags team:platform,cost-center:engineering
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Instrumentation with custom logging
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
export DD_BETA_COMMANDS_ENABLED=true
|
|
180
|
+
export DD_API_KEY=your-api-key
|
|
181
|
+
|
|
182
|
+
datadog-ci container-app instrument \
|
|
183
|
+
--subscription-id 12345678-1234-1234-1234-123456789012 \
|
|
184
|
+
--resource-group my-resource-group \
|
|
185
|
+
--name my-container-app \
|
|
186
|
+
--log-path /home/LogFiles/myapp/*.log \
|
|
187
|
+
--instance-logging
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
### Dry run to preview changes
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
export DD_BETA_COMMANDS_ENABLED=true
|
|
195
|
+
export DD_API_KEY=your-api-key
|
|
196
|
+
|
|
197
|
+
datadog-ci container-app instrument \
|
|
198
|
+
--subscription-id 12345678-1234-1234-1234-123456789012 \
|
|
199
|
+
--resource-group my-resource-group \
|
|
200
|
+
--name my-container-app \
|
|
201
|
+
--dry-run
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Community
|
|
205
|
+
|
|
206
|
+
For product feedback and questions, join the `#serverless` channel in the [Datadog community on Slack](https://chat.datadoghq.com/).
|
|
207
|
+
|
|
208
|
+
[1]: https://docs.datadoghq.com/account_management/api-app-keys/#api-keys
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ContainerAppsAPIClient, ContainerApp } from '@azure/arm-appcontainers';
|
|
2
|
+
import { ContainerAppConfigOptions } from '@datadog/datadog-ci-base/commands/container-app/common';
|
|
3
|
+
import { ContainerAppInstrumentCommand } from '@datadog/datadog-ci-base/commands/container-app/instrument';
|
|
4
|
+
export declare class PluginCommand extends ContainerAppInstrumentCommand {
|
|
5
|
+
private cred;
|
|
6
|
+
private tagClient;
|
|
7
|
+
execute(): Promise<0 | 1>;
|
|
8
|
+
processSubscription(subscriptionId: string, resourceGroupToNames: Record<string, string[]>, config: ContainerAppConfigOptions): Promise<boolean>;
|
|
9
|
+
/**
|
|
10
|
+
* Process an Azure Container App for instrumentation.
|
|
11
|
+
* @returns A promise that resolves to a boolean indicating success or failure.
|
|
12
|
+
*/
|
|
13
|
+
processContainerApp(containerAppClient: ContainerAppsAPIClient, config: ContainerAppConfigOptions, resourceGroup: string, containerAppName: string): Promise<boolean>;
|
|
14
|
+
addTags(config: ContainerAppConfigOptions, subscriptionId: string, resourceGroup: string, containerApp: ContainerApp): Promise<void>;
|
|
15
|
+
instrumentSidecar(client: ContainerAppsAPIClient, config: ContainerAppConfigOptions, resourceGroup: string, containerApp: ContainerApp): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
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 arm_appcontainers_1 = require("@azure/arm-appcontainers");
|
|
17
|
+
const arm_resources_1 = require("@azure/arm-resources");
|
|
18
|
+
const identity_1 = require("@azure/identity");
|
|
19
|
+
const instrument_1 = require("@datadog/datadog-ci-base/commands/container-app/instrument");
|
|
20
|
+
const constants_1 = require("@datadog/datadog-ci-base/constants");
|
|
21
|
+
const apikey_1 = require("@datadog/datadog-ci-base/helpers/apikey");
|
|
22
|
+
const renderer_1 = require("@datadog/datadog-ci-base/helpers/renderer");
|
|
23
|
+
const azure_1 = require("@datadog/datadog-ci-base/helpers/serverless/azure");
|
|
24
|
+
const constants_2 = require("@datadog/datadog-ci-base/helpers/serverless/constants");
|
|
25
|
+
const source_code_integration_1 = require("@datadog/datadog-ci-base/helpers/serverless/source-code-integration");
|
|
26
|
+
const tags_1 = require("@datadog/datadog-ci-base/helpers/tags");
|
|
27
|
+
const utils_1 = require("@datadog/datadog-ci-base/helpers/utils");
|
|
28
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
29
|
+
const es6_1 = __importDefault(require("fast-deep-equal/es6"));
|
|
30
|
+
const common_1 = require("../common");
|
|
31
|
+
class PluginCommand extends instrument_1.ContainerAppInstrumentCommand {
|
|
32
|
+
execute() {
|
|
33
|
+
var _a, _b, _c;
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
this.enableFips();
|
|
36
|
+
const [containerAppsToInstrument, config, errors] = yield this.ensureConfig();
|
|
37
|
+
if (errors.length > 0) {
|
|
38
|
+
for (const error of errors) {
|
|
39
|
+
this.context.stdout.write((0, renderer_1.renderError)(error));
|
|
40
|
+
}
|
|
41
|
+
return 1;
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const isApiKeyValid = yield (0, apikey_1.newApiKeyValidator)({
|
|
45
|
+
apiKey: process.env.DD_API_KEY,
|
|
46
|
+
datadogSite: (_a = process.env.DD_SITE) !== null && _a !== void 0 ? _a : constants_1.DATADOG_SITE_US1,
|
|
47
|
+
}).validateApiKey();
|
|
48
|
+
if (!isApiKeyValid) {
|
|
49
|
+
throw Error();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
this.context.stdout.write((0, renderer_1.renderSoftWarning)(`Invalid API Key stored in the environment variable ${chalk_1.default.bold('DD_API_KEY')}: ${(0, utils_1.maskString)((_b = process.env.DD_API_KEY) !== null && _b !== void 0 ? _b : '')}\nEnsure you copied the value and not the Key ID.`));
|
|
54
|
+
return 1;
|
|
55
|
+
}
|
|
56
|
+
this.cred = new identity_1.DefaultAzureCredential();
|
|
57
|
+
if (!(yield (0, azure_1.ensureAzureAuth)((msg) => this.context.stdout.write(msg), this.cred))) {
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
this.tagClient = new arm_resources_1.ResourceManagementClient(this.cred).tagsOperations;
|
|
61
|
+
if (config.sourceCodeIntegration) {
|
|
62
|
+
config.extraTags = yield (0, source_code_integration_1.handleSourceCodeIntegration)(this.context, (_c = config.uploadGitMetadata) !== null && _c !== void 0 ? _c : true, config.extraTags);
|
|
63
|
+
}
|
|
64
|
+
this.context.stdout.write(`${this.dryRunPrefix}🐶 Beginning instrumentation of Azure Container App(s)\n`);
|
|
65
|
+
const results = yield Promise.all(Object.entries(containerAppsToInstrument).map(([subscriptionId, resourceGroupToNames]) => this.processSubscription(subscriptionId, resourceGroupToNames, config)));
|
|
66
|
+
const success = results.every((result) => result);
|
|
67
|
+
this.context.stdout.write(`${this.dryRunPrefix}🐶 Instrumentation completed ${success ? 'successfully!' : 'with errors, see above for details.'}\n`);
|
|
68
|
+
return success ? 0 : 1;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
processSubscription(subscriptionId, resourceGroupToNames, config) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const containerAppClient = new arm_appcontainers_1.ContainerAppsAPIClient(this.cred, subscriptionId);
|
|
74
|
+
const results = yield Promise.all(Object.entries(resourceGroupToNames).flatMap(([resourceGroup, containerAppNames]) => containerAppNames.map((containerAppName) => this.processContainerApp(containerAppClient, config, resourceGroup, containerAppName))));
|
|
75
|
+
return results.every((result) => result);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Process an Azure Container App for instrumentation.
|
|
80
|
+
* @returns A promise that resolves to a boolean indicating success or failure.
|
|
81
|
+
*/
|
|
82
|
+
processContainerApp(containerAppClient, config, resourceGroup, containerAppName) {
|
|
83
|
+
var _a;
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
try {
|
|
86
|
+
const [containerApp, secrets] = yield Promise.all([
|
|
87
|
+
containerAppClient.containerApps.get(resourceGroup, containerAppName),
|
|
88
|
+
containerAppClient.containerApps.listSecrets(resourceGroup, containerAppName),
|
|
89
|
+
]);
|
|
90
|
+
// insert secrets since they're not exposed by the get api
|
|
91
|
+
containerApp.configuration = Object.assign(Object.assign({}, containerApp.configuration), { secrets: secrets.value });
|
|
92
|
+
config = Object.assign(Object.assign({}, config), { service: (_a = config.service) !== null && _a !== void 0 ? _a : containerAppName });
|
|
93
|
+
yield this.instrumentSidecar(containerAppClient, config, resourceGroup, containerApp);
|
|
94
|
+
yield this.addTags(config, containerAppClient.subscriptionId, resourceGroup, containerApp);
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
this.context.stdout.write((0, renderer_1.renderError)(`Failed to instrument ${containerAppName}: ${(0, azure_1.formatError)(error)}`));
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
addTags(config, subscriptionId, resourceGroup, containerApp) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const updatedTags = Object.assign(Object.assign({}, containerApp.tags), { service: config.service, [tags_1.SERVERLESS_CLI_VERSION_TAG_NAME]: tags_1.SERVERLESS_CLI_VERSION_TAG_VALUE });
|
|
106
|
+
if (config.environment) {
|
|
107
|
+
updatedTags.env = config.environment;
|
|
108
|
+
}
|
|
109
|
+
if (config.version) {
|
|
110
|
+
updatedTags.version = config.version;
|
|
111
|
+
}
|
|
112
|
+
if (!(0, es6_1.default)(containerApp.tags, updatedTags)) {
|
|
113
|
+
this.context.stdout.write(`${this.dryRunPrefix}Updating tags for ${chalk_1.default.bold(containerApp.name)}\n`);
|
|
114
|
+
if (!this.dryRun) {
|
|
115
|
+
try {
|
|
116
|
+
yield this.tagClient.beginCreateOrUpdateAtScopeAndWait(`/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.App/containerApps/${containerApp.name}`, { properties: { tags: updatedTags } });
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
this.context.stdout.write((0, renderer_1.renderError)(`Failed to update tags for ${chalk_1.default.bold(containerApp.name)}: ${(0, azure_1.formatError)(error)}`));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
instrumentSidecar(client, config, resourceGroup, containerApp) {
|
|
126
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
// TODO add main container env vars (dd service, env, version)
|
|
129
|
+
const envVarsByName = (0, common_1.getEnvVarsByName)(config, client.subscriptionId, resourceGroup);
|
|
130
|
+
const containers = (_b = (_a = containerApp.template) === null || _a === void 0 ? void 0 : _a.containers) !== null && _b !== void 0 ? _b : [];
|
|
131
|
+
const secrets = (_d = (_c = containerApp.configuration) === null || _c === void 0 ? void 0 : _c.secrets) !== null && _d !== void 0 ? _d : [];
|
|
132
|
+
const volumes = (_f = (_e = containerApp.template) === null || _e === void 0 ? void 0 : _e.volumes) !== null && _f !== void 0 ? _f : [];
|
|
133
|
+
const sidecarContainer = containers.find((c) => c.name === constants_2.SIDECAR_CONTAINER_NAME);
|
|
134
|
+
const apiKeySecret = (_h = (_g = containerApp.configuration) === null || _g === void 0 ? void 0 : _g.secrets) === null || _h === void 0 ? void 0 : _h.find(({ name }) => name === common_1.DD_API_KEY_SECRET_NAME);
|
|
135
|
+
// checks for if we should make changes
|
|
136
|
+
const sidecarHasCorrectImage = (sidecarContainer === null || sidecarContainer === void 0 ? void 0 : sidecarContainer.image) === constants_2.SIDECAR_IMAGE;
|
|
137
|
+
const hasCorrectEnvVars = (0, es6_1.default)(Object.fromEntries(((_j = sidecarContainer === null || sidecarContainer === void 0 ? void 0 : sidecarContainer.env) !== null && _j !== void 0 ? _j : []).map((env) => [env.name, env])), envVarsByName);
|
|
138
|
+
const hasApiKey = (apiKeySecret === null || apiKeySecret === void 0 ? void 0 : apiKeySecret.value) === process.env.DD_API_KEY;
|
|
139
|
+
const hasSharedVolume = volumes.some((v) => v.name === config.sharedVolumeName);
|
|
140
|
+
const sidecarHasVolumeMount = (_k = sidecarContainer === null || sidecarContainer === void 0 ? void 0 : sidecarContainer.volumeMounts) === null || _k === void 0 ? void 0 : _k.some((mount) => mount.volumeName === config.sharedVolumeName && mount.mountPath === config.sharedVolumePath);
|
|
141
|
+
if (sidecarHasCorrectImage && hasCorrectEnvVars && hasApiKey && hasSharedVolume && sidecarHasVolumeMount) {
|
|
142
|
+
this.context.stdout.write(`${this.dryRunPrefix}Sidecar container ${chalk_1.default.bold(constants_2.SIDECAR_CONTAINER_NAME)} already exists with correct configuration.\n`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
this.context.stdout.write(`${this.dryRunPrefix}Updating configuration for ${chalk_1.default.bold(containerApp.name)}\n`);
|
|
146
|
+
if (!this.dryRun) {
|
|
147
|
+
const sharedVolume = {
|
|
148
|
+
volumeName: config.sharedVolumeName,
|
|
149
|
+
mountPath: config.sharedVolumePath,
|
|
150
|
+
};
|
|
151
|
+
// Update the Container App template with the Datadog sidecar and volume mounts
|
|
152
|
+
const newSidecar = Object.assign(Object.assign({ name: constants_2.SIDECAR_CONTAINER_NAME, image: constants_2.SIDECAR_IMAGE, env: Object.values(envVarsByName) }, { volumeMounts: [sharedVolume] }), { resources: {
|
|
153
|
+
cpu: 0.25,
|
|
154
|
+
memory: '0.5Gi',
|
|
155
|
+
} });
|
|
156
|
+
// Update all app containers to add volume mounts
|
|
157
|
+
const updatedContainers = containers.map((container) => {
|
|
158
|
+
var _a, _b;
|
|
159
|
+
const volumeMounts = (_a = container.volumeMounts) !== null && _a !== void 0 ? _a : [];
|
|
160
|
+
const currentEnvVarsByName = Object.fromEntries(((_b = container.env) !== null && _b !== void 0 ? _b : []).map((env) => [env.name, env]));
|
|
161
|
+
return Object.assign(Object.assign(Object.assign({}, container), { env: Object.values(Object.assign(Object.assign({}, currentEnvVarsByName), envVarsByName)) }), {
|
|
162
|
+
volumeMounts: volumeMounts.some((mount) => mount.volumeName === config.sharedVolumeName)
|
|
163
|
+
? volumeMounts
|
|
164
|
+
: [...volumeMounts, { volumeName: config.sharedVolumeName, mountPath: config.sharedVolumePath }],
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
// Add sidecar if it doesn't exist
|
|
168
|
+
if (!sidecarContainer) {
|
|
169
|
+
updatedContainers.push(newSidecar);
|
|
170
|
+
}
|
|
171
|
+
const newApiKeySecret = {
|
|
172
|
+
name: common_1.DD_API_KEY_SECRET_NAME,
|
|
173
|
+
value: process.env.DD_API_KEY,
|
|
174
|
+
};
|
|
175
|
+
const updatedApp = Object.assign(Object.assign({}, containerApp), { configuration: Object.assign(Object.assign({}, containerApp.configuration), { secrets: apiKeySecret
|
|
176
|
+
? secrets.map((s) => (s.name === common_1.DD_API_KEY_SECRET_NAME ? newApiKeySecret : s))
|
|
177
|
+
: [...secrets, newApiKeySecret] }), template: Object.assign(Object.assign({}, containerApp.template), { containers: updatedContainers, volumes: hasSharedVolume ? volumes : [...volumes, { name: config.sharedVolumeName, storageType: 'EmptyDir' }] }) });
|
|
178
|
+
yield client.containerApps.beginUpdateAndWait(resourceGroup, containerApp.name, updatedApp);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.PluginCommand = PluginCommand;
|
|
184
|
+
//# sourceMappingURL=instrument.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../src/commands/instrument.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA6G;AAC7G,wDAA6E;AAC7E,8CAAsD;AAEtD,2FAAwG;AACxG,kEAAmE;AACnE,oEAA0E;AAC1E,wEAAwF;AACxF,6EAA8F;AAC9F,qFAA2G;AAC3G,iHAA+G;AAC/G,gEAAuH;AACvH,kEAAiE;AACjE,kDAAyB;AACzB,8DAAuC;AAEvC,sCAAkE;AAElE,MAAa,aAAc,SAAQ,0CAA6B;IAIjD,OAAO;;;YAClB,IAAI,CAAC,UAAU,EAAE,CAAA;YACjB,MAAM,CAAC,yBAAyB,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;YAC7E,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;gBACrB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;oBAC1B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAA,sBAAW,EAAC,KAAK,CAAC,CAAC,CAAA;iBAC9C;gBAED,OAAO,CAAC,CAAA;aACT;YAED,IAAI;gBACF,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAkB,EAAC;oBAC7C,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC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 +1,4 @@
|
|
|
1
|
+
import { EnvironmentVar } from '@azure/arm-appcontainers';
|
|
2
|
+
import { ContainerAppConfigOptions } from '@datadog/datadog-ci-base/commands/container-app/common';
|
|
3
|
+
export declare const DD_API_KEY_SECRET_NAME = "dd-api-key";
|
|
4
|
+
export declare const getEnvVarsByName: (config: ContainerAppConfigOptions, subscriptionId: string, resourceGroup: string) => Record<string, EnvironmentVar>;
|
package/dist/common.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getEnvVarsByName = exports.DD_API_KEY_SECRET_NAME = void 0;
|
|
4
|
+
const common_1 = require("@datadog/datadog-ci-base/helpers/serverless/common");
|
|
5
|
+
exports.DD_API_KEY_SECRET_NAME = 'dd-api-key';
|
|
6
|
+
const getEnvVarsByName = (config, subscriptionId, resourceGroup) => {
|
|
7
|
+
// Get base environment variables
|
|
8
|
+
const envVars = Object.fromEntries(Object.entries((0, common_1.getBaseEnvVars)(config)).map(([name, value]) => [name, { name, value }]));
|
|
9
|
+
// special case for DD_API_KEY where we use a secret
|
|
10
|
+
delete envVars.DD_API_KEY.value;
|
|
11
|
+
envVars.DD_API_KEY.secretRef = exports.DD_API_KEY_SECRET_NAME;
|
|
12
|
+
envVars.DD_AZURE_SUBSCRIPTION_ID = { name: 'DD_AZURE_SUBSCRIPTION_ID', value: subscriptionId };
|
|
13
|
+
envVars.DD_AZURE_RESOURCE_GROUP = { name: 'DD_AZURE_RESOURCE_GROUP', value: resourceGroup };
|
|
14
|
+
envVars.DD_SERVERLESS_LOG_PATH = { name: 'DD_SERVERLESS_LOG_PATH', value: config.logsPath };
|
|
15
|
+
return envVars;
|
|
16
|
+
};
|
|
17
|
+
exports.getEnvVarsByName = getEnvVarsByName;
|
|
18
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../src/common.ts"],"names":[],"mappings":";;;AAEA,+EAAiF;AAEpE,QAAA,sBAAsB,GAAG,YAAY,CAAA;AAE3C,MAAM,gBAAgB,GAAG,CAC9B,MAAiC,EACjC,cAAsB,EACtB,aAAqB,EACW,EAAE;IAClC,iCAAiC;IACjC,MAAM,OAAO,GAAmC,MAAM,CAAC,WAAW,CAChE,MAAM,CAAC,OAAO,CAAC,IAAA,uBAAc,EAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAC,IAAI,EAAE,KAAK,EAAC,CAAC,CAAC,CACrF,CAAA;IAED,oDAAoD;IACpD,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAA;IAC/B,OAAO,CAAC,UAAU,CAAC,SAAS,GAAG,8BAAsB,CAAA;IAErD,OAAO,CAAC,wBAAwB,GAAG,EAAC,IAAI,EAAE,0BAA0B,EAAE,KAAK,EAAE,cAAc,EAAC,CAAA;IAC5F,OAAO,CAAC,uBAAuB,GAAG,EAAC,IAAI,EAAE,yBAAyB,EAAE,KAAK,EAAE,aAAa,EAAC,CAAA;IACzF,OAAO,CAAC,sBAAsB,GAAG,EAAC,IAAI,EAAE,wBAAwB,EAAE,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAC,CAAA;IAEzF,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAnBY,QAAA,gBAAgB,oBAmB5B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@datadog/datadog-ci-plugin-container-app",
|
|
3
|
+
"version": "4.1.3",
|
|
4
|
+
"description": "Datadog CI plugin for `container-app` commands",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"datadog",
|
|
8
|
+
"datadog-ci",
|
|
9
|
+
"plugin"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/DataDog/datadog-ci/tree/master/packages/plugin-container-app",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/DataDog/datadog-ci.git",
|
|
15
|
+
"directory": "packages/plugin-container-app"
|
|
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-base": "4.1.3"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@azure/arm-appcontainers": "^3.0.0",
|
|
42
|
+
"@azure/arm-resources": "^6.1.0",
|
|
43
|
+
"@azure/identity": "^4.10.1",
|
|
44
|
+
"chalk": "3.0.0",
|
|
45
|
+
"fast-deep-equal": "^3.1.3"
|
|
46
|
+
}
|
|
47
|
+
}
|