Skip to content

Commit

Permalink
fix(kustomize): Allow port numbers in git URLs (#9921)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
flo-02-mu and viceice committed May 11, 2021
1 parent 9ca604b commit dd712a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions lib/manager/kustomize/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe(getName(), () => {
lookupName: 'ssh://git@bitbucket.com/user/test-repo',
});
});
it('should extract the depName if the URL includes a port number', () => {
const pkg = extractBase(
'ssh://git@bitbucket.com:7999/user/test-repo?ref=v1.2.3'
);
expect(pkg).toEqual({
currentValue: 'v1.2.3',
datasource: datasourceGitTags.id,
depName: 'bitbucket.com:7999/user/test-repo',
lookupName: 'ssh://git@bitbucket.com:7999/user/test-repo',
});
});
it('should extract the version of a non http base with subdir', () => {
const pkg = extractBase(
'ssh://git@bitbucket.com/user/test-repo/subdir?ref=v1.2.3'
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/kustomize/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { Image, Kustomize } from './types';

// URL specifications should follow the hashicorp URL format
// https://github.com/hashicorp/go-getter#url-format
const gitUrl = /^(?:git::)?(?<url>(?:(?:(?:http|https|ssh):\/\/)?(?:.*@)?)?(?<path>(?:[^:/]+[:/])?(?<project>[^/]+\/[^/]+)))(?<subdir>[^?]*)\?ref=(?<currentValue>.+)$/;
const gitUrl = /^(?:git::)?(?<url>(?:(?:(?:http|https|ssh):\/\/)?(?:.*@)?)?(?<path>(?:[^:/\s]+(?::[0-9]+)?[:/])?(?<project>[^/\s]+\/[^/\s]+)))(?<subdir>[^?\s]*)\?ref=(?<currentValue>.+)$/;

export function extractBase(base: string): PackageDependency | null {
const match = gitUrl.exec(base);
Expand Down

0 comments on commit dd712a7

Please sign in to comment.