Skip to content

Commit

Permalink
fix(manager/terragrunt): Update terragrunt packageName (#33810)
Browse files Browse the repository at this point in the history
Co-authored-by: Rhys Arkins <[email protected]>
  • Loading branch information
mblum14 and rarkins authored Feb 3, 2025
1 parent d0916b1 commit 6f862cc
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/modules/manager/terragrunt/__fixtures__/3.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ terraform {
source = "git::ssh://[email protected]/hashicorp/example?ref=v1.0.3&depth=1"
}

# gittags_ssh_subdir
terraform {
source = "git::ssh://[email protected]/hashicorp/example//subdir/test?ref=v1.0.4&depth=1"
}

# invalid, ignored by test since it does not have source on the next line
terraform {
}
Expand Down
9 changes: 8 additions & 1 deletion lib/modules/manager/terragrunt/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,13 @@ describe('modules/manager/terragrunt/extract', () => {
depType: 'gitTags',
packageName: 'ssh://[email protected]/hashicorp/example',
},
{
currentValue: 'v1.0.4',
datasource: 'git-tags',
depName: 'mygit.com/hashicorp/example',
depType: 'gitTags',
packageName: 'ssh://[email protected]/hashicorp/example',
},
{
skipReason: 'no-source',
},
Expand Down Expand Up @@ -466,7 +473,7 @@ describe('modules/manager/terragrunt/extract', () => {
},
],
});
expect(res?.deps).toHaveLength(35);
expect(res?.deps).toHaveLength(36);
expect(res?.deps.filter((dep) => dep.skipReason)).toHaveLength(4);
});

Expand Down
5 changes: 3 additions & 2 deletions lib/modules/manager/terragrunt/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function analyseTerragruntModule(
dep.datasource = GithubTagsDatasource.id;
} else if (gitTagsRefMatch?.groups) {
const { url, tag } = gitTagsRefMatch.groups;
const { hostname, host, origin, pathname, protocol } = new URL(url);
const { hostname, host, pathname, protocol } = new URL(url);
const containsSubDirectory = pathname.includes('//');
if (containsSubDirectory) {
logger.debug('Terragrunt module contains subdirectory');
Expand All @@ -87,7 +87,8 @@ export function analyseTerragruntModule(
dep.datasource = detectGitTagDatasource(url);
if (dep.datasource === GitTagsDatasource.id) {
if (containsSubDirectory) {
dep.packageName = `${origin}${pathname.split('//')[0]}`;
const tempLookupName = url.split('//');
dep.packageName = tempLookupName[0] + '//' + tempLookupName[1];
} else {
dep.packageName = url;
}
Expand Down

0 comments on commit 6f862cc

Please sign in to comment.