Skip to content

Commit

Permalink
fix(terraform-provider): make git:: prefix optional
Browse files Browse the repository at this point in the history
  • Loading branch information
secustor committed Jun 28, 2020
1 parent 0af36ae commit 914ac1d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 8 additions & 1 deletion lib/manager/terraform/__snapshots__/extract.spec.ts.snap
Expand Up @@ -150,7 +150,14 @@ Object {
"depType": "terraform",
"skipReason": "unsupported-version",
},
Object {},
Object {
"currentValue": "v1.0.0",
"datasource": "git-tags",
"depName": "bitbucket.com/hashicorp/example",
"depNameShort": "hashicorp/example",
"depType": "gitTags",
"lookupName": "https://bitbucket.com/hashicorp/example",
},
Object {
"currentValue": "v1.0.0",
"datasource": "git-tags",
Expand Down
10 changes: 4 additions & 6 deletions lib/manager/terraform/extract.ts
Expand Up @@ -45,6 +45,8 @@ function checkFileContainsDependency(
const dependencyBlockExtractionRegex = /^\s*(?<type>module|provider|required_providers)\s+("(?<lookupName>[^"]+)"\s+)?{\s*$/;
const contentCheckList = ['module "', 'provider "', 'required_providers '];
const keyValueExtractionRegex = /^\s*(?<key>[^\s]+)\s+=\s+"(?<value>[^"]+)"\s*$/; // extracts `exampleKey = exampleValue`
const githubRefMatchRegex = /github.com(\/|:)([^/]+\/[a-z0-9-.]+).*\?ref=(.*)$/;
const gitTagsRefMatchRegex = /(?:git::)?((?:http|https|ssh):\/\/(?:.*@)?(.*.*\/(.*\/.*)))\?ref=(.*)$/;

export function extractPackageFile(content: string): PackageFile | null {
logger.trace({ content }, 'terraform.extractPackageFile()');
Expand Down Expand Up @@ -120,12 +122,8 @@ export function extractPackageFile(content: string): PackageFile | null {
dep.managerData.terraformDependencyType ===
TerraformDependencyTypes.module
) {
const githubRefMatch = /github.com(\/|:)([^/]+\/[a-z0-9-.]+).*\?ref=(.*)$/.exec(
dep.managerData.source
);
const gitTagsRefMatch = /git::((?:http|https|ssh):\/\/(?:.*@)?(.*.*\/(.*\/.*)))\?ref=(.*)$/.exec(
dep.managerData.source
);
const githubRefMatch = githubRefMatchRegex.exec(dep.managerData.source);
const gitTagsRefMatch = gitTagsRefMatchRegex.exec(dep.managerData.source);
/* eslint-disable no-param-reassign */
if (githubRefMatch) {
const depNameShort = githubRefMatch[2].replace(/\.git$/, '');
Expand Down

0 comments on commit 914ac1d

Please sign in to comment.