Skip to content

Commit

Permalink
fix(terraform): wrong internal provider lookup (#7520)
Browse files Browse the repository at this point in the history
  • Loading branch information
viceice committed Oct 22, 2020
1 parent 6056567 commit c86bf9c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/datasource/terraform-provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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: {},
Expand Down
4 changes: 3 additions & 1 deletion lib/manager/terraform/__snapshots__/extract.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion lib/manager/terraform/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c86bf9c

Please sign in to comment.