serverless-plugin-datadog 3.4.0 → 3.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/README.md +31 -38
  2. package/dist/package.json +14 -4
  3. package/dist/src/env.d.ts +6 -3
  4. package/dist/src/env.d.ts.map +1 -1
  5. package/dist/src/env.js +25 -3
  6. package/dist/src/env.js.map +1 -1
  7. package/dist/src/forwarder.d.ts +1 -1
  8. package/dist/src/forwarder.d.ts.map +1 -1
  9. package/dist/src/git-metadata/interfaces.d.ts +10 -0
  10. package/dist/src/git-metadata/interfaces.d.ts.map +1 -0
  11. package/dist/src/git-metadata/interfaces.js +43 -0
  12. package/dist/src/git-metadata/interfaces.js.map +1 -0
  13. package/dist/src/git.d.ts +8 -0
  14. package/dist/src/git.d.ts.map +1 -0
  15. package/dist/src/git.js +115 -0
  16. package/dist/src/git.js.map +1 -0
  17. package/dist/src/helpers/apikey.d.ts +13 -0
  18. package/dist/src/helpers/apikey.d.ts.map +1 -0
  19. package/dist/src/helpers/apikey.js +74 -0
  20. package/dist/src/helpers/apikey.js.map +1 -0
  21. package/dist/src/helpers/errors.d.ts +3 -0
  22. package/dist/src/helpers/errors.d.ts.map +1 -0
  23. package/dist/src/helpers/errors.js +7 -0
  24. package/dist/src/helpers/errors.js.map +1 -0
  25. package/dist/src/helpers/interfaces.d.ts +20 -0
  26. package/dist/src/helpers/interfaces.d.ts.map +1 -0
  27. package/dist/src/helpers/interfaces.js +3 -0
  28. package/dist/src/helpers/interfaces.js.map +1 -0
  29. package/dist/src/helpers/retry.d.ts +3 -0
  30. package/dist/src/helpers/retry.d.ts.map +1 -0
  31. package/dist/src/helpers/retry.js +39 -0
  32. package/dist/src/helpers/retry.js.map +1 -0
  33. package/dist/src/helpers/tags.d.ts +29 -0
  34. package/dist/src/helpers/tags.d.ts.map +1 -0
  35. package/dist/src/helpers/tags.js +50 -0
  36. package/dist/src/helpers/tags.js.map +1 -0
  37. package/dist/src/helpers/upload.d.ts +45 -0
  38. package/dist/src/helpers/upload.d.ts.map +1 -0
  39. package/dist/src/helpers/upload.js +70 -0
  40. package/dist/src/helpers/upload.js.map +1 -0
  41. package/dist/src/helpers/utils.d.ts +31 -0
  42. package/dist/src/helpers/utils.d.ts.map +1 -0
  43. package/dist/src/helpers/utils.js +115 -0
  44. package/dist/src/helpers/utils.js.map +1 -0
  45. package/dist/src/index.d.ts +9 -1
  46. package/dist/src/index.d.ts.map +1 -1
  47. package/dist/src/index.js +57 -13
  48. package/dist/src/index.js.map +1 -1
  49. package/dist/src/layers-gov.json +8 -8
  50. package/dist/src/layers.json +84 -84
  51. package/dist/src/monitor-api-requests.d.ts +1 -1
  52. package/dist/src/monitor-api-requests.d.ts.map +1 -1
  53. package/dist/src/monitor-api-requests.js.map +1 -1
  54. package/dist/src/output.d.ts +1 -1
  55. package/dist/src/output.d.ts.map +1 -1
  56. package/dist/src/source-code-integration.d.ts +12 -0
  57. package/dist/src/source-code-integration.d.ts.map +1 -0
  58. package/dist/src/source-code-integration.js +76 -0
  59. package/dist/src/source-code-integration.js.map +1 -0
  60. package/dist/src/tracing.d.ts +1 -1
  61. package/dist/src/tracing.d.ts.map +1 -1
  62. package/package.json +14 -4
  63. package/dist/env.d.ts +0 -17
  64. package/dist/env.d.ts.map +0 -1
  65. package/dist/env.js +0 -63
  66. package/dist/env.js.map +0 -1
  67. package/dist/forwarder.d.ts +0 -14
  68. package/dist/forwarder.d.ts.map +0 -1
  69. package/dist/forwarder.js +0 -87
  70. package/dist/forwarder.js.map +0 -1
  71. package/dist/index.d.ts +0 -10
  72. package/dist/index.d.ts.map +0 -1
  73. package/dist/index.js +0 -161
  74. package/dist/index.js.map +0 -1
  75. package/dist/layer.d.ts +0 -26
  76. package/dist/layer.d.ts.map +0 -1
  77. package/dist/layer.js +0 -65
  78. package/dist/layer.js.map +0 -1
  79. package/dist/layers.json +0 -156
  80. package/dist/templates/node-es6-template.d.ts +0 -2
  81. package/dist/templates/node-es6-template.d.ts.map +0 -1
  82. package/dist/templates/node-es6-template.js +0 -25
  83. package/dist/templates/node-es6-template.js.map +0 -1
  84. package/dist/templates/node-js-template.d.ts +0 -2
  85. package/dist/templates/node-js-template.d.ts.map +0 -1
  86. package/dist/templates/node-js-template.js +0 -24
  87. package/dist/templates/node-js-template.js.map +0 -1
  88. package/dist/templates/node-ts-template.d.ts +0 -2
  89. package/dist/templates/node-ts-template.d.ts.map +0 -1
  90. package/dist/templates/node-ts-template.js +0 -26
  91. package/dist/templates/node-ts-template.js.map +0 -1
  92. package/dist/templates/python-template.d.ts +0 -2
  93. package/dist/templates/python-template.d.ts.map +0 -1
  94. package/dist/templates/python-template.js +0 -25
  95. package/dist/templates/python-template.js.map +0 -1
  96. package/dist/tracing.d.ts +0 -9
  97. package/dist/tracing.d.ts.map +0 -1
  98. package/dist/tracing.js +0 -36
  99. package/dist/tracing.js.map +0 -1
  100. package/dist/util.d.ts +0 -9
  101. package/dist/util.d.ts.map +0 -1
  102. package/dist/util.js +0 -72
  103. package/dist/util.js.map +0 -1
  104. package/dist/wrapper.d.ts +0 -11
  105. package/dist/wrapper.d.ts.map +0 -1
  106. package/dist/wrapper.js +0 -57
  107. package/dist/wrapper.js.map +0 -1
  108. package/dist/yarn.lock +0 -3703
package/README.md CHANGED
@@ -31,33 +31,33 @@ Each version of the plugin is published with a [specific set of versions of the
31
31
 
32
32
  To further configure your plugin, use the following custom parameters in your `serverless.yml`:
33
33
 
34
- | Parameter | Description |
35
- | --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
- | `flushMetricsToLogs` | Send custom metrics by using logs with the Datadog Forwarder Lambda function (recommended). Defaults to `true`. If you disable this parameter, it's required to set `apiKey` or if encrypted, `apiKMSKey` or `apiKeySecretArn`. `flushMetricsToLogs` is ignored when `addExtension` is true. |
37
- | `site` | Set which Datadog site to send data, this is only used when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. |
38
- | `apiKey` | Datadog API Key, only needed when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKey` will add the Datadog API key directly to your Lambda functions as an environment variable. For more information about getting a Datadog API key, see the [API key documentation][3]. |
39
- | `apiKeySecretArn` | The ARN of the secret storing the Datadog API key in AWS Secrets Manager. Use this parameter in place of `apiKey` when `flushMetricsToLogs` is `false` or `addExtension` is `true`. If set, remember to add the `secretsmanager:GetSecretValue` permission to the Lambda execution role. |
40
- | `apiKMSKey` | Datadog API Key encrypted using KMS. Use this parameter in place of `apiKey` when `flushMetricsToLogs` is `false` or `addExtension` is `true`, and you are using KMS encryption. Defining `apiKMSKey` will add the Datadog API Key directly to your Lambda functions as an environment variable. |
41
- | `captureLambdaPayload` | (Experimental) This optional setting configures Datadog ingestion for incoming and outgoing AWS Lambda payloads. Function request and response values are added as part of outgoing APM spans sent to Datadog, and require Datadog APM to be configured on your function. Obfuscation of fields in the Lambda payload is available via the `replace_tags` block within `apm_config` settings in [datadog.yaml.][12] Defaults to `false`. |
42
- | `monitorsApiKey` | Datadog API Key. Only needed when using plugin to create monitors for your functions and when `monitors` is defined. Separate from `apiKey` with your function, `monitorsApiKey` is only used to create monitors through the Datadog Monitors API. You may use the same API key for both `apiKey` and `monitorsApiKey`. |
43
- | `monitorsAppKey` | Datadog Application Key. Only needed when using plugin to create monitors for your function and when `monitors` is defined. |
44
- | `addLayers` | Whether to install the Datadog Lambda library as a layer. Defaults to `true`. Set to `false` when you plan to package the Datadog Lambda library to your function's deployment package on your own so that you can install a specific version of the Datadog Lambda library ([Python][4] or [Node.js][5]). |
45
- | `addExtension` | Whether to install the Datadog Lambda Extension as a layer. Defaults to `false`. When enabled, it's required to set the `apiKey`, `apiKMSKey`, or `apiKeySecretArn` parameter. Learn more about the [Datadog Lambda Extension Layer][8] in the documentation. **Note**: AWS only supports Lambda Extensions for [certain runtimes][9]. |
46
- | `logLevel` | The log level, set to `DEBUG` for extended logging. |
47
- | `enableXrayTracing` | Set `true` to enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`. |
48
- | `enableDDTracing` | Enable Datadog tracing on the Lambda function. Note: This applies only to integrations using the Datadog Extension. Defaults to `true`. |
49
- | `enableDDLogs` | Enable Datadog log collection for the Lambda function. Note: This setting has no effect on logs sent via the Datadog Forwarder. Defaults to `true`. |
50
- | `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Defaults to `true`. |
51
- | `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to Http-api log groups. Defaults to `true`. |
52
- | `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to Websocket log groups. Defaults to `true`. |
53
- | `forwarderArn` | Setting this parameter subscribes the given Datadog forwarder to the Lambda functions’ CloudWatch log groups. Required when `enableDDTracing` is set to `true` unless the subscription is otherwise applied. For example, if a Datadog Forwarder subscription is applied via Datadog's AWS Integration, then `forwarderArn` is not required. |
54
- | `integrationTesting` | Set `true` when running integration tests. This will bypass the validation of the Forwarder ARN and the addition of Datadog Monitor output links. Defaults to `false`. |
55
- | `enableTags` | When set, automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition. It does NOT override if a `service` or `env` tag already exists. Defaults to `true`. |
56
- | `injectLogContext` | When set, the lambda layer will automatically patch console.log with Datadog's tracing ids. Defaults to `true`. |
57
- | `exclude` | When set, this plugin will ignore all specified functions. Use this parameter if you have any functions that should not include Datadog functionality. Defaults to `[]`. |
58
- | `enabled` | When set to false, the Datadog plugin will stay inactive. Defaults to `true`. You can control this option using an environment variable, e.g. `enabled: ${strToBool(${env:DD_PLUGIN_ENABLED, true})}`, to activate/deactivate the plugin during deployment. Alternatively, you can also use the value passed in through `--stage` to control this option, [see example.](#disable-plugin-for-particular-environment) |
59
- | `monitors` | When defined, the Datadog plugin will configure monitors for the deployed function. You must also have `monitorsApiKey` and `monitorsAppKey` defined. To learn how to define monitors, see [To Enable and Configure a Recommended Serverless Monitor.](#to-enable-and-configure-a-recommended-serverless-monitor) |
60
- | `customHandler` | When set, the specified handler is set as the handler for all the functions. By deafult, the handler is set to `/opt/nodejs/node_modules/datadog-lambda-js/handler.handler` if `addLayers` is set to `true`, or `node_modules/datadog-lambda-js/dist/handler.handler` if `addLayers` is set to `false` |
34
+ | Parameter | Description |
35
+ | ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
36
+ | `flushMetricsToLogs` | Send custom metrics by using logs with the Datadog Forwarder Lambda function (recommended). Defaults to `true`. To use an encrypted key, set `apiKMSKey` or `apiKeySecretArn` in the configuration. `flushMetricsToLogs` is ignored when `addExtension` is true. |
37
+ | `site` | Set which Datadog site to send data to. This is only used when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Possible values are `datadoghq.com`, `datadoghq.eu`, `us3.datadoghq.com`, `us5.datadoghq.com`, and `ddog-gov.com`. The default is `datadoghq.com`. |
38
+ | `apiKey` | Datadog API key. Required when `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKey` adds the Datadog API key directly to your Lambda functions as an environment variable. For more information about getting a Datadog API key, see the [API key documentation][3]. Can also be set via the `DATADOG_API_KEY` environment variable. |
39
+ | `appKey` | Datadog app key. Only needed when the `monitors` field is defined. Can also be set via the `DATADOG_APP_KEY` environment variable. |
40
+ | `apiKeySecretArn` | An alternative to using the `apiKey` field. The ARN of the secret storing the Datadog API key in AWS Secrets Manager. Use this parameter if you're storing your secrets in AWS Secrets Manager, and when `flushMetricsToLogs` is `false` or `addExtension` is `true`. If set, remember to add the `secretsmanager:GetSecretValue` permission to the Lambda execution role. |
41
+ | `apiKMSKey` | An alternative to using the `apiKey` field. Datadog API key encrypted using KMS. Use this parameter if you're storing your secrets with KMS, and if `flushMetricsToLogs` is `false` or `addExtension` is `true`. Defining `apiKMSKey` adds the Datadog API Key directly to your Lambda functions as an environment variable. |
42
+ | `captureLambdaPayload` | (Experimental) This optional setting configures Datadog ingestion for incoming and outgoing AWS Lambda payloads. Function request and response values are added as part of outgoing APM spans sent to Datadog, and require Datadog APM to be configured on your function. You can obfuscate fields in the Lambda payload by using the `replace_tags` block within `apm_config` settings in [datadog.yaml.][12] Defaults to `false`. |
43
+ | `addLayers` | Whether to install the Datadog Lambda library as a layer. Defaults to `true`. Set to `false` when you plan to package the Datadog Lambda library to your function's deployment package on your own so that you can install a specific version of the Datadog Lambda library ([Python][4] or [Node.js][5]). |
44
+ | `addExtension` | Whether to install the Datadog Lambda Extension as a layer. Defaults to `false`. When enabled, you must set either the environment variable `DATADOG_API_KEY`, or the configuration values `apiKMSKey` or `apiKeySecretArn`. Learn more about the [Datadog Lambda Extension Layer][8] in the documentation. **Note**: AWS only supports Lambda Extensions for [certain runtimes][9]. |
45
+ | `logLevel` | The log level, set to `DEBUG` for extended logging. |
46
+ | `enableXrayTracing` | Set `true` to enable X-Ray tracing on the Lambda functions and API Gateway integrations. Defaults to `false`. |
47
+ | `enableDDTracing` | Enable Datadog tracing on the Lambda function. Note: This applies only to integrations using the Datadog Extension. Defaults to `true`. |
48
+ | `enableDDLogs` | Enable Datadog log collection for the Lambda function. Note: This setting has no effect on logs sent by the Datadog Forwarder. Defaults to `true`. |
49
+ | `enableSourceCodeIntegration` | Enable Datadog source code integration for the function. This feature links your Github repository information to the function in Datadog and allows you to view stack traces from Datadog directly in Github. For more information, see [Source Code Integration](https://docs.datadoghq.com/integrations/guide/source-code-integration). |
50
+ | `subscribeToApiGatewayLogs` | Enable automatic subscription of the Datadog Forwarder to API Gateway log groups. Defaults to `true`. |
51
+ | `subscribeToHttpApiLogs` | Enable automatic subscription of the Datadog Forwarder to HTTP API log groups. Defaults to `true`. |
52
+ | `subscribeToWebsocketLogs` | Enable automatic subscription of the Datadog Forwarder to WebSocket log groups. Defaults to `true`. |
53
+ | `forwarderArn` | Setting this parameter subscribes the given Datadog forwarder to the Lambda functions’ CloudWatch log groups. Required when `enableDDTracing` is set to `true` unless the subscription is otherwise applied. For example, if a Datadog Forwarder subscription is applied using Datadog's AWS Integration, then `forwarderArn` is not required. |
54
+ | `integrationTesting` | Set `true` when running integration tests. This bypasses the validation of the Forwarder ARN and the addition of Datadog Monitor output links. Defaults to `false`. |
55
+ | `enableTags` | When set, automatically tag the Lambda functions with the `service` and `env` tags using the `service` and `stage` values from the serverless application definition. It does NOT override if a `service` or `env` tag already exists. Defaults to `true`. |
56
+ | `injectLogContext` | When set, the Lambda layer automatically patches `console.log` with Datadog's tracing IDs. Defaults to `true`. |
57
+ | `exclude` | When set, this plugin ignores all specified functions. Use this parameter if you have any functions that should not include Datadog functionality. Defaults to `[]`. |
58
+ | `enabled` | When set to `false`, the Datadog plugin stays inactive. Defaults to `true`. You can control this option using an environment variable. For example, use `enabled: ${strToBool(${env:DD_PLUGIN_ENABLED, true})}` to activate/deactivate the plugin during deployment. Alternatively, you can also use the value passed in through `--stage` to control this option[see example](#disable-plugin-for-particular-environment). |
59
+ | `monitors` | When defined, the Datadog plugin will configure monitors for the deployed function. Requires setting `DATADOG_API_KEY` and `DATADOG_APP_KEY` in your environment. To learn how to define monitors, see [To Enable and Configure a Recommended Serverless Monitor](#to-enable-and-configure-a-recommended-serverless-monitor). |
60
+ | `customHandler` | When set, the specified handler is set as the handler for all the functions. By default, the handler is set to `/opt/nodejs/node_modules/datadog-lambda-js/handler.handler` if `addLayers` is set to `true`, or `node_modules/datadog-lambda-js/dist/handler.handler` if `addLayers` is set to `false`. |
61
61
 
62
62
  To use any of these parameters, add a `custom` > `datadog` section to your `serverless.yml` similar to this example:
63
63
 
@@ -65,11 +65,8 @@ To use any of these parameters, add a `custom` > `datadog` section to your `serv
65
65
  custom:
66
66
  datadog:
67
67
  flushMetricsToLogs: true
68
- apiKey: "{Datadog_API_Key}"
69
68
  apiKeySecretArn: "{Datadog_API_Key_Secret_ARN}"
70
69
  apiKMSKey: "{Encrypted_Datadog_API_Key}"
71
- monitorsApiKey: "{Datadog_API_Key}"
72
- monitorsAppKey: "{Datadog_Application_Key}"
73
70
  addLayers: true
74
71
  logLevel: "info"
75
72
  enableXrayTracing: false
@@ -85,6 +82,8 @@ custom:
85
82
 
86
83
  **Note**: If you use webpack, Datadog recommends using the prebuilt layers by setting `addLayers` to `true`, which is the default, and add `datadog-lambda-js` and `dd-trace` to the [externals][6] section of your webpack config.
87
84
 
85
+ **Note**: Many of the above configuration values require setting `DATADOG_API_KEY` in your environment. If you store these values in AWS Secrets Manager or AWS KMS, refer to the above options `apiKeySecretArn` and `apiKMSKey` to pull your Datadog API key from the correct location.
86
+
88
87
  ### TypeScript
89
88
 
90
89
  If you are using serverless-typescript, make sure that `serverless-datadog` is above the `serverless-typescript` entry in your `serverless.yml`. The plugin will automatically detect `.ts` files.
@@ -173,7 +172,7 @@ There are seven recommended monitors with default values pre-configured.
173
172
 
174
173
  #### To Enable and Configure a Recommended Serverless Monitor
175
174
 
176
- To create a recommended monitor, you must use its respective serverless monitor ID. Note that you must also set the `monitorApiKey` and `monitorAppKey`.
175
+ To create a recommended monitor, you must use its respective serverless monitor ID. Note that you must also set the `DATADOG_API_KEY` and `DATADOG_APP_KEY` in your environment.
177
176
 
178
177
  If you’d like to further configure the parameters for a recommended monitor, you can directly define the parameter values below the serverless monitor ID. Parameters not specified under a recommended monitor will use the default recommended value. The `query` parameter for recommended monitors cannot be directly modified and will default to using the `query` valued as defined above; however, you may change the threshold value in `query` by re-defining it within the `options` parameter. To delete a monitor, remove the monitor from the `serverless.yml` template. For further documentation on how to define monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
179
178
 
@@ -187,8 +186,6 @@ Define the appropriate serverless monitor ID without specifying any parameter va
187
186
  custom:
188
187
  datadog:
189
188
  addLayers: true
190
- monitorsApiKey: "{Datadog_API_Key}"
191
- monitorsAppKey: "{Datadog_APP_Key}"
192
189
  monitors:
193
190
  - high_error_rate:
194
191
  ```
@@ -199,8 +196,6 @@ custom:
199
196
  custom:
200
197
  datadog:
201
198
  addLayers: true
202
- monitorsApiKey: "{Datadog_API_Key}"
203
- monitorsAppKey: "{Datadog_APP_Key}"
204
199
  monitors:
205
200
  - high_error_rate:
206
201
  name: "High Error Rate with Modified Warning Threshold"
@@ -222,14 +217,12 @@ Removing the serverless monitor ID and its parameters will delete the monitor.
222
217
 
223
218
  #### To Enable and Configure a Custom Monitor
224
219
 
225
- To define a custom monitor, you must define a unique serverless monitor ID string in addition to passing in the API key and Application key. The `query` parameter is required but every other parameter is optional. Define a unique serverless monitor ID string and specify the necessary parameters below. For further documentation on monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
220
+ To define a custom monitor, you must define a unique serverless monitor ID string in addition to passing in the API key and Application key, `DATADOG_API_KEY` and `DATADOG_APP_KEY`, in your environment. The `query` parameter is required but every other parameter is optional. Define a unique serverless monitor ID string and specify the necessary parameters below. For further documentation on monitor parameters, see the [Datadog Monitors API](https://docs.datadoghq.com/api/latest/monitors/#create-a-monitor).
226
221
 
227
222
  ```yaml
228
223
  custom:
229
224
  datadog:
230
225
  addLayers: true
231
- monitorsApiKey: "{Datadog_API_Key}"
232
- monitorsAppKey: "{Datadog_APP_Key}"
233
226
  monitors:
234
227
  - custom_monitor_id:
235
228
  name: "Custom Monitor"
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "serverless-plugin-datadog",
3
- "version": "3.4.0",
3
+ "version": "3.5.3",
4
4
  "description": "Serverless plugin to automatically instrument python and node functions with datadog tracing",
5
5
  "main": "dist/src/index.js",
6
6
  "repository": "https://github.com/DataDog/serverless-plugin-datadog",
@@ -17,14 +17,15 @@
17
17
  "format": "prettier --write \"src/**\" \"README.md\""
18
18
  },
19
19
  "devDependencies": {
20
- "@types/jest": "^26.0.20",
20
+ "@types/async-retry": "^1.4.3",
21
+ "@types/jest": "^27.4.0",
21
22
  "@types/mock-fs": "4.13.0",
22
23
  "@types/node": "^14.14.20",
23
24
  "@types/node-fetch": "^2.5.10",
24
25
  "@types/serverless": "1.78.34",
25
26
  "jest": "^26.6.3",
27
+ "jest-environment-node": "^26.6.2",
26
28
  "mock-fs": "4.13.0",
27
- "nock": "^13.0.5",
28
29
  "prettier": "^2.2.1",
29
30
  "serverless": "2.63.0",
30
31
  "ts-jest": "^26.4.4",
@@ -51,11 +52,20 @@
51
52
  "\\.snap$",
52
53
  "<rootDir>/node_modules/"
53
54
  ],
55
+ "testEnvironment": "<rootDir>/testEnvironment.js",
56
+ "clearMocks": true,
54
57
  "collectCoverageFrom": [
55
58
  "src/**/*.ts"
56
59
  ]
57
60
  },
58
61
  "dependencies": {
59
- "node-fetch": "^2.6.1"
62
+ "async-retry": "^1.3.3",
63
+ "axios": "^0.25.0",
64
+ "chalk": "^3.0.0",
65
+ "form-data": "^3.0.0",
66
+ "node-fetch": "^2.6.1",
67
+ "proxy": "^1.0.2",
68
+ "proxy-agent": "^5.0.0",
69
+ "simple-git": "^2.48.0"
60
70
  }
61
71
  }
package/dist/src/env.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { FunctionInfo } from "./layer";
2
1
  import Service from "serverless/classes/Service";
2
+ import { FunctionInfo } from "./layer";
3
3
  export interface Configuration {
4
4
  enabled?: boolean;
5
5
  addLayers: boolean;
6
6
  apiKey?: string;
7
+ appKey?: string;
8
+ monitorsApiKey?: string;
9
+ monitorsAppKey?: string;
7
10
  apiKeySecretArn?: string;
8
11
  apiKMSKey?: string;
9
12
  captureLambdaPayload?: boolean;
10
- monitorsApiKey?: string;
11
- monitorsAppKey?: string;
12
13
  site: string;
13
14
  logLevel: string | undefined;
14
15
  flushMetricsToLogs: boolean;
@@ -21,6 +22,7 @@ export interface Configuration {
21
22
  integrationTesting?: boolean;
22
23
  enableTags: boolean;
23
24
  injectLogContext: boolean;
25
+ enableSourceCodeIntegration: boolean;
24
26
  exclude: string[];
25
27
  monitors?: {
26
28
  [id: string]: {
@@ -31,6 +33,7 @@ export interface Configuration {
31
33
  subscribeToExecutionLogs: boolean;
32
34
  customHandler?: string;
33
35
  }
36
+ export declare const ddTagsEnvVar = "DD_TAGS";
34
37
  export declare const defaultConfiguration: Configuration;
35
38
  export declare function setEnvConfiguration(config: Configuration, handlers: FunctionInfo[]): void;
36
39
  export declare function getConfig(service: Service): Configuration;
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAA8B,MAAM,SAAS,CAAC;AACnE,OAAO,OAAO,MAAM,4BAA4B,CAAC;AAEjD,MAAM,WAAW,aAAa;IAE5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,OAAO,CAAC;IAEnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAE/B,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,IAAI,EAAE,MAAM,CAAC;IAEb,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAE7B,kBAAkB,EAAE,OAAO,CAAC;IAE5B,iBAAiB,EAAE,OAAO,CAAC;IAE3B,eAAe,EAAE,OAAO,CAAC;IAEzB,YAAY,EAAE,OAAO,CAAC;IAEtB,YAAY,EAAE,OAAO,CAAC;IAGtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,OAAO,CAAC;IAG1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,EAA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Y,EAAE,OAAO,CAAC;IAGtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAInB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAI7B,UAAU,EAAE,OAAO,CAAC;IAEpB,gBAAgB,EAAE,OAAO,CAAC;IAG1B,2BAA2B,EAAE,OAAO,CAAC;IAGrC,OAAO,EAAE,MAAM,EAAE,CAAC;IAElB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,EAAE,MAAM,GAAG;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAA;KAAE,EAAE,CAAC;IAGtD,qBAAqB,EAAE,OAAO,CAAC;IAE/B,wBAAwB,EAAE,OAAO,CAAC;IAGlC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAaD,eAAO,MAAM,YAAY,YAAY,CAAC;AAEtC,eAAO,MAAM,oBAAoB,EAAE,aAiBlC,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,QAuDlF;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,aAAa,CA0BzD;AAED,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,QAgB3D;AAiBD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,WAehD"}
package/dist/src/env.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * Copyright 2021 Datadog, Inc.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = void 0;
10
+ exports.hasWebpackPlugin = exports.forceExcludeDepsFromWebpack = exports.getConfig = exports.setEnvConfiguration = exports.defaultConfiguration = exports.ddTagsEnvVar = void 0;
11
11
  const layer_1 = require("./layer");
12
12
  const webpackPluginName = "serverless-webpack";
13
13
  const apiKeyEnvVar = "DD_API_KEY";
@@ -20,6 +20,7 @@ const ddTracingEnabledEnvVar = "DD_TRACE_ENABLED";
20
20
  const logInjectionEnvVar = "DD_LOGS_INJECTION";
21
21
  const ddLogsEnabledEnvVar = "DD_SERVERLESS_LOGS_ENABLED";
22
22
  const ddCaptureLambdaPayloadEnvVar = "DD_CAPTURE_LAMBDA_PAYLOAD";
23
+ exports.ddTagsEnvVar = "DD_TAGS";
23
24
  exports.defaultConfiguration = {
24
25
  addLayers: true,
25
26
  flushMetricsToLogs: true,
@@ -30,6 +31,7 @@ exports.defaultConfiguration = {
30
31
  addExtension: false,
31
32
  enableTags: true,
32
33
  injectLogContext: true,
34
+ enableSourceCodeIntegration: true,
33
35
  exclude: [],
34
36
  integrationTesting: false,
35
37
  subscribeToAccessLogs: true,
@@ -42,6 +44,17 @@ function setEnvConfiguration(config, handlers) {
42
44
  var _a;
43
45
  (_a = handler.environment) !== null && _a !== void 0 ? _a : (handler.environment = {});
44
46
  const environment = handler.environment;
47
+ if (process.env.DATADOG_API_KEY !== undefined &&
48
+ environment[apiKeyEnvVar] === undefined &&
49
+ // Only set this from the environment if all other methods of authentication
50
+ // are not in use. This will set DATADOG_API_KEY on the lambda from the environment
51
+ // variable directly if they haven't set one of the below three options
52
+ // in the configuration.
53
+ config.apiKMSKey === undefined &&
54
+ config.apiKey === undefined &&
55
+ config.apiKeySecretArn === undefined) {
56
+ environment[apiKeyEnvVar] = process.env.DATADOG_API_KEY;
57
+ }
45
58
  if (config.apiKey !== undefined && environment[apiKeyEnvVar] === undefined) {
46
59
  environment[apiKeyEnvVar] = config.apiKey;
47
60
  }
@@ -52,7 +65,7 @@ function setEnvConfiguration(config, handlers) {
52
65
  const isNode = layer_1.runtimeLookup[handler.runtime] === layer_1.RuntimeType.NODE;
53
66
  const isSendingSynchronousMetrics = !config.addExtension && !config.flushMetricsToLogs;
54
67
  if (isSendingSynchronousMetrics && isNode) {
55
- throw new Error(`\`apiKeySecretArn\` is not supported for Node runtimes when using Synchronous Metrics. Use either \`apiKey\` or \`apiKmsKey\`.`);
68
+ throw new Error("`apiKeySecretArn` is not supported for Node runtimes when using Synchronous Metrics. Set DATADOG_API_KEY in your environment, or use `apiKmsKey` in the configuration.");
56
69
  }
57
70
  environment[apiKeySecretArnEnvVar] = config.apiKeySecretArn;
58
71
  }
@@ -81,6 +94,7 @@ function setEnvConfiguration(config, handlers) {
81
94
  }
82
95
  exports.setEnvConfiguration = setEnvConfiguration;
83
96
  function getConfig(service) {
97
+ var _a, _b, _c, _d, _e, _f;
84
98
  let custom = service.custom;
85
99
  if (custom === undefined) {
86
100
  custom = {};
@@ -89,7 +103,15 @@ function getConfig(service) {
89
103
  if (datadog === undefined) {
90
104
  datadog = {};
91
105
  }
92
- return Object.assign(Object.assign({}, exports.defaultConfiguration), datadog);
106
+ // These values are deprecated but will supersede everything if set
107
+ if ((_a = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _a === void 0 ? void 0 : _a.monitorsApiKey) {
108
+ datadog.apiKey = (_c = (_b = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _b === void 0 ? void 0 : _b.monitorsApiKey) !== null && _c !== void 0 ? _c : datadog.apiKey;
109
+ }
110
+ if ((_d = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _d === void 0 ? void 0 : _d.monitorsAppKey) {
111
+ datadog.appKey = (_f = (_e = custom === null || custom === void 0 ? void 0 : custom.datadog) === null || _e === void 0 ? void 0 : _e.monitorsAppKey) !== null && _f !== void 0 ? _f : datadog.appKey;
112
+ }
113
+ const config = Object.assign(Object.assign({}, exports.defaultConfiguration), datadog);
114
+ return config;
93
115
  }
94
116
  exports.getConfig = getConfig;
95
117
  function forceExcludeDepsFromWebpack(service) {
@@ -1 +1 @@
1
- {"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/env.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,mCAAmE;AA8DnE,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AAC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AG,CAAC,IAAI,CAAC,CAAC;QACrB,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,EAAE;YACvC,IAAI,GAAG,EAAE,CAAC;YACV,GAAG,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;SAClB;QACD,IAAI,IAAI,KAAK,KAAK,EAAE;YAClB,OAAO;SACR;QACD,GAAG,GAAG,IAAI,CAAC;KACZ;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,gBAAgB,CAAC,OAAgB;IAC/C,MAAM,OAAO,GAA0B,OAAe,CAAC,OAAO,CAAC;IAC/D,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,KAAK,CAAC;KACd;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,gCAAgC;QAChC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,SAAS,CAAC;KAC7E;IACD,qCAAqC;IACrC,MAAM,OAAO,GAA0B,OAAe,CAAC,OAAO,CAAC,OAAO,CAAC;IACvE,IAAI,OAAO,KAAK,SAAS,EAAE;QACzB,OAAO,KAAK,CAAC;KACd;IACD,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,iBAAiB,CAAC,KAAK,SAAS,CAAC;AAC9E,CAAC;AAfD,4CAeC"}
@@ -1,5 +1,5 @@
1
- import { FunctionInfo } from "layer";
2
1
  import Service from "serverless/classes/Service";
2
+ import { FunctionInfo } from "./layer";
3
3
  import Aws = require("serverless/plugins/aws/provider/awsProvider");
4
4
  interface ForwarderConfigs {
5
5
  AddExtension: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"forwarder.d.ts","sourceRoot":"","sources":["../../src/forwarder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,OAAO,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GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,UAAU,CAuBxD"}
@@ -0,0 +1,10 @@
1
+ import { MultipartPayload } from "../helpers/upload";
2
+ export declare class CommitInfo {
3
+ hash: string;
4
+ remote: string;
5
+ trackedFiles: string[];
6
+ constructor(hash: string, remote: string, trackedFiles: string[]);
7
+ asMultipartPayload(cliVersion: string): MultipartPayload;
8
+ private repositoryPayload;
9
+ }
10
+ //# sourceMappingURL=interfaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/git-metadata/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,qBAAa,UAAU;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,EAAE,CAAC;gBAElB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAMzD,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB;IAqB/D,OAAO,CAAC,iBAAiB,CAWpB;CACN"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommitInfo = void 0;
4
+ class CommitInfo {
5
+ constructor(hash, remote, trackedFiles) {
6
+ this.repositoryPayload = () => JSON.stringify({
7
+ data: [
8
+ {
9
+ files: this.trackedFiles,
10
+ hash: this.hash,
11
+ repository_url: this.remote,
12
+ },
13
+ ],
14
+ // Make sure to update the version if the format of the JSON payloads changes in any way.
15
+ version: 1,
16
+ });
17
+ this.hash = hash;
18
+ this.remote = remote;
19
+ this.trackedFiles = trackedFiles;
20
+ }
21
+ asMultipartPayload(cliVersion) {
22
+ return {
23
+ content: new Map([
24
+ ["cli_version", { value: cliVersion }],
25
+ ["type", { value: "repository" }],
26
+ [
27
+ "repository",
28
+ {
29
+ options: {
30
+ contentType: "application/json",
31
+ filename: "repository",
32
+ },
33
+ value: this.repositoryPayload(),
34
+ },
35
+ ],
36
+ ["git_repository_url", { value: this.remote }],
37
+ ["git_commit_sha", { value: this.hash }],
38
+ ]),
39
+ };
40
+ }
41
+ }
42
+ exports.CommitInfo = CommitInfo;
43
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/git-metadata/interfaces.ts"],"names":[],"mappings":";;;AAEA,MAAa,UAAU;IAKrB,YAAY,IAAY,EAAE,MAAc,EAAE,YAAsB;QA2BxD,sBAAiB,GAAG,GAAW,EAAE,CACvC,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE;gBACJ;oBACE,KAAK,EAAE,IAAI,CAAC,YAAY;oBACxB,IAAI,EAAE,IAAI,CAAC,IAAI;oBACf,cAAc,EAAE,IAAI,CAAC,MAAM;iBAC5B;aACF;YACD,yFAAyF;YACzF,OAAO,EAAE,CAAC;SACX,CAAC,CAAC;QArCH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAEM,kBAAkB,CAAC,UAAkB;QAC1C,OAAO;YACL,OAAO,EAAE,IAAI,GAAG,CAAC;gBACf,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC;gBACtC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC;gBACjC;oBACE,YAAY;oBACZ;wBACE,OAAO,EAAE;4BACP,WAAW,EAAE,kBAAkB;4BAC/B,QAAQ,EAAE,YAAY;yBACvB;wBACD,KAAK,EAAE,IAAI,CAAC,iBAAiB,EAAE;qBAChC;iBACF;gBACD,CAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;gBAC9C,CAAC,gBAAgB,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;aACzC,CAAC;SACH,CAAC;IACJ,CAAC;CAcF;AA5CD,gCA4CC"}
@@ -0,0 +1,8 @@
1
+ import * as simpleGit from "simple-git";
2
+ import { CommitInfo } from "./git-metadata/interfaces";
3
+ export declare const newSimpleGit: () => Promise<simpleGit.SimpleGit | undefined>;
4
+ export declare const gitRemote: (git: simpleGit.SimpleGit) => Promise<string>;
5
+ export declare const stripCredentials: (remote: string) => string;
6
+ export declare const gitTrackedFiles: (git: simpleGit.SimpleGit) => Promise<string[]>;
7
+ export declare const getCommitInfo: (git: simpleGit.SimpleGit, repositoryURL?: string | undefined) => Promise<CommitInfo | undefined>;
8
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAGvD,eAAO,MAAM,YAAY,QAAa,QAAQ,UAAU,SAAS,GAAG,SAAS,CAiB5E,CAAC;AAGF,eAAO,MAAM,SAAS,QAAe,UAAU,SAAS,KAAG,QAAQ,MAAM,CAexE,CAAC;AAGF,eAAO,MAAM,gBAAgB,WAAY,MAAM,WAU9C,CAAC;AAMF,eAAO,MAAM,eAAe,QAAe,UAAU,SAAS,KAAG,QAAQ,MAAM,EAAE,CAIhF,CAAC;AAGF,eAAO,MAAM,aAAa,QACnB,UAAU,SAAS,yCAEvB,QAAQ,UAAU,GAAG,SAAS,CAmBhC,CAAC"}
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
+ return new (P || (P = Promise))(function (resolve, reject) {
24
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
28
+ });
29
+ };
30
+ Object.defineProperty(exports, "__esModule", { value: true });
31
+ exports.getCommitInfo = exports.gitTrackedFiles = exports.stripCredentials = exports.gitRemote = exports.newSimpleGit = void 0;
32
+ const simpleGit = __importStar(require("simple-git"));
33
+ const url_1 = require("url");
34
+ const interfaces_1 = require("./git-metadata/interfaces");
35
+ // Returns a configured SimpleGit.
36
+ const newSimpleGit = () => __awaiter(void 0, void 0, void 0, function* () {
37
+ const options = {
38
+ baseDir: process.cwd(),
39
+ binary: "git",
40
+ maxConcurrentProcesses: 1,
41
+ };
42
+ try {
43
+ // Attempt to set the baseDir to the root of the repository so the 'git ls-files' command
44
+ // returns the tracked files paths relative to the root of the repository.
45
+ const git = simpleGit.gitP(options);
46
+ const root = yield git.revparse("--show-toplevel");
47
+ options.baseDir = root;
48
+ }
49
+ catch (_a) {
50
+ return undefined;
51
+ }
52
+ return simpleGit.gitP(options);
53
+ });
54
+ exports.newSimpleGit = newSimpleGit;
55
+ // Returns the remote of the current repository.
56
+ const gitRemote = (git) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const remotes = yield git.getRemotes(true);
58
+ if (remotes.length === 0) {
59
+ throw new Error("No git remotes available");
60
+ }
61
+ for (const remote of remotes) {
62
+ // We're trying to pick the remote called with the default git name 'origin'.
63
+ if (remote.name === "origin") {
64
+ return (0, exports.stripCredentials)(remote.refs.push);
65
+ }
66
+ }
67
+ // Falling back to picking the first remote in the list if 'origin' is not found.
68
+ return (0, exports.stripCredentials)(remotes[0].refs.push);
69
+ });
70
+ exports.gitRemote = gitRemote;
71
+ // StripCredentials removes credentials from a remote HTTP url.
72
+ const stripCredentials = (remote) => {
73
+ try {
74
+ const url = new url_1.URL(remote);
75
+ url.username = "";
76
+ url.password = "";
77
+ return url.toString();
78
+ }
79
+ catch (_a) {
80
+ return remote;
81
+ }
82
+ };
83
+ exports.stripCredentials = stripCredentials;
84
+ // Returns the hash of the current repository.
85
+ const gitHash = (git) => __awaiter(void 0, void 0, void 0, function* () { return git.revparse("HEAD"); });
86
+ // Returns the tracked files of the current repository.
87
+ const gitTrackedFiles = (git) => __awaiter(void 0, void 0, void 0, function* () {
88
+ const files = yield git.raw("ls-files");
89
+ return files.split(/\r\n|\r|\n/).filter((s) => s !== "");
90
+ });
91
+ exports.gitTrackedFiles = gitTrackedFiles;
92
+ // Returns the current hash, remote URL and tracked files paths.
93
+ const getCommitInfo = (git, repositoryURL) => __awaiter(void 0, void 0, void 0, function* () {
94
+ // Invoke git commands to retrieve the remote, hash and tracked files.
95
+ // We're using Promise.all instead of Promive.allSettled since we want to fail early if
96
+ // any of the promises fails.
97
+ let remote;
98
+ let hash;
99
+ let trackedFiles;
100
+ try {
101
+ if (repositoryURL) {
102
+ [hash, trackedFiles] = yield Promise.all([gitHash(git), (0, exports.gitTrackedFiles)(git)]);
103
+ remote = repositoryURL;
104
+ }
105
+ else {
106
+ [remote, hash, trackedFiles] = yield Promise.all([(0, exports.gitRemote)(git), gitHash(git), (0, exports.gitTrackedFiles)(git)]);
107
+ }
108
+ }
109
+ catch (e) {
110
+ throw e;
111
+ }
112
+ return new interfaces_1.CommitInfo(hash, remote, trackedFiles);
113
+ });
114
+ exports.getCommitInfo = getCommitInfo;
115
+ //# sourceMappingURL=git.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAAwC;AACxC,6BAA0B;AAC1B,0DAAuD;AAEvD,kCAAkC;AAC3B,MAAM,YAAY,GAAG,GAAmD,EAAE;IAC/E,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE;QACtB,MAAM,EAAE,KAAK;QACb,sBAAsB,EAAE,CAAC;KAC1B,CAAC;IACF,IAAI;QACF,yFAAyF;QACzF,0EAA0E;QAC1E,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpC,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QACnD,OAAO,CAAC,OAAO,GAAG,IAAI,CAAC;KACxB;IAAC,WAAM;QACN,OAAO,SAAS,CAAC;KAClB;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC,CAAA,CAAC;AAjBW,QAAA,YAAY,gBAiBvB;AAEF,gDAAgD;AACzC,MAAM,SAAS,GAAG,CAAO,GAAwB,EAAmB,EAAE;IAC3E,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3C,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;QACxB,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IAED,KAAK,MAAM,MAAM,IAAI,OAAO,E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F,6BAA6B;IAC7B,IAAI,MAAc,CAAC;IACnB,IAAI,IAAY,CAAC;IACjB,IAAI,YAAsB,CAAC;IAC3B,IAAI;QACF,IAAI,aAAa,EAAE;YACjB,CAAC,IAAI,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC/E,MAAM,GAAG,aAAa,CAAC;SACxB;aAAM;YACL,CAAC,MAAM,EAAE,IAAI,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAA,iBAAS,EAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,IAAA,uBAAe,EAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SACxG;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,CAAC;KACT;IAED,OAAO,IAAI,uBAAU,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,CAAC;AACpD,CAAC,CAAA,CAAC;AAtBW,QAAA,aAAa,iBAsBxB"}
@@ -0,0 +1,13 @@
1
+ import { AxiosError } from "axios";
2
+ /** ApiKeyValidator is an helper interface to interpret Datadog error responses and possibly check the
3
+ * validity of the api key.
4
+ */
5
+ export interface ApiKeyValidator {
6
+ verifyApiKey(error: AxiosError): Promise<void>;
7
+ }
8
+ export interface ApiKeyValidatorParams {
9
+ apiKey: string;
10
+ datadogSite: string;
11
+ }
12
+ export declare const newApiKeyValidator: (params: ApiKeyValidatorParams) => ApiKeyValidator;
13
+ //# sourceMappingURL=apikey.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apikey.d.ts","sourceRoot":"","sources":["../../../src/helpers/apikey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAoB,MAAM,OAAO,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChD;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,WAAY,qBAAqB,KAAG,eACL,CAAC"}