You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: use GITHUB_TOKEN if available in Serverless-Init .NET install script (#748)
Currently the .NET install script for Serverless-Init makes
unauthenticated requests to the Github API, sometimes resulting in rate
limiting. This PR adds a `GITHUB_TOKEN` to be passed as a [Docker
secret](https://docs.docker.com/build/building/secrets/) to the .NET
install script to allow for an increased rate limit. If no
`GITHUB_TOKEN` is passed then requests will be unauthenticated as they
were before this change.
## Motivation
#734
## Additional Notes
- Check if a `GITHUB_TOKEN` environment variable is set. If it is, pass
it in the `Authorization` header with `Bearer`
- Add a `status_code` attribute to the response json and print it for
troubleshooting
- Use `jq` to parse the response json
* Note that control characters needed to be stripped from the Github
responses in order to be successfully parsed
- If the tracer version is not parsed from the response json, presumably
due to rate limiting or some other issue on Github's end, exit the
script
Github token provided -> success
```
#16 6.759 Github token provided
#16 7.243 Status code of version request: 200
#16 7.291 Downloading version 3.21.0 of the .NET tracer into /tmp/datadog-dotnet-apm.tar.gz
#16 7.291 Github token provided
#16 10.08 Status code of download request: 200
```
No Github token provided -> success
```
#16 7.664 Github token not provided
#16 7.967 Status code of version request: 200
#16 8.018 Downloading version 3.21.0 of the .NET tracer into /tmp/datadog-dotnet-apm.tar.gz
#16 8.019 Github token not provided
#16 11.10 Status code of download request: 200
```
No Github token provided -> rate limited
```
6.518 Github token not provided
6.780 Status code of version request: 403
6.828 Error: Could not determine the tracer version. Exiting.
```
### Usage
- Pass value in `GITHUB_TOKEN` environment variable to the Docker secret
`github-token`.
```
docker build -t <image> --secret id=github-token,env=GITHUB_TOKEN .
```
- In the Dockerfile, read the value of the `github-token` secret into
the `GITHUB_TOKEN` environment variable so it can be passed in the
authentication header of the Github API request.
```
RUN --mount=type=secret,id=github-token,env=GITHUB_TOKEN \
chmod +x /app/dotnet.sh && /app/dotnet.sh
```
Relevant documentation to update following this change:
-
https://docs.datadoghq.com/serverless/guide/gcr_serverless_init/?tab=dotnet
-
https://docs.datadoghq.com/serverless/guide/aca_serverless_init/?tab=dotnet
-
https://docs.datadoghq.com/serverless/guide/azure_app_service_linux_containers_serverless_init/?tab=dotnet
0 commit comments