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

feat: support depth URL argument in Terraform modules #21287

Merged
merged 8 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/modules/manager/terraform/extractors/others/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ describe('modules/manager/terraform/extractors/others/modules', () => {
const ssh = gitTagsRefMatchRegex.exec(
'ssh://github.com/hashicorp/example?ref=v1.0.0'
)?.groups;
const depth = gitTagsRefMatchRegex.exec(
'ssh://github.com/hashicorp/example?depth=1&ref=v1.0.0'
)?.groups;
const folder = gitTagsRefMatchRegex.exec(
'git::ssh://git@git.example.com/modules/foo-module.git//bar?depth=1&ref=v1.0.0'
)?.groups;

expect(http).toMatchObject({
project: 'hashicorp/example',
Expand All @@ -60,6 +66,14 @@ describe('modules/manager/terraform/extractors/others/modules', () => {
project: 'hashicorp/example',
tag: 'v1.0.0',
});
expect(depth).toMatchObject({
project: 'hashicorp/example',
tag: 'v1.0.0',
});
expect(folder).toMatchObject({
project: '/bar',
tag: 'v1.0.0',
});
});

it('should parse alpha-numeric characters as well as dots, underscores, and dashes in repo names', () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/terraform/extractors/others/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const bitbucketRefMatchRegex = regEx(
/(?:git::)?(?<url>(?:http|https|ssh)?(?::\/\/)?(?:.*@)?(?<path>bitbucket\.org\/(?<workspace>.*)\/(?<project>.*).git\/?(?<subfolder>.*)))\?ref=(?<tag>.*)$/
);
export const gitTagsRefMatchRegex = regEx(
/(?:git::)?(?<url>(?:(?:http|https|ssh):\/\/)?(?:.*@)?(?<path>.*\/(?<project>.*\/.*)))\?ref=(?<tag>.*)$/
/(?:git::)?(?<url>(?:(?:http|https|ssh):\/\/)?(?:.*@)?(?<path>.*\/(?<project>.*\/.*)))\?.*ref=(?<tag>.*)$/
);
export const azureDevOpsSshRefMatchRegex = regEx(
/(?:git::)?(?<url>git@ssh\.dev\.azure\.com:v3\/(?<organization>[^/]*)\/(?<project>[^/]*)\/(?<repository>[^/]*))(?<modulepath>.*)?\?ref=(?<tag>.*)$/
Expand Down