From c86bf9ca1d8aaecd89f6c9fea5aff36f430367ed Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Thu, 22 Oct 2020 10:22:04 +0200 Subject: [PATCH] fix(terraform): wrong internal provider lookup (#7520) --- lib/datasource/terraform-provider/index.ts | 6 ++++++ lib/manager/terraform/__snapshots__/extract.spec.ts.snap | 4 +++- lib/manager/terraform/providers.ts | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/datasource/terraform-provider/index.ts b/lib/datasource/terraform-provider/index.ts index 26fc1aa7ba..2dcbd4f62c 100644 --- a/lib/datasource/terraform-provider/index.ts +++ b/lib/datasource/terraform-provider/index.ts @@ -60,6 +60,7 @@ async function queryRegistry( const currentVersion = dep.releases.find((release) => { return res.version === release.version; }); + // istanbul ignore else if (currentVersion) { currentVersion.releaseTimestamp = res.published_at; } @@ -78,6 +79,11 @@ async function queryReleaseBackend( const backendURL = registryURL + `/index.json`; const res = (await http.getJson<TerraformProviderReleaseBackend>(backendURL)) .body; + + if (!res[backendLookUpName]) { + return null; + } + const dep: ReleaseResult = { name: repository, versions: {}, diff --git a/lib/manager/terraform/__snapshots__/extract.spec.ts.snap b/lib/manager/terraform/__snapshots__/extract.spec.ts.snap index 6bbb0d3545..cb6a5a9029 100644 --- a/lib/manager/terraform/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/terraform/__snapshots__/extract.spec.ts.snap @@ -296,7 +296,9 @@ Object { "depName": "docker", "depNameShort": "docker", "depType": "terraform", - "lookupName": "terraform-providers/docker", + "registryUrls": Array [ + "https://releases.hashicorp.com", + ], }, Object { "currentValue": "2.7.0", diff --git a/lib/manager/terraform/providers.ts b/lib/manager/terraform/providers.ts index 27d76dffcb..98f6918c18 100644 --- a/lib/manager/terraform/providers.ts +++ b/lib/manager/terraform/providers.ts @@ -55,7 +55,10 @@ export function analyzeTerraformProvider(dep: PackageDependency): void { if (is.nonEmptyString(dep.managerData.source)) { const source = sourceExtractionRegex.exec(dep.managerData.source); if (source) { - if (source.groups.hostname) { + // buildin providers https://github.com/terraform-providers + if (source.groups.namespace === 'terraform-providers') { + dep.registryUrls = [`https://releases.hashicorp.com`]; + } else if (source.groups.hostname) { dep.registryUrls = [`https://${source.groups.hostname}`]; dep.lookupName = `${source.groups.namespace}/${source.groups.type}`; } else { -- GitLab