Skip to content

Commit

Permalink
refactor: always set registryUrls
Browse files Browse the repository at this point in the history
  • Loading branch information
fgreinacher committed Jan 20, 2024
1 parent 2e37a6e commit b3417de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/modules/manager/gitlabci/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,6 @@ describe('modules/manager/gitlabci/extract', () => {
});

it('extracts component references', () => {
GlobalConfig.set({
endpoint: 'https://gitlab.example.com',
});

const content = codeBlock`
include:
- component: gitlab.example.com/an-org/a-project/a-component@1.0
Expand All @@ -377,24 +373,28 @@ describe('modules/manager/gitlabci/extract', () => {
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',
},
{
Expand Down
14 changes: 2 additions & 12 deletions lib/modules/manager/gitlabci/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ function getAllIncludeComponents(

function extractDepFromIncludeComponent(
includeComponent: GitlabIncludeComponent,
endpoint: string | undefined,
): PackageDependency | null {
const componentReference = componentReferenceRegex.exec(
includeComponent.component,
Expand All @@ -147,6 +146,7 @@ function extractDepFromIncludeComponent(
depName: componentReference.projectPath,
depType: 'repository',
currentValue: componentReference.specificVersion,
registryUrls: [`https://${componentReference.fqdn}`],
};
if (dep.currentValue === componentReferenceLatestVersion) {
logger.debug(
Expand All @@ -155,15 +155,6 @@ function extractDepFromIncludeComponent(
);
dep.skipReason = 'unsupported-version';
}
const endpointUrl = parseUrl(endpoint);
if (endpointUrl && endpointUrl.hostname !== componentReference.fqdn) {
const registryUrl = `https://${componentReference.fqdn}`;
logger.debug(
{ componentReference: includeComponent.component },
'Setting registry URL for external component reference',
);
dep.registryUrls = [registryUrl];
}
return dep;
}

Expand All @@ -173,7 +164,6 @@ export function extractPackageFile(
config: ExtractConfig,
): PackageFileContent | null {
let deps: PackageDependency[] = [];
const endpoint = GlobalConfig.get('endpoint');
try {
// TODO: use schema (#9610)
const doc = parseSingleYaml<GitlabPipeline>(replaceReferenceTags(content), {
Expand Down Expand Up @@ -210,7 +200,7 @@ export function extractPackageFile(

const includedComponents = getAllIncludeComponents(doc);
for (const includedComponent of includedComponents) {
const dep = extractDepFromIncludeComponent(includedComponent, endpoint);
const dep = extractDepFromIncludeComponent(includedComponent);
if (dep) {
deps.push(dep);
}
Expand Down

0 comments on commit b3417de

Please sign in to comment.