diff --git a/lib/datasource/docker/__snapshots__/index.spec.ts.snap b/lib/datasource/docker/__snapshots__/index.spec.ts.snap index abba07ed47c4cb62255bb4951c494105f8fc9138..df87d8dce223cb477fde07c11a1d988e52ae7edc 100644 --- a/lib/datasource/docker/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/docker/__snapshots__/index.spec.ts.snap @@ -20,6 +20,9 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1 Array [ "https://index.docker.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -35,6 +38,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1 Object { "headers": Object { "authorization": "Basic c29tZS11c2VybmFtZTpzb21lLXBhc3N3b3Jk", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -51,6 +55,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1 Object { "headers": Object { "authorization": "Bearer some-token ", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -65,6 +70,9 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1 Array [ "https://index.docker.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -80,6 +88,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (explicit) 1 Object { "headers": Object { "accept": "application/vnd.docker.distribution.manifest.v2+json", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -143,6 +152,9 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (implicit) 1 Array [ "https://index.docker.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -158,6 +170,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (implicit) 1 Object { "headers": Object { "authorization": "Basic c29tZS11c2VybmFtZTpzb21lLXBhc3N3b3Jk", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -174,6 +187,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (implicit) 1 Object { "headers": Object { "authorization": "Bearer some-token ", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -188,6 +202,9 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (implicit) 1 Array [ "https://index.docker.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -203,6 +220,7 @@ exports[`api/docker getReleases adds library/ prefix for Docker Hub (implicit) 1 Object { "headers": Object { "accept": "application/vnd.docker.distribution.manifest.v2+json", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -266,6 +284,9 @@ exports[`api/docker getReleases adds no library/ prefix for other registries 1`] Array [ "https://k8s.gcr.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -281,6 +302,7 @@ exports[`api/docker getReleases adds no library/ prefix for other registries 1`] Object { "headers": Object { "authorization": "Basic c29tZS11c2VybmFtZTpzb21lLXBhc3N3b3Jk", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -297,6 +319,7 @@ exports[`api/docker getReleases adds no library/ prefix for other registries 1`] Object { "headers": Object { "authorization": "Bearer some-token ", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -311,6 +334,9 @@ exports[`api/docker getReleases adds no library/ prefix for other registries 1`] Array [ "https://k8s.gcr.io/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -326,6 +352,7 @@ exports[`api/docker getReleases adds no library/ prefix for other registries 1`] Object { "headers": Object { "accept": "application/vnd.docker.distribution.manifest.v2+json", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -389,6 +416,9 @@ exports[`api/docker getReleases uses custom registry in depName 1`] = ` Array [ "https://registry.company.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -402,7 +432,9 @@ exports[`api/docker getReleases uses custom registry in depName 1`] = ` Array [ "https://registry.company.com/v2/node/tags/list?n=10000", Object { - "headers": Object {}, + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -416,6 +448,9 @@ exports[`api/docker getReleases uses custom registry in depName 1`] = ` Array [ "https://registry.company.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -458,6 +493,9 @@ Array [ Array [ "https://registry.company.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -471,7 +509,9 @@ Array [ Array [ "https://registry.company.com/v2/node/tags/list?n=10000", Object { - "headers": Object {}, + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -485,7 +525,9 @@ Array [ Array [ "https://api.github.com/user/9287/repos?page=3&per_page=100", Object { - "headers": Object {}, + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -499,6 +541,9 @@ Array [ Array [ "https://registry.company.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -514,6 +559,7 @@ Array [ Object { "headers": Object { "accept": "application/vnd.docker.distribution.manifest.v2+json", + "user-agent": "https://github.com/renovatebot/renovate", }, "hooks": Object { "beforeRedirect": Array [ @@ -533,6 +579,9 @@ exports[`api/docker getReleases uses lower tag limit for ECR deps 1`] = ` Array [ "https://123456789.dkr.ecr.us-east-1.amazonaws.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -546,7 +595,9 @@ exports[`api/docker getReleases uses lower tag limit for ECR deps 1`] = ` Array [ "https://123456789.dkr.ecr.us-east-1.amazonaws.com/v2/node/tags/list?n=1000", Object { - "headers": Object {}, + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -560,6 +611,9 @@ exports[`api/docker getReleases uses lower tag limit for ECR deps 1`] = ` Array [ "https://123456789.dkr.ecr.us-east-1.amazonaws.com/v2/", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], diff --git a/lib/datasource/pypi/__snapshots__/index.spec.ts.snap b/lib/datasource/pypi/__snapshots__/index.spec.ts.snap index f29de15db3bc552e557ff64374033632e5f8230f..0acd2fbda85a2fda8868e129803673c3119fd527 100644 --- a/lib/datasource/pypi/__snapshots__/index.spec.ts.snap +++ b/lib/datasource/pypi/__snapshots__/index.spec.ts.snap @@ -227,6 +227,9 @@ Array [ Array [ "https://custom.pypi.net/foo/azure-cli-monitor/json", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -245,6 +248,9 @@ Array [ Array [ "https://my.pypi.python/pypi/azure-cli-monitor/json", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -263,6 +269,9 @@ Array [ Array [ "https://custom.pypi.net/foo/azure-cli-monitor/json", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], @@ -276,6 +285,9 @@ Array [ Array [ "https://second-index/foo/azure-cli-monitor/json", Object { + "headers": Object { + "user-agent": "https://github.com/renovatebot/renovate", + }, "hooks": Object { "beforeRedirect": Array [ [Function], diff --git a/lib/util/got/__snapshots__/index.spec.ts.snap b/lib/util/got/__snapshots__/index.spec.ts.snap index 0a67641f59438a3b027fa577b0e303b8f909e102..d3e89bf57f2d4b3f687c12bdd2e57d46881a397b 100644 --- a/lib/util/got/__snapshots__/index.spec.ts.snap +++ b/lib/util/got/__snapshots__/index.spec.ts.snap @@ -17,7 +17,7 @@ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -65,7 +65,7 @@ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -110,7 +110,7 @@ Object { "accept": "application/json", "accept-encoding": "gzip, deflate", "authorization": "Bearer XXX", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -155,7 +155,7 @@ Object { "accept": "application/json", "accept-encoding": "gzip, deflate", "authorization": "Bearer XXX", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -199,7 +199,7 @@ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -245,7 +245,7 @@ Object { "headers": Object { "accept": "application/json", "accept-encoding": "gzip, deflate", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -291,7 +291,7 @@ Object { "Private-token": "XXX", "accept": "application/json", "accept-encoding": "gzip, deflate", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], @@ -337,7 +337,7 @@ Object { "accept": "application/json", "accept-encoding": "gzip, deflate", "authorization": "token XXX", - "user-agent": "https://github.com/renovatebot/renovate", + "user-agent": "got/9.6.0 (https://github.com/sindresorhus/got)", }, "hooks": Object { "afterResponse": Array [], diff --git a/lib/util/got/index.ts b/lib/util/got/index.ts index 0a058615dbc425a4d49071f60bee44d0a0ebc1f7..66ee31e67442a9005ddf955e54fcc54506f37747 100644 --- a/lib/util/got/index.ts +++ b/lib/util/got/index.ts @@ -1,17 +1,16 @@ +import got from 'got'; import auth from './auth'; import cacheGet from './cache-get'; import hostRules from './host-rules'; -import renovateAgent from './renovate-agent'; import { mergeInstances } from './util'; export * from './common'; /* * This is the default got instance for Renovate. - * - Set the user agent to be Renovate * - Cache all GET requests for the lifetime of the repo * */ -export const api = mergeInstances(cacheGet, renovateAgent, hostRules, auth); +export const api = mergeInstances(got, cacheGet, hostRules, auth); export default api; diff --git a/lib/util/got/renovate-agent.ts b/lib/util/got/renovate-agent.ts deleted file mode 100644 index 5b2eea2bfc1c8500111cb7bf45447c5dce4a3768..0000000000000000000000000000000000000000 --- a/lib/util/got/renovate-agent.ts +++ /dev/null @@ -1,11 +0,0 @@ -import got from 'got'; - -// Sets the user agent to be Renovate - -export default got.extend({ - headers: { - 'user-agent': - process.env.RENOVATE_USER_AGENT || - 'https://github.com/renovatebot/renovate', - }, -}); diff --git a/lib/util/http/index.ts b/lib/util/http/index.ts index 01a1a0899279ef1dfec3faaba57b5171fc8cbbf6..5521261b9dfa6892f40ffd0179d8dbffc36f8a65 100644 --- a/lib/util/http/index.ts +++ b/lib/util/http/index.ts @@ -67,6 +67,12 @@ export class Http<GetOptions = HttpOptions, PostOptions = HttpPostOptions> { }, ], }; + combinedOptions.headers = { + ...combinedOptions.headers, + 'user-agent': + process.env.RENOVATE_USER_AGENT || + 'https://github.com/renovatebot/renovate', + }; const res = await got(resolvedUrl, combinedOptions); return { body: res.body, headers: res.headers }; }