Skip to content

Commit

Permalink
feat(internal): migrate to got v11 (#6725)
Browse files Browse the repository at this point in the history
Co-authored-by: Jamie Magee <JamieMagee@users.noreply.github.com>
Co-authored-by: Rhys Arkins <rhys@arkins.net>
  • Loading branch information
3 people authored Jul 22, 2020
1 parent ae43b51 commit 5815f75
Show file tree
Hide file tree
Showing 21 changed files with 506 additions and 407 deletions.
12 changes: 6 additions & 6 deletions lib/datasource/orb/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down Expand Up @@ -153,7 +153,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down Expand Up @@ -185,7 +185,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down Expand Up @@ -217,7 +217,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down Expand Up @@ -249,7 +249,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down Expand Up @@ -281,7 +281,7 @@ Array [
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"content-length": 128,
"content-length": "128",
"content-type": "application/json",
"host": "circleci.com",
"user-agent": "https://github.com/renovatebot/renovate",
Expand Down
4 changes: 2 additions & 2 deletions lib/datasource/packagist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getHostOpts(url: string): HttpOptions {
url,
});
if (username && password) {
opts.auth = `${username}:${password}`;
Object.assign(opts, { username, password });
}
return opts;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ async function getPackagistFile(
const { key, sha256 } = file;
const fileName = key.replace('%hash%', sha256);
const opts = getHostOpts(regUrl);
if (opts.auth || (opts.headers && opts.headers.authorization)) {
if (opts.password || opts.headers?.authorization) {
return (await http.getJson<PackagistFile>(regUrl + '/' + fileName, opts))
.body;
}
Expand Down
10 changes: 4 additions & 6 deletions lib/datasource/pod/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,15 @@ function releasesGithubUrl(
function handleError(lookupName: string, err: HttpError): void {
const errorData = { lookupName, err };

if (
err.statusCode === 429 ||
(err.statusCode >= 500 && err.statusCode < 600)
) {
const statusCode = err.response?.statusCode;
if (statusCode === 429 || (statusCode >= 500 && statusCode < 600)) {
logger.warn({ lookupName, err }, `CocoaPods registry failure`);
throw new ExternalHostError(err);
}

if (err.statusCode === 401) {
if (statusCode === 401) {
logger.debug(errorData, 'Authorization error');
} else if (err.statusCode === 404) {
} else if (statusCode === 404) {
logger.debug(errorData, 'Package lookup error');
} else {
logger.warn(errorData, 'CocoaPods lookup failure: Unknown error');
Expand Down
50 changes: 25 additions & 25 deletions lib/datasource/terraform-module/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,31 @@ Array [
`;

exports[`datasource/terraform-module getReleases processes real data on changed subpath 1`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"host": "terraform.foo.bar",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://terraform.foo.bar/.well-known/terraform.json",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"host": "terraform.foo.bar",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://terraform.foo.bar/api/registry/v1/modules/hashicorp/consul/aws",
},
]
`;

exports[`datasource/terraform-module getReleases processes real data on changed subpath 2`] = `
Object {
"name": "hashicorp/consul/aws",
"releases": Array [
Expand Down Expand Up @@ -184,31 +209,6 @@ Object {
}
`;

exports[`datasource/terraform-module getReleases processes real data on changed subpath 2`] = `
Array [
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"host": "terraform.foo.bar",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://terraform.foo.bar/.well-known/terraform.json",
},
Object {
"headers": Object {
"accept": "application/json",
"accept-encoding": "gzip, deflate",
"host": "terraform.foo.bar",
"user-agent": "https://github.com/renovatebot/renovate",
},
"method": "GET",
"url": "https://terraform.foo.bar/api/registry/v1/modules/hashicorp/consul/aws",
},
]
`;

exports[`datasource/terraform-module getReleases processes with registry in name 1`] = `
Object {
"homepage": "https://registry.terraform.io/modules/hashicorp/consul/aws",
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/terraform-module/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ describe('datasource/terraform-module', () => {
registryUrls: ['https://terraform.foo.bar'],
depName: 'hashicorp/consul/aws',
});
expect(httpMock.getTrace()).toMatchSnapshot();
expect(res).toMatchSnapshot();
expect(res).not.toBeNull();
expect(httpMock.getTrace()).toMatchSnapshot();
});
});
});
Loading

0 comments on commit 5815f75

Please sign in to comment.