Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(manager/terragrunt): Update terragrunt packageName #33810

Merged
merged 8 commits into from
Feb 3, 2025
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://git@mygit.com/hashicorp/example?ref=v1.0.3&depth=1"
}

# gittags_ssh_subdir
terraform {
source = "git::ssh://git@mygit.com/hashicorp/example//subdir/test?ref=v1.0.4&depth=1"
}

mblum14 marked this conversation as resolved.
Show resolved Hide resolved
# 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://git@mygit.com/hashicorp/example',
},
{
currentValue: 'v1.0.4',
datasource: 'git-tags',
depName: 'mygit.com/hashicorp/example',
depType: 'gitTags',
packageName: 'ssh://git@mygit.com/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]}`;
mblum14 marked this conversation as resolved.
Show resolved Hide resolved
const tempLookupName = url.split('//');
dep.packageName = tempLookupName[0] + '//' + tempLookupName[1];
} else {
dep.packageName = url;
}
Expand Down