-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager/gitlabci): support registry aliases (#28607)
Co-authored-by: Sebastian Poxhofer <[email protected]>
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -354,6 +354,69 @@ describe('modules/manager/gitlabci/extract', () => { | |
expect(extractFromJob({ image: 'image:test' })).toEqual(expectedRes); | ||
}); | ||
|
||
it('extracts component references via registry aliases', () => { | ||
const registryAliases = { | ||
$CI_SERVER_HOST: 'gitlab.example.com', | ||
}; | ||
const content = codeBlock` | ||
include: | ||
- component: $CI_SERVER_HOST/an-org/a-project/[email protected] | ||
inputs: | ||
stage: build | ||
- component: $CI_SERVER_HOST/an-org/a-subgroup/a-project/a-component@e3262fdd0914fa823210cdb79a8c421e2cef79d8 | ||
- component: $CI_SERVER_HOST/an-org/a-subgroup/another-project/a-component@main | ||
- component: $CI_SERVER_HOST/another-org/a-project/a-component@~latest | ||
inputs: | ||
stage: test | ||
- component: $CI_SERVER_HOST/malformed-component-reference | ||
- component: | ||
malformed: true | ||
- component: $CI_SERVER_HOST/an-org/[email protected] | ||
- component: other-gitlab.example.com/an-org/a-project/[email protected] | ||
`; | ||
const res = extractPackageFile(content, '', { | ||
registryAliases, | ||
}); | ||
expect(res?.deps).toMatchObject([ | ||
{ | ||
currentValue: '1.0', | ||
datasource: 'gitlab-tags', | ||
depName: 'an-org/a-project', | ||
depType: 'repository', | ||
registryUrls: ['https://gitlab.example.com'], | ||
}, | ||
{ | ||
currentValue: 'e3262fdd0914fa823210cdb79a8c421e2cef79d8', | ||
datasource: 'gitlab-tags', | ||
depName: 'an-org/a-subgroup/a-project', | ||
depType: 'repository', | ||
registryUrls: ['https://gitlab.example.com'], | ||
}, | ||
{ | ||
currentValue: 'main', | ||
datasource: 'gitlab-tags', | ||
depName: 'an-org/a-subgroup/another-project', | ||
depType: 'repository', | ||
registryUrls: ['https://gitlab.example.com'], | ||
}, | ||
{ | ||
currentValue: '~latest', | ||
datasource: 'gitlab-tags', | ||
depName: 'another-org/a-project', | ||
depType: 'repository', | ||
registryUrls: ['https://gitlab.example.com'], | ||
skipReason: 'unsupported-version', | ||
}, | ||
{ | ||
currentValue: '1.0', | ||
datasource: 'gitlab-tags', | ||
depName: 'an-org/a-project', | ||
depType: 'repository', | ||
registryUrls: ['https://other-gitlab.example.com'], | ||
}, | ||
]); | ||
}); | ||
|
||
it('extracts component references', () => { | ||
const content = codeBlock` | ||
include: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters