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(managers/circleci): add registryAliases support to circleci manager #32945

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -3691,6 +3691,7 @@ This feature works with the following managers:

- [`ansible`](modules/manager/ansible/index.md)
- [`bitbucket-pipelines`](modules/manager/bitbucket-pipelines/index.md)
- [`circleci`](modules/manager/circleci/index.md)
- [`docker-compose`](modules/manager/docker-compose/index.md)
- [`dockerfile`](modules/manager/dockerfile/index.md)
- [`droneci`](modules/manager/droneci/index.md)
Expand Down
27 changes: 27 additions & 0 deletions lib/modules/manager/circleci/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,33 @@ describe('modules/manager/circleci/extract', () => {
expect(extractPackageFile('nothing here')).toBeNull();
});

it('handles registry alias', () => {
const res = extractPackageFile(
'executors:\n my-executor:\n docker:\n - image: quay.io/myName/myPackage:0.6.2',
'',
{
registryAliases: {
'quay.io': 'my-quay-mirror.registry.com',
'index.docker.io': 'my-docker-mirror.registry.com',
},
},
);
expect(res).toEqual({
deps: [
{
autoReplaceStringTemplate:
'quay.io/myName/myPackage:{{#if newValue}}{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}',
currentDigest: undefined,
currentValue: '0.6.2',
datasource: 'docker',
depName: 'my-quay-mirror.registry.com/myName/myPackage',
depType: 'docker',
replaceString: 'quay.io/myName/myPackage:0.6.2',
},
],
});
});

it('extracts multiple image and resolves yaml anchors', () => {
const res = extractPackageFile(file1);
expect(res?.deps).toEqual([
Expand Down
11 changes: 8 additions & 3 deletions lib/modules/manager/circleci/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@ import { parseSingleYaml } from '../../../util/yaml';
import { OrbDatasource } from '../../datasource/orb';
import * as npmVersioning from '../../versioning/npm';
import { getDep } from '../dockerfile/extract';
import type { PackageDependency, PackageFileContent } from '../types';
import type {
ExtractConfig,
PackageDependency,
PackageFileContent,
} from '../types';
import { CircleCiFile, type CircleCiJob } from './schema';

export function extractPackageFile(
content: string,
packageFile?: string,
config?: ExtractConfig,
): PackageFileContent | null {
const deps: PackageDependency[] = [];
try {
Expand Down Expand Up @@ -38,15 +43,15 @@ export function extractPackageFile(
for (const job of environments) {
for (const dockerElement of coerceArray(job.docker)) {
deps.push({
...getDep(dockerElement.image),
...getDep(dockerElement.image, true, config?.registryAliases),
depType: 'docker',
});
}
}

for (const alias of coerceArray(parsed.aliases)) {
deps.push({
...getDep(alias.image),
...getDep(alias.image, true, config?.registryAliases),
depType: 'docker',
});
}
Expand Down
Loading