@datadog/datadog-ci 3.10.0 → 3.11.0

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/README.md CHANGED
@@ -43,6 +43,10 @@ The following values are available for each `<command>` and (optionally) `<subco
43
43
 
44
44
  See each command's linked README for more details, or click on [📚](https://docs.datadoghq.com/) to see the related documentation page.
45
45
 
46
+ #### `aas`
47
+ - `instrument`: Apply Datadog instrumentation to the given [Azure App Services](src/commands/aas).
48
+ - `uninstrument`: Revert Datadog instrumentation from the given [Azure App Services](src/commands/aas).
49
+
46
50
  #### `cloud-run`
47
51
  - `flare`: Troubleshoot your issues with [Cloud Run service](src/commands/cloud-run) configuration. [📚](https://docs.datadoghq.com/serverless/google_cloud_run)
48
52
 
@@ -108,6 +112,7 @@ The following are **beta** commands, you can enable them with with `DD_BETA_COMM
108
112
  #### `deployment`
109
113
  - `mark`: Mark a CI job as a [deployment](src/commands/deployment). [📚](https://docs.datadoghq.com/continuous_delivery/)
110
114
  - `correlate`: [Correlate](src/commands/deployment/) GitOps CD deployments with application repositories CI pipelines. [📚](https://docs.datadoghq.com/continuous_delivery/deployments/argocd#correlate-deployments-with-ci-pipelines)
115
+ - `correlate-image`: [Correlate an image](src/commands/deployment/) from a CD provider with its source commit. [📚](https://docs.datadoghq.com/continuous_delivery/deployments/argocd#correlate-images-with-source-code)
111
116
 
112
117
  #### `dora`
113
118
  - `deployment`: Send a new deployment event for [DORA Metrics](src/commands/dora) to Datadog. [📚](https://docs.datadoghq.com/dora_metrics/)
package/dist/cli.js CHANGED
@@ -8,7 +8,7 @@ exports.cli = exports.BETA_COMMANDS = void 0;
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const clipanion_1 = require("clipanion");
10
10
  const version_1 = require("./helpers/version");
11
- exports.BETA_COMMANDS = ['dora', 'deployment', 'elf-symbols', 'aas'];
11
+ exports.BETA_COMMANDS = ['dora', 'deployment', 'elf-symbols'];
12
12
  const onError = (err) => {
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QAAQ,CAAC,oBAAQ,CAAC,cAAc,CAAC,CAAA;AAErC,MAAM,YAAY,GAAG,GAAG,SAAS,WAAW,CAAA;AAC5C,KAAK,MAAM,aAAa,IAAI,YAAE,CAAC,WAAW,CAAC,YAAY,CAAC,EAAE;IACxD,MAAM,mBAAmB,GACvB,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,KAAK,MAAM,CAAA;IACjG,IAAI,qBAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,mBAAmB,EAAE;QACjE,SAAQ;KACT;IACD,MAAM,WAAW,GAAG,GAAG,YAAY,IAAI,aAAa,EAAE,CAAA;IACtD,IAAI,YAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,EAAE;QAC1C,8DAA8D;QAC9D,CAAC;QAAC,OAAO,CAAC,GAAG,WAAW,MAAM,CAAoB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;KAC/F;CACF;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3B,KAAK,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;QACtC,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAA;CACH"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const instrument_1 = require("./instrument");
4
- module.exports = [instrument_1.InstrumentCommand];
4
+ const uninstrument_1 = require("./uninstrument");
5
+ module.exports = [instrument_1.InstrumentCommand, uninstrument_1.UninstrumentCommand];
5
6
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/aas/cli.ts"],"names":[],"mappings":";;AAAA,6CAA8C;AAE9C,MAAM,CAAC,OAAO,GAAG,CAAC,8BAAiB,CAAC,CAAA"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/aas/cli.ts"],"names":[],"mappings":";;AAAA,6CAA8C;AAC9C,iDAAkD;AAElD,MAAM,CAAC,OAAO,GAAG,CAAC,8BAAiB,EAAE,kCAAmB,CAAC,CAAA"}
@@ -1,29 +1,47 @@
1
1
  import type { PagedAsyncIterableIterator } from '@azure/core-paging';
2
2
  import { Site } from '@azure/arm-appservice';
3
+ import { DefaultAzureCredential } from '@azure/identity';
3
4
  import { Command } from 'clipanion';
4
5
  import { AasConfigOptions } from './interfaces';
5
6
  export declare const SIDECAR_CONTAINER_NAME = "datadog-sidecar";
6
7
  export declare const SIDECAR_IMAGE = "index.docker.io/datadog/serverless-init:latest";
7
8
  export declare const SIDECAR_PORT = "8126";
9
+ export declare const AAS_DD_SETTING_NAMES: readonly ["DD_API_KEY", "DD_SITE", "DD_AAS_INSTANCE_LOGGING_ENABLED", "DD_SERVICE", "DD_ENV", "DD_SERVERLESS_LOG_PATH", "DD_DOTNET_TRACER_HOME", "DD_TRACE_LOG_DIRECTORY", "CORECLR_ENABLE_PROFILING", "CORECLR_PROFILER", "CORECLR_PROFILER_PATH"];
10
+ export type AasDatadogSettingName = typeof AAS_DD_SETTING_NAMES[number];
11
+ type AasDatadogConfig = Partial<Record<AasDatadogSettingName, string>>;
12
+ /**
13
+ * Maps Subscription ID to Resource Group to App Service names.
14
+ */
15
+ export type AasBySubscriptionAndGroup = Record<string, Record<string, string[]>>;
8
16
  export declare abstract class AasCommand extends Command {
9
17
  dryRun: boolean;
10
18
  private subscriptionId;
11
19
  private resourceGroup;
12
20
  private aasName;
21
+ private resourceIds;
13
22
  private configPath;
14
- private service;
15
- private environment;
16
- private isInstanceLoggingEnabled;
17
- private logPath;
18
- private isDotnet;
19
23
  private fips;
20
24
  private fipsIgnoreError;
21
25
  private fipsConfig;
22
26
  get dryRunPrefix(): string;
27
+ get additionalConfig(): Partial<AasConfigOptions>;
23
28
  enableFips(): void;
24
- ensureConfig(): Promise<[AasConfigOptions, string[]]>;
29
+ ensureConfig(): Promise<[AasBySubscriptionAndGroup, AasConfigOptions, string[]]>;
30
+ ensureAzureAuth(cred: DefaultAzureCredential): Promise<boolean>;
31
+ ensureLinux(site: Site): boolean;
25
32
  }
26
- export declare const getEnvVars: (config: AasConfigOptions) => Record<string, string>;
33
+ export declare const getEnvVars: (config: AasConfigOptions) => AasDatadogConfig;
27
34
  export declare const isWindows: (site: Site) => boolean;
28
35
  export declare const isDotnet: (site: Site) => boolean;
29
36
  export declare const collectAsyncIterator: <T>(it: PagedAsyncIterableIterator<T, T[], import("@azure/core-paging").PageSettings>) => Promise<T[]>;
37
+ /**
38
+ * Formats an error (usually an Azure RestError) object into a string for display.
39
+ */
40
+ export declare const formatError: (error: any) => string;
41
+ interface Resource {
42
+ subscriptionId: string;
43
+ resourceGroup: string;
44
+ name: string;
45
+ }
46
+ export declare const parseResourceId: (resourceId: string) => Resource | undefined;
47
+ export {};
@@ -15,8 +15,12 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
15
15
  function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
18
21
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.collectAsyncIterator = exports.isDotnet = exports.isWindows = exports.getEnvVars = exports.AasCommand = exports.SIDECAR_PORT = exports.SIDECAR_IMAGE = exports.SIDECAR_CONTAINER_NAME = void 0;
22
+ exports.parseResourceId = exports.formatError = exports.collectAsyncIterator = exports.isDotnet = exports.isWindows = exports.getEnvVars = exports.AasCommand = exports.AAS_DD_SETTING_NAMES = exports.SIDECAR_PORT = exports.SIDECAR_IMAGE = exports.SIDECAR_CONTAINER_NAME = void 0;
23
+ const chalk_1 = __importDefault(require("chalk"));
20
24
  const clipanion_1 = require("clipanion");
21
25
  const constants_1 = require("../../constants");
22
26
  const env_1 = require("../../helpers/env");
@@ -36,6 +40,19 @@ const CORECLR_ENABLE_PROFILING = '1';
36
40
  const CORECLR_PROFILER = '{846F5F1C-F9AE-4B07-969E-05C26BC060D8}';
37
41
  // The profiler binary that the .NET CLR loads into memory, which contains the GUID
38
42
  const CORECLR_PROFILER_PATH = '/home/site/wwwroot/datadog/linux-musl-x64/Datadog.Trace.ClrProfiler.Native.so';
43
+ exports.AAS_DD_SETTING_NAMES = [
44
+ 'DD_API_KEY',
45
+ 'DD_SITE',
46
+ 'DD_AAS_INSTANCE_LOGGING_ENABLED',
47
+ 'DD_SERVICE',
48
+ 'DD_ENV',
49
+ 'DD_SERVERLESS_LOG_PATH',
50
+ 'DD_DOTNET_TRACER_HOME',
51
+ 'DD_TRACE_LOG_DIRECTORY',
52
+ 'CORECLR_ENABLE_PROFILING',
53
+ 'CORECLR_PROFILER',
54
+ 'CORECLR_PROFILER_PATH',
55
+ ];
39
56
  class AasCommand extends clipanion_1.Command {
40
57
  constructor() {
41
58
  var _a, _b;
@@ -52,24 +69,12 @@ class AasCommand extends clipanion_1.Command {
52
69
  this.aasName = clipanion_1.Option.String('-n,--name', {
53
70
  description: 'Name of the Azure App Service to instrument',
54
71
  });
72
+ this.resourceIds = clipanion_1.Option.Array('-r,--resource-id', {
73
+ description: 'Full Azure resource IDs to instrument, eg "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Web/sites/{aasName}"',
74
+ });
55
75
  this.configPath = clipanion_1.Option.String('--config', {
56
76
  description: 'Path to the configuration file',
57
77
  });
58
- this.service = clipanion_1.Option.String('--service', {
59
- description: 'How you want to tag your service. For example, `my-service`',
60
- });
61
- this.environment = clipanion_1.Option.String('--env,--environment', {
62
- description: 'How you want to tag your env. For example, `prod`',
63
- });
64
- this.isInstanceLoggingEnabled = clipanion_1.Option.Boolean('--instance-logging', false, {
65
- description: 'When enabled, log collection is automatically configured for an additional file path: /home/LogFiles/*$COMPUTERNAME*.log',
66
- });
67
- this.logPath = clipanion_1.Option.String('--log-path', {
68
- description: 'Where you write your logs. For example, /home/LogFiles/*.log or /home/LogFiles/myapp/*.log',
69
- });
70
- this.isDotnet = clipanion_1.Option.Boolean('--dotnet', false, {
71
- description: 'Add in required .NET-specific configuration options, is automatically inferred for code runtimes. This should be specified if you are using a containerized .NET app.',
72
- });
73
78
  this.fips = clipanion_1.Option.Boolean('--fips', false);
74
79
  this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
75
80
  this.fipsConfig = {
@@ -80,50 +85,88 @@ class AasCommand extends clipanion_1.Command {
80
85
  get dryRunPrefix() {
81
86
  return this.dryRun ? renderer_1.dryRunTag + ' ' : '';
82
87
  }
88
+ get additionalConfig() {
89
+ return {};
90
+ }
83
91
  enableFips() {
84
92
  (0, fips_1.enableFips)(this.fips || this.fipsConfig.fips, this.fipsIgnoreError || this.fipsConfig.fipsIgnoreError);
85
93
  }
86
94
  ensureConfig() {
95
+ var _a, _b;
87
96
  return __awaiter(this, void 0, void 0, function* () {
88
97
  const config = (yield (0, utils_1.resolveConfigFromFile)({
89
- aas: {
90
- subscriptionId: this.subscriptionId,
91
- resourceGroup: this.resourceGroup,
92
- aasName: this.aasName,
93
- service: this.service,
94
- environment: this.environment,
95
- isInstanceLoggingEnabled: this.isInstanceLoggingEnabled,
96
- logPath: this.logPath,
97
- isDotnet: this.isDotnet,
98
- },
98
+ aas: Object.assign({ subscriptionId: this.subscriptionId, resourceGroup: this.resourceGroup, aasName: this.aasName }, this.additionalConfig),
99
99
  }, {
100
100
  configPath: this.configPath,
101
101
  defaultConfigPaths: utils_1.DEFAULT_CONFIG_PATHS,
102
102
  })).aas;
103
+ const appServices = {};
103
104
  const errors = [];
104
105
  if (process.env.DD_API_KEY === undefined) {
105
106
  errors.push('DD_API_KEY environment variable is required');
106
107
  }
107
- if (!this.subscriptionId) {
108
- errors.push('--subscription-id is required');
108
+ const specifiedSiteArgs = [config.subscriptionId, config.resourceGroup, config.aasName];
109
+ // all or none of the site args should be specified
110
+ if (!(specifiedSiteArgs.every((arg) => arg) || specifiedSiteArgs.every((arg) => !arg))) {
111
+ errors.push('--subscription-id, --resource-group, and --name must be specified together or not at all');
112
+ }
113
+ else if (specifiedSiteArgs.every((arg) => arg)) {
114
+ appServices[config.subscriptionId] = { [config.resourceGroup]: [config.aasName] };
115
+ }
116
+ if ((_a = this.resourceIds) === null || _a === void 0 ? void 0 : _a.length) {
117
+ for (const resourceId of this.resourceIds) {
118
+ const parsed = (0, exports.parseResourceId)(resourceId);
119
+ if (parsed) {
120
+ const { subscriptionId, resourceGroup, name } = parsed;
121
+ if (!appServices[subscriptionId]) {
122
+ appServices[subscriptionId] = {};
123
+ }
124
+ if (!appServices[subscriptionId][resourceGroup]) {
125
+ appServices[subscriptionId][resourceGroup] = [];
126
+ }
127
+ appServices[subscriptionId][resourceGroup].push(name);
128
+ }
129
+ else {
130
+ errors.push(`Invalid AAS resource ID: ${resourceId}`);
131
+ }
132
+ }
109
133
  }
110
- if (!this.resourceGroup) {
111
- errors.push('--resource-group is required');
134
+ if (!((_b = this.resourceIds) === null || _b === void 0 ? void 0 : _b.length) && specifiedSiteArgs.every((arg) => !arg)) {
135
+ errors.push('No App Services specified to instrument');
112
136
  }
113
- if (!this.aasName) {
114
- errors.push('App Service (--name) is required');
137
+ return [appServices, config, errors];
138
+ });
139
+ }
140
+ ensureAzureAuth(cred) {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ try {
143
+ yield cred.getToken('https://management.azure.com/.default');
115
144
  }
116
- return [config, errors];
145
+ catch (error) {
146
+ this.context.stdout.write((0, renderer_1.renderSoftWarning)(`Failed to authenticate with Azure: ${error.name}\n\nPlease ensure that you have the Azure CLI installed (https://aka.ms/azure-cli) and have run ${chalk_1.default.bold('az login')} to authenticate.\n`));
147
+ return false;
148
+ }
149
+ return true;
117
150
  });
118
151
  }
152
+ ensureLinux(site) {
153
+ if ((0, exports.isWindows)(site)) {
154
+ this.context.stdout.write((0, renderer_1.renderSoftWarning)(`Unable to instrument ${site.name}. Only Linux-based Azure App Services are currently supported.
155
+ Please see the documentation for information on
156
+ how to instrument Windows-based App Services:
157
+ https://docs.datadoghq.com/serverless/azure_app_services/azure_app_services_windows`));
158
+ return false;
159
+ }
160
+ return true;
161
+ }
119
162
  }
120
163
  exports.AasCommand = AasCommand;
121
164
  const getEnvVars = (config) => {
122
- var _a;
165
+ var _a, _b;
123
166
  let envVars = {
124
167
  DD_API_KEY: process.env.DD_API_KEY,
125
168
  DD_SITE: (_a = process.env.DD_SITE) !== null && _a !== void 0 ? _a : constants_1.DATADOG_SITE_US1,
126
- DD_AAS_INSTANCE_LOGGING_ENABLED: config.isInstanceLoggingEnabled.toString(),
169
+ DD_AAS_INSTANCE_LOGGING_ENABLED: ((_b = config.isInstanceLoggingEnabled) !== null && _b !== void 0 ? _b : false).toString(),
127
170
  };
128
171
  if (config.service) {
129
172
  envVars.DD_SERVICE = config.service;
@@ -180,4 +223,23 @@ const collectAsyncIterator = (it) => { var _a, it_1, it_1_1; return __awaiter(vo
180
223
  return arr;
181
224
  }); };
182
225
  exports.collectAsyncIterator = collectAsyncIterator;
226
+ /**
227
+ * Formats an error (usually an Azure RestError) object into a string for display.
228
+ */
229
+ // no-dd-sa:typescript-best-practices/no-explicit-any
230
+ const formatError = (error) => {
231
+ var _a, _b, _c;
232
+ const errorType = (_a = error.code) !== null && _a !== void 0 ? _a : error.name;
233
+ const errorMessage = (_c = (_b = error.details) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : error.message;
234
+ return `${errorType}: ${errorMessage}`;
235
+ };
236
+ exports.formatError = formatError;
237
+ const parseResourceId = (resourceId) => {
238
+ const match = resourceId.match(/^\/subscriptions\/([^/]+)\/resourceGroups\/([^/]+)\/providers\/Microsoft\.Web\/sites\/([^/]+)$/i);
239
+ if (match) {
240
+ const [, subscriptionId, resourceGroup, name] = match;
241
+ return { subscriptionId, resourceGroup, name };
242
+ }
243
+ };
244
+ exports.parseResourceId = parseResourceId;
183
245
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/commands/aas/common.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,yCAAyC;AAEzC,+CAAyF;AACzF,2CAA2C;AAC3C,6CAA6C;AAC7C,qDAAgD;AAChD,+CAA+E;AAIlE,QAAA,sBAAsB,GAAG,iBAAiB,CAAA;AAC1C,QAAA,aAAa,GAAG,gDAAgD,CAAA;AAChE,QAAA,YAAY,GAAG,MAAM,CAAA;AAElC,2DAA2D;AAC3D,MAAM,qBAAqB,GAAG,4BAA4B,CAAA;AAC1D,+BAA+B;AAC/B,MAAM,sBAAsB,GAAG,uBAAuB,CAAA;AACtD,0DAA0D;AAC1D,MAAM,wBAAwB,GAAG,GAAG,CAAA;AACpC,gBAAgB;AAChB,MAAM,gBAAgB,GAAG,wCAAwC,CAAA;AACjE,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,+EAA+E,CAAA;AAE7G,MAAsB,UAAW,SAAQ,mBAAO;IAAhD;;;QACS,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE;YACpD,WAAW,EAAE,6DAA6D;SAC3E,CAAC,CAAA;QACM,mBAAc,GAAG,kBAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE;YAC7D,WAAW,EAAE,kDAAkD;SAChE,CAAC,CAAA;QACM,kBAAa,GAAG,kBAAM,CAAC,MAAM,CAAC,qBAAqB,EAAE;YAC3D,WAAW,EAAE,6DAA6D;SAC3E,CAAC,CAAA;Q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CAAC,CAAC,CAAA;SACZ;;;;;;;;;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,IAAA,CAAA;AAPY,QAAA,oBAAoB,wBAOhC;AAED;;GAEG;AACH,qDAAqD;AAC9C,MAAM,WAAW,GAAG,CAAC,KAAU,EAAU,EAAE;;IAChD,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,IAAI,mCAAI,KAAK,CAAC,IAAI,CAAA;IAC1C,MAAM,YAAY,GAAG,MAAA,MAAA,KAAK,CAAC,OAAO,0CAAE,OAAO,mCAAI,KAAK,CAAC,OAAO,CAAA;IAE5D,OAAO,GAAG,SAAS,KAAK,YAAY,EAAE,CAAA;AACxC,CAAC,CAAA;AALY,QAAA,WAAW,eAKvB;AAQM,MAAM,eAAe,GAAG,CAAC,UAAkB,EAAwB,EAAE;IAC1E,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAC5B,iGAAiG,CAClG,CAAA;IACD,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,EAAE,cAAc,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,KAAK,CAAA;QAErD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAE,IAAI,EAAC,CAAA;KAC7C;AACH,CAAC,CAAA;AATY,QAAA,eAAe,mBAS3B"}
@@ -1,10 +1,23 @@
1
1
  import { WebSiteManagementClient } from '@azure/arm-appservice';
2
+ import { DefaultAzureCredential } from '@azure/identity';
2
3
  import { AasCommand } from './common';
3
4
  import { AasConfigOptions } from './interfaces';
4
5
  export declare class InstrumentCommand extends AasCommand {
5
6
  static paths: string[][];
6
7
  static usage: import("clipanion").Usage;
8
+ private service;
9
+ private environment;
10
+ private isInstanceLoggingEnabled;
11
+ private logPath;
7
12
  private shouldNotRestart;
13
+ private isDotnet;
14
+ get additionalConfig(): Partial<AasConfigOptions>;
8
15
  execute(): Promise<0 | 1>;
16
+ processSubscription(cred: DefaultAzureCredential, subscriptionId: string, resourceGroupToNames: Record<string, string[]>, config: AasConfigOptions): Promise<boolean>;
17
+ /**
18
+ * Process an Azure App Service for instrumentation.
19
+ * @returns A promise that resolves to a boolean indicating success or failure.
20
+ */
21
+ processAas(client: WebSiteManagementClient, config: AasConfigOptions, resourceGroup: string, aasName: string): Promise<boolean>;
9
22
  instrumentSidecar(client: WebSiteManagementClient, config: AasConfigOptions, resourceGroup: string, aasName: string): Promise<void>;
10
23
  }
@@ -26,15 +26,40 @@ const common_1 = require("./common");
26
26
  class InstrumentCommand extends common_1.AasCommand {
27
27
  constructor() {
28
28
  super(...arguments);
29
+ this.service = clipanion_1.Option.String('--service', {
30
+ description: 'How you want to tag your service. For example, `my-service`',
31
+ });
32
+ this.environment = clipanion_1.Option.String('--env,--environment', {
33
+ description: 'How you want to tag your env. For example, `prod`',
34
+ });
35
+ this.isInstanceLoggingEnabled = clipanion_1.Option.Boolean('--instance-logging', false, {
36
+ description: 'When enabled, log collection is automatically configured for an additional file path: /home/LogFiles/*$COMPUTERNAME*.log',
37
+ });
38
+ this.logPath = clipanion_1.Option.String('--log-path', {
39
+ description: 'Where you write your logs. For example, /home/LogFiles/*.log or /home/LogFiles/myapp/*.log',
40
+ });
29
41
  this.shouldNotRestart = clipanion_1.Option.Boolean('--no-restart', false, {
30
42
  description: 'Do not restart the App Service after applying instrumentation.',
31
43
  });
44
+ this.isDotnet = clipanion_1.Option.Boolean('--dotnet', false, {
45
+ description: 'Add in required .NET-specific configuration options, is automatically inferred for code runtimes. This should be specified if you are using a containerized .NET app.',
46
+ });
47
+ }
48
+ get additionalConfig() {
49
+ return {
50
+ service: this.service,
51
+ environment: this.environment,
52
+ isInstanceLoggingEnabled: this.isInstanceLoggingEnabled,
53
+ logPath: this.logPath,
54
+ shouldNotRestart: this.shouldNotRestart,
55
+ isDotnet: this.isDotnet,
56
+ };
32
57
  }
33
58
  execute() {
34
59
  var _a, _b;
35
60
  return __awaiter(this, void 0, void 0, function* () {
36
61
  this.enableFips();
37
- const [config, errors] = yield this.ensureConfig();
62
+ const [appServicesToInstrument, config, errors] = yield this.ensureConfig();
38
63
  if (errors.length > 0) {
39
64
  for (const error of errors) {
40
65
  this.context.stdout.write((0, renderer_1.renderError)(error));
@@ -50,45 +75,53 @@ class InstrumentCommand extends common_1.AasCommand {
50
75
  return 1;
51
76
  }
52
77
  const cred = new identity_1.DefaultAzureCredential();
53
- try {
54
- yield cred.getToken('https://management.azure.com/.default');
55
- }
56
- catch (error) {
57
- this.context.stdout.write((0, renderer_1.renderSoftWarning)(`Failed to authenticate with Azure: ${error.name}\n\nPlease ensure that you have the Azure CLI installed (https://aka.ms/azure-cli) and have run ${chalk_1.default.bold('az login')} to authenticate.\n`));
78
+ if (!(yield this.ensureAzureAuth(cred))) {
58
79
  return 1;
59
80
  }
60
- this.context.stdout.write(`${this.dryRunPrefix}🐶 Instrumenting Azure App Service\n`);
61
- const client = new arm_appservice_1.WebSiteManagementClient(cred, config.subscriptionId, { apiVersion: '2024-11-01' });
62
- const site = yield client.webApps.get(config.resourceGroup, config.aasName);
63
- if ((0, common_1.isWindows)(site)) {
64
- this.context.stdout.write((0, renderer_1.renderSoftWarning)(`Only Linux-based Azure App Services are currently supported.
65
- Please see the documentation for information on
66
- how to instrument Windows-based App Services:
67
- https://docs.datadoghq.com/serverless/azure_app_services/azure_app_services_windows`));
68
- return 1;
69
- }
70
- config.isDotnet = config.isDotnet || (0, common_1.isDotnet)(site);
81
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Beginning instrumentation of Azure App Service(s)\n`);
82
+ const results = yield Promise.all(Object.entries(appServicesToInstrument).map(([subscriptionId, resourceGroupToNames]) => this.processSubscription(cred, subscriptionId, resourceGroupToNames, config)));
83
+ const success = results.every((result) => result);
84
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Instrumentation completed ${success ? 'successfully!' : 'with errors, see above for details.'}\n`);
85
+ return success ? 0 : 1;
86
+ });
87
+ }
88
+ processSubscription(cred, subscriptionId, resourceGroupToNames, config) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ const client = new arm_appservice_1.WebSiteManagementClient(cred, subscriptionId, { apiVersion: '2024-11-01' });
91
+ const results = yield Promise.all(Object.entries(resourceGroupToNames).flatMap(([resourceGroup, aasNames]) => aasNames.map((aasName) => this.processAas(client, config, resourceGroup, aasName))));
92
+ return results.every((result) => result);
93
+ });
94
+ }
95
+ /**
96
+ * Process an Azure App Service for instrumentation.
97
+ * @returns A promise that resolves to a boolean indicating success or failure.
98
+ */
99
+ processAas(client, config, resourceGroup, aasName) {
100
+ return __awaiter(this, void 0, void 0, function* () {
71
101
  try {
72
- yield this.instrumentSidecar(client, config, config.resourceGroup, config.aasName);
102
+ const site = yield client.webApps.get(resourceGroup, aasName);
103
+ if (!this.ensureLinux(site)) {
104
+ return false;
105
+ }
106
+ yield this.instrumentSidecar(client, Object.assign(Object.assign({}, config), { isDotnet: config.isDotnet || (0, common_1.isDotnet)(site) }), resourceGroup, aasName);
73
107
  }
74
108
  catch (error) {
75
- this.context.stdout.write((0, renderer_1.renderError)(`Failed to instrument sidecar: ${error}`));
76
- return 1;
109
+ this.context.stdout.write((0, renderer_1.renderError)(`Failed to instrument ${aasName}: ${(0, common_1.formatError)(error)}`));
110
+ return false;
77
111
  }
78
- if (!this.shouldNotRestart) {
79
- this.context.stdout.write(`${this.dryRunPrefix}Restarting Azure App Service\n`);
112
+ if (!config.shouldNotRestart) {
113
+ this.context.stdout.write(`${this.dryRunPrefix}Restarting Azure App Service ${chalk_1.default.bold(aasName)}\n`);
80
114
  if (!this.dryRun) {
81
115
  try {
82
- yield client.webApps.restart(config.resourceGroup, config.aasName);
116
+ yield client.webApps.restart(resourceGroup, aasName);
83
117
  }
84
118
  catch (error) {
85
- this.context.stdout.write((0, renderer_1.renderError)(`Failed to restart Azure App Service: ${error}`));
86
- return 1;
119
+ this.context.stdout.write((0, renderer_1.renderError)(`Failed to restart Azure App Service ${chalk_1.default.bold(aasName)}: ${error}`));
120
+ return false;
87
121
  }
88
122
  }
89
123
  }
90
- this.context.stdout.write(`${this.dryRunPrefix}🐶 Instrumentation complete!\n`);
91
- return 0;
124
+ return true;
92
125
  });
93
126
  }
94
127
  instrumentSidecar(client, config, resourceGroup, aasName) {
@@ -105,7 +138,7 @@ https://docs.datadoghq.com/serverless/azure_app_services/azure_app_services_wind
105
138
  sidecarContainer.targetPort !== common_1.SIDECAR_PORT ||
106
139
  !((_a = sidecarContainer.environmentVariables) === null || _a === void 0 ? void 0 : _a.every(({ name, value }) => name === value)) ||
107
140
  !(0, es6_1.default)(new Set(sidecarContainer.environmentVariables.map(({ name }) => name)), new Set(Object.keys(envVars)))) {
108
- this.context.stdout.write(`${this.dryRunPrefix}${sidecarContainer === undefined ? 'Creating' : 'Updating'} sidecar container ${chalk_1.default.bold(common_1.SIDECAR_CONTAINER_NAME)}\n`);
141
+ this.context.stdout.write(`${this.dryRunPrefix}${sidecarContainer === undefined ? 'Creating' : 'Updating'} sidecar container ${chalk_1.default.bold(common_1.SIDECAR_CONTAINER_NAME)} on ${chalk_1.default.bold(aasName)}\n`);
109
142
  if (!this.dryRun) {
110
143
  yield client.webApps.createOrUpdateSiteContainer(resourceGroup, aasName, common_1.SIDECAR_CONTAINER_NAME, {
111
144
  image: common_1.SIDECAR_IMAGE,
@@ -121,13 +154,13 @@ https://docs.datadoghq.com/serverless/azure_app_services/azure_app_services_wind
121
154
  const existingEnvVars = yield client.webApps.listApplicationSettings(resourceGroup, aasName);
122
155
  const updatedEnvVars = { properties: Object.assign(Object.assign({}, existingEnvVars.properties), envVars) };
123
156
  if (!(0, es6_1.default)(existingEnvVars.properties, updatedEnvVars.properties)) {
124
- this.context.stdout.write(`${this.dryRunPrefix}Updating Application Settings\n`);
157
+ this.context.stdout.write(`${this.dryRunPrefix}Updating Application Settings for ${chalk_1.default.bold(aasName)}\n`);
125
158
  if (!this.dryRun) {
126
159
  yield client.webApps.updateApplicationSettings(resourceGroup, aasName, updatedEnvVars);
127
160
  }
128
161
  }
129
162
  else {
130
- this.context.stdout.write(`${this.dryRunPrefix}No Application Settings changes needed.\n`);
163
+ this.context.stdout.write(`${this.dryRunPrefix}No Application Settings changes needed for ${chalk_1.default.bold(aasName)}.\n`);
131
164
  }
132
165
  });
133
166
  }
@@ -1 +1 @@
1
- {"version":3,"file":"instrument.js","sourceRoot":"","sources":["../../../src/commands/aas/instrument.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA+E;AAC/E,8CAAsD;AACtD,kDAAyB;AACzB,yCAAyC;AACzC,8DAAuC;AAEvC,+CAAgD;AAChD,iDAAuD;AACvD,qDAAqE;AACrE,+CAA8C;AAE9C,qCASiB;AAGjB,MAAa,iBAAkB,SAAQ,mBAAU;IAAjD;;QAOU,qBAAgB,GAAG,kBAAM,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE;YAC/D,WAAW,EAAE,gEAAgE;SAC9E,CAAC,CAAA;IAyIJ,CAAC;IAvIc,OAAO;;;YAClB,IAAI,CAAC,UAAU,EAAE,CAAA;YACjB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,YAAY,EAAE,CAAA;YAClD,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;YACD,MAAM,aAAa,GAAG,MAAM,IAAA,2BAAkB,EAAC;gBAC7C,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU;gBAC9B,WAAW,EAAE,MAAA,OAAO,CAAC,GAAG,CAAC,OAAO,mCAAI,4BAAgB;aACrD,CAAC,CAAC,cAAc,EAAE,CAAA;YACnB,IAAI,CAAC,aAAa,EAAE;gBAClB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACvB,IAAA,4BAAiB,EACf,sDAAsD,eAA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C,KAAK,CACvB,GAAG,IAAI,CAAC,YAAY,qBAAqB,eAAK,CAAC,IAAI,CACjD,+BAAsB,CACvB,+CAA+C,CACjD,CAAA;aACF;YACD,MAAM,eAAe,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,uBAAuB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;YAC5F,MAAM,cAAc,GAAqB,EAAC,UAAU,kCAAM,eAAe,CAAC,UAAU,GAAK,OAAO,CAAC,EAAC,CAAA;YAClG,IAAI,CAAC,IAAA,aAAK,EAAC,eAAe,CAAC,UAAU,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE;gBACjE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,qCAAqC,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC3G,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBAChB,MAAM,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,aAAa,EAAE,OAAO,EAAE,cAAc,CAAC,CAAA;iBACvF;aACF;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACvB,GAAG,IAAI,CAAC,YAAY,8CAA8C,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAC3F,CAAA;aACF;;KACF;;AArMH,8CAsMC;AArMe,uBAAK,GAAG,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,AAA1B,CAA0B;AAC/B,uBAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,wDAAwD;CACtE,CAAC,AAHiB,CAGjB"}
@@ -3,15 +3,14 @@
3
3
  * the CLI in order to instrument properly.
4
4
  */
5
5
  export interface AasConfigOptions {
6
- subscriptionId: string;
7
- resourceGroup: string;
8
- aasName: string;
9
- service: string | undefined;
10
- environment: string | undefined;
11
- isInstanceLoggingEnabled: boolean;
12
- logPath: string | undefined;
13
- isDotnet: boolean;
6
+ subscriptionId?: string;
7
+ resourceGroup?: string;
8
+ aasName?: string;
9
+ resourceIds?: string[];
10
+ service?: string;
11
+ environment?: string;
12
+ isInstanceLoggingEnabled?: boolean;
13
+ logPath?: string;
14
+ isDotnet?: boolean;
15
+ shouldNotRestart?: boolean;
14
16
  }
15
- export type ValueOptional<T> = {
16
- [K in keyof T]: T[K] | undefined;
17
- };
@@ -0,0 +1,16 @@
1
+ import { WebSiteManagementClient } from '@azure/arm-appservice';
2
+ import { DefaultAzureCredential } from '@azure/identity';
3
+ import { AasCommand } from './common';
4
+ import { AasConfigOptions } from './interfaces';
5
+ export declare class UninstrumentCommand extends AasCommand {
6
+ static paths: string[][];
7
+ static usage: import("clipanion").Usage;
8
+ execute(): Promise<0 | 1>;
9
+ processSubscription(cred: DefaultAzureCredential, subscriptionId: string, resourceGroupToNames: Record<string, string[]>, config: AasConfigOptions): Promise<boolean>;
10
+ /**
11
+ * Process an Azure App Service for uninstrumentation.
12
+ * @returns A promise that resolves to a boolean indicating success or failure.
13
+ */
14
+ processAas(client: WebSiteManagementClient, config: AasConfigOptions, resourceGroup: string, aasName: string): Promise<boolean>;
15
+ uninstrumentSidecar(client: WebSiteManagementClient, config: AasConfigOptions, resourceGroup: string, aasName: string): Promise<void>;
16
+ }
@@ -0,0 +1,99 @@
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.UninstrumentCommand = void 0;
16
+ const arm_appservice_1 = require("@azure/arm-appservice");
17
+ const identity_1 = require("@azure/identity");
18
+ const chalk_1 = __importDefault(require("chalk"));
19
+ const clipanion_1 = require("clipanion");
20
+ const renderer_1 = require("../../helpers/renderer");
21
+ const common_1 = require("./common");
22
+ class UninstrumentCommand extends common_1.AasCommand {
23
+ execute() {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ this.enableFips();
26
+ const [appServicesToUninstrument, config, errors] = yield this.ensureConfig();
27
+ if (errors.length > 0) {
28
+ for (const error of errors) {
29
+ this.context.stdout.write((0, renderer_1.renderError)(error));
30
+ }
31
+ return 1;
32
+ }
33
+ const cred = new identity_1.DefaultAzureCredential();
34
+ if (!(yield this.ensureAzureAuth(cred))) {
35
+ return 1;
36
+ }
37
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Beginning uninstrumentation of Azure App Service(s)\n`);
38
+ const results = yield Promise.all(Object.entries(appServicesToUninstrument).map(([subscriptionId, resourceGroupToNames]) => this.processSubscription(cred, subscriptionId, resourceGroupToNames, config)));
39
+ const success = results.every((result) => result);
40
+ this.context.stdout.write(`${this.dryRunPrefix}🐶 Uninstrumentation completed ${success ? 'successfully!' : 'with errors, see above for details.'}\n`);
41
+ return success ? 0 : 1;
42
+ });
43
+ }
44
+ processSubscription(cred, subscriptionId, resourceGroupToNames, config) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ const client = new arm_appservice_1.WebSiteManagementClient(cred, subscriptionId, { apiVersion: '2024-11-01' });
47
+ const results = yield Promise.all(Object.entries(resourceGroupToNames).flatMap(([resourceGroup, aasNames]) => aasNames.map((aasName) => this.processAas(client, config, resourceGroup, aasName))));
48
+ return results.every((result) => result);
49
+ });
50
+ }
51
+ /**
52
+ * Process an Azure App Service for uninstrumentation.
53
+ * @returns A promise that resolves to a boolean indicating success or failure.
54
+ */
55
+ processAas(client, config, resourceGroup, aasName) {
56
+ return __awaiter(this, void 0, void 0, function* () {
57
+ try {
58
+ const site = yield client.webApps.get(resourceGroup, aasName);
59
+ if (!this.ensureLinux(site)) {
60
+ return false;
61
+ }
62
+ yield this.uninstrumentSidecar(client, Object.assign(Object.assign({}, config), { isDotnet: config.isDotnet || (0, common_1.isDotnet)(site) }), resourceGroup, aasName);
63
+ }
64
+ catch (error) {
65
+ this.context.stdout.write((0, renderer_1.renderError)(`Failed to uninstrument ${chalk_1.default.bold(aasName)}: ${(0, common_1.formatError)(error)}`));
66
+ return false;
67
+ }
68
+ return true;
69
+ });
70
+ }
71
+ uninstrumentSidecar(client, config, resourceGroup, aasName) {
72
+ return __awaiter(this, void 0, void 0, function* () {
73
+ this.context.stdout.write(`${this.dryRunPrefix}Removing sidecar container ${chalk_1.default.bold(common_1.SIDECAR_CONTAINER_NAME)} from ${chalk_1.default.bold(aasName)} (if it exists)\n`);
74
+ if (!this.dryRun) {
75
+ yield client.webApps.deleteSiteContainer(resourceGroup, aasName, common_1.SIDECAR_CONTAINER_NAME);
76
+ }
77
+ this.context.stdout.write(`${this.dryRunPrefix}Checking Application Settings on ${chalk_1.default.bold(aasName)}\n`);
78
+ const currentEnvVars = (yield client.webApps.listApplicationSettings(resourceGroup, aasName)).properties;
79
+ if (currentEnvVars !== undefined && common_1.AAS_DD_SETTING_NAMES.some((key) => key in currentEnvVars)) {
80
+ this.context.stdout.write(`${this.dryRunPrefix}Updating Application Settings for ${chalk_1.default.bold(aasName)}\n`);
81
+ if (!this.dryRun) {
82
+ yield client.webApps.updateApplicationSettings(resourceGroup, aasName, {
83
+ properties: Object.fromEntries(Object.entries(currentEnvVars).filter(([key]) => !common_1.AAS_DD_SETTING_NAMES.includes(key))),
84
+ });
85
+ }
86
+ }
87
+ else {
88
+ this.context.stdout.write(`${this.dryRunPrefix}No Application Settings changes needed for ${chalk_1.default.bold(aasName)}.\n`);
89
+ }
90
+ });
91
+ }
92
+ }
93
+ exports.UninstrumentCommand = UninstrumentCommand;
94
+ UninstrumentCommand.paths = [['aas', 'uninstrument']];
95
+ UninstrumentCommand.usage = clipanion_1.Command.Usage({
96
+ category: 'Serverless',
97
+ description: 'Remove Datadog instrumentation from an Azure App Service.',
98
+ });
99
+ //# sourceMappingURL=uninstrument.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uninstrument.js","sourceRoot":"","sources":["../../../src/commands/aas/uninstrument.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0DAA6D;AAC7D,8CAAsD;AACtD,kDAAyB;AACzB,yCAAiC;AAEjC,qDAAkD;AAElD,qCAAwG;AAGxG,MAAa,mBAAoB,SAAQ,mBAAU;IAOpC,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,MAAM,IAAI,GAAG,IAAI,iCAAsB,EAAE,CAAA;YACzC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,EAAE;gBACvC,OAAO,CAAC,CAAA;aACT;YACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,0DAA0D,CAAC,CAAA;YACzG,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAC/B,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,cAAc,EAAE,oBA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YACxG,IAAI,cAAc,KAAK,SAAS,IAAI,6BAAoB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,cAAc,CAAC,EAAE;gBAC7F,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,YAAY,qCAAqC,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC3G,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;oBAChB,MAAM,MAAM,CAAC,OAAO,CAAC,yBAAyB,CAAC,aAAa,EAAE,OAAO,EAAE;wBACrE,UAAU,EAAE,MAAM,CAAC,WAAW,CAC5B,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAE,6BAA0C,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAC7G;qBACF,CAAC,CAAA;iBACH;aACF;iBAAM;gBACL,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CACvB,GAAG,IAAI,CAAC,YAAY,8CAA8C,eAAK,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAC3F,CAAA;aACF;QACH,CAAC;KAAA;;AAnHH,kDAoHC;AAnHe,yBAAK,GAAG,CAAC,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,CAAA;AACjC,yBAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,YAAY;IACtB,WAAW,EAAE,2DAA2D;CACzE,CAAC,CAAA"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const correlate_1 = require("./correlate");
4
+ const correlate_image_1 = require("./correlate-image");
4
5
  const mark_1 = require("./mark");
5
- module.exports = [mark_1.DeploymentMarkCommand, correlate_1.DeploymentCorrelateCommand];
6
+ module.exports = [mark_1.DeploymentMarkCommand, correlate_1.DeploymentCorrelateCommand, correlate_image_1.DeploymentCorrelateImageCommand];
6
7
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/deployment/cli.ts"],"names":[],"mappings":";;AAAA,2CAAsD;AACtD,iCAA4C;AAE5C,MAAM,CAAC,OAAO,GAAG,CAAC,4BAAqB,EAAE,sCAA0B,CAAC,CAAA"}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../src/commands/deployment/cli.ts"],"names":[],"mappings":";;AAAA,2CAAsD;AACtD,uDAAiE;AACjE,iCAA4C;AAE5C,MAAM,CAAC,OAAO,GAAG,CAAC,4BAAqB,EAAE,sCAA0B,EAAE,iDAA+B,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Command } from 'clipanion';
2
+ export declare class DeploymentCorrelateImageCommand extends Command {
3
+ static paths: string[][];
4
+ static usage: import("clipanion").Usage;
5
+ private commitSha;
6
+ private repositoryUrl;
7
+ private image;
8
+ private fips;
9
+ private fipsIgnoreError;
10
+ private dryRun;
11
+ private logger;
12
+ private config;
13
+ execute(): Promise<number>;
14
+ private handleError;
15
+ }
@@ -0,0 +1,121 @@
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.DeploymentCorrelateImageCommand = void 0;
16
+ const axios_1 = require("axios");
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const clipanion_1 = require("clipanion");
19
+ const constants_1 = require("../../constants");
20
+ const env_1 = require("../../helpers/env");
21
+ const fips_1 = require("../../helpers/fips");
22
+ const logger_1 = require("../../helpers/logger");
23
+ const retry_1 = require("../../helpers/retry");
24
+ const utils_1 = require("../../helpers/utils");
25
+ class DeploymentCorrelateImageCommand extends clipanion_1.Command {
26
+ constructor() {
27
+ var _a, _b;
28
+ super(...arguments);
29
+ this.commitSha = clipanion_1.Option.String('--commit-sha');
30
+ this.repositoryUrl = clipanion_1.Option.String('--repository-url');
31
+ this.image = clipanion_1.Option.String('--image');
32
+ this.fips = clipanion_1.Option.Boolean('--fips', false);
33
+ this.fipsIgnoreError = clipanion_1.Option.Boolean('--fips-ignore-error', false);
34
+ this.dryRun = clipanion_1.Option.Boolean('--dry-run', false);
35
+ this.logger = new logger_1.Logger((s) => this.context.stdout.write(s), logger_1.LogLevel.INFO);
36
+ this.config = {
37
+ apiKey: process.env.DD_API_KEY,
38
+ appKey: process.env.DD_APP_KEY,
39
+ fips: (_a = (0, env_1.toBoolean)(process.env[constants_1.FIPS_ENV_VAR])) !== null && _a !== void 0 ? _a : false,
40
+ fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
41
+ };
42
+ }
43
+ execute() {
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.config.apiKey) {
47
+ this.logger.error(`Missing ${chalk_1.default.red.bold('DD_API_KEY')} in your environment.`);
48
+ return 1;
49
+ }
50
+ if (!this.config.appKey) {
51
+ this.logger.error(`Missing ${chalk_1.default.red.bold('DD_APP_KEY')} in your environment.`);
52
+ return 1;
53
+ }
54
+ if (!this.commitSha) {
55
+ this.logger.error('Missing commit SHA. It must be provided with --commit-sha');
56
+ return 1;
57
+ }
58
+ if (!this.repositoryUrl) {
59
+ this.logger.error('Missing repository URL. It must be provided with --repository-url');
60
+ return 1;
61
+ }
62
+ if (!this.image) {
63
+ this.logger.error('Missing image. It must be provided with --image');
64
+ return 1;
65
+ }
66
+ const site = process.env.DD_SITE || 'datadoghq.com';
67
+ const baseAPIURL = `https://${(0, utils_1.getApiHostForSite)(site)}`;
68
+ const request = (0, utils_1.getRequestBuilder)({ baseUrl: baseAPIURL, apiKey: this.config.apiKey, appKey: this.config.appKey });
69
+ const correlateEvent = {
70
+ type: 'ci_deployment_correlate_image',
71
+ attributes: {
72
+ commit_sha: this.commitSha,
73
+ repository_url: this.repositoryUrl,
74
+ image: this.image,
75
+ },
76
+ };
77
+ if (this.dryRun) {
78
+ this.logger.info(`[DRYRUN] Sending correlation event\n data: ` + JSON.stringify(correlateEvent, undefined, 2));
79
+ return 0;
80
+ }
81
+ const doRequest = () => request({
82
+ data: {
83
+ data: correlateEvent,
84
+ },
85
+ method: 'post',
86
+ url: '/api/v2/ci/deployments/correlate-image',
87
+ });
88
+ try {
89
+ yield (0, retry_1.retryRequest)(doRequest, {
90
+ maxTimeout: 30000,
91
+ minTimeout: 5000,
92
+ onRetry: (e, attempt) => {
93
+ this.logger.warn(`[attempt ${attempt}] Could not send correlation event. Retrying...: ${e.message}\n`);
94
+ },
95
+ retries: 5,
96
+ });
97
+ }
98
+ catch (error) {
99
+ this.handleError(error);
100
+ }
101
+ return 0;
102
+ });
103
+ }
104
+ handleError(error) {
105
+ var _a, _b;
106
+ this.context.stderr.write(`${chalk_1.default.red.bold('[ERROR]')} Could not send deployment correlation data: ${(0, axios_1.isAxiosError)(error)
107
+ ? JSON.stringify({
108
+ status: (_a = error.response) === null || _a === void 0 ? void 0 : _a.status,
109
+ response: (_b = error.response) === null || _b === void 0 ? void 0 : _b.data,
110
+ }, undefined, 2)
111
+ : error.message}\n`);
112
+ }
113
+ }
114
+ exports.DeploymentCorrelateImageCommand = DeploymentCorrelateImageCommand;
115
+ DeploymentCorrelateImageCommand.paths = [['deployment', 'correlate-image']];
116
+ DeploymentCorrelateImageCommand.usage = clipanion_1.Command.Usage({
117
+ category: 'CI Visibility',
118
+ description: 'Correlate images with their source commit.',
119
+ details: 'This command will correlate the image with a commit of the application repository.',
120
+ });
121
+ //# sourceMappingURL=correlate-image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correlate-image.js","sourceRoot":"","sources":["../../../src/commands/deployment/correlate-image.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iCAAkC;AAClC,kDAAyB;AACzB,yCAAyC;AAEzC,+CAAuE;AACvE,2CAA2C;AAC3C,6CAA6C;AAC7C,iDAAqD;AACrD,+CAAgD;AAChD,+CAAwE;AAExE,MAAa,+BAAgC,SAAQ,mBAAO;IAA5D;;;QASU,cAAS,GAAG,kBAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACzC,kBAAa,GAAG,kBAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACjD,UAAK,GAAG,kBAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;QAChC,SAAI,GAAG,kBAAM,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;QACtC,oBAAe,GAAG,kBAAM,CAAC,OAAO,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAA;QAC9D,WAAM,GAAG,kBAAM,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;QAE3C,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,U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IAAI,CAAC,WAAW,CAAC,KAAc,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;;AArHH,0EAsHC;AArHe,qCAAK,GAAG,CAAC,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC,AAAtC,CAAsC;AAE3C,qCAAK,GAAG,mBAAO,CAAC,KAAK,CAAC;IAClC,QAAQ,EAAE,eAAe;IACzB,WAAW,EAAE,4CAA4C;IACzD,OAAO,EAAE,oFAAoF;CAC9F,CAAC,AAJiB,CAIjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/datadog-ci",
3
- "version": "3.10.0",
3
+ "version": "3.11.0",
4
4
  "description": "Run datadog actions from the CI.",
5
5
  "repository": "https://github.com/DataDog/datadog-ci",
6
6
  "license": "Apache-2.0",