Skip to content
Snippets Groups Projects
Unverified Commit 39f03b2b authored by Etienne's avatar Etienne Committed by GitHub
Browse files

fix(terraform): extract github repository name containing dots (#6154)

parent 0c6935f8
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,14 @@ module "bar" { ...@@ -6,6 +6,14 @@ module "bar" {
source = "github.com/hashicorp/example?ref=next" source = "github.com/hashicorp/example?ref=next"
} }
module "repo-with-dot" {
source = "github.com/hashicorp/example.2.3?ref=v1.0.0"
}
module "repo-with-dot-and-git-suffix" {
source = "github.com/hashicorp/example.2.3.git?ref=v1.0.0"
}
module "consul" { module "consul" {
source = "hashicorp/consul/aws" source = "hashicorp/consul/aws"
version = "0.1.0" version = "0.1.0"
......
...@@ -20,6 +20,22 @@ Object { ...@@ -20,6 +20,22 @@ Object {
"lookupName": "hashicorp/example", "lookupName": "hashicorp/example",
"skipReason": "unsupported-version", "skipReason": "unsupported-version",
}, },
Object {
"currentValue": "v1.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example.2.3",
"depNameShort": "hashicorp/example.2.3",
"depType": "github",
"lookupName": "hashicorp/example.2.3",
},
Object {
"currentValue": "v1.0.0",
"datasource": "github-tags",
"depName": "github.com/hashicorp/example.2.3",
"depNameShort": "hashicorp/example.2.3",
"depType": "github",
"lookupName": "hashicorp/example.2.3",
},
Object { Object {
"currentValue": "0.1.0", "currentValue": "0.1.0",
"datasource": "terraform-module", "datasource": "terraform-module",
......
...@@ -19,7 +19,7 @@ describe('lib/manager/terraform/extract', () => { ...@@ -19,7 +19,7 @@ describe('lib/manager/terraform/extract', () => {
it('extracts', () => { it('extracts', () => {
const res = extractPackageFile(tf1); const res = extractPackageFile(tf1);
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
expect(res.deps).toHaveLength(22); expect(res.deps).toHaveLength(24);
expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(6); expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(6);
}); });
it('returns null if only local deps', () => { it('returns null if only local deps', () => {
......
...@@ -85,7 +85,7 @@ export function extractPackageFile(content: string): PackageFile | null { ...@@ -85,7 +85,7 @@ export function extractPackageFile(content: string): PackageFile | null {
dep.managerData.terraformDependencyType === dep.managerData.terraformDependencyType ===
TerraformDependencyTypes.module TerraformDependencyTypes.module
) { ) {
const githubRefMatch = /github.com(\/|:)([^/]+\/[a-z0-9-]+).*\?ref=(.*)$/.exec( const githubRefMatch = /github.com(\/|:)([^/]+\/[a-z0-9-.]+).*\?ref=(.*)$/.exec(
dep.managerData.source dep.managerData.source
); );
// Regex would need to be updated to support ssh:// // Regex would need to be updated to support ssh://
...@@ -94,12 +94,13 @@ export function extractPackageFile(content: string): PackageFile | null { ...@@ -94,12 +94,13 @@ export function extractPackageFile(content: string): PackageFile | null {
); );
/* eslint-disable no-param-reassign */ /* eslint-disable no-param-reassign */
if (githubRefMatch) { if (githubRefMatch) {
const depNameShort = githubRefMatch[2].replace(/\.git$/, '');
dep.depType = 'github'; dep.depType = 'github';
dep.depName = 'github.com/' + githubRefMatch[2]; dep.depName = 'github.com/' + depNameShort;
dep.depNameShort = githubRefMatch[2]; dep.depNameShort = depNameShort;
dep.currentValue = githubRefMatch[3]; dep.currentValue = githubRefMatch[3];
dep.datasource = datasourceGithubTags.id; dep.datasource = datasourceGithubTags.id;
dep.lookupName = githubRefMatch[2]; dep.lookupName = depNameShort;
dep.managerData.lineNumber = dep.managerData.sourceLine; dep.managerData.lineNumber = dep.managerData.sourceLine;
if (!isVersion(dep.currentValue)) { if (!isVersion(dep.currentValue)) {
dep.skipReason = SkipReason.UnsupportedVersion; dep.skipReason = SkipReason.UnsupportedVersion;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment