Skip to content
Snippets Groups Projects
Unverified Commit 3d29ce33 authored by Caio Andrade's avatar Caio Andrade Committed by GitHub
Browse files

fix(gitlabci): Support named services (#9732)

parent 54b99bd1
No related branches found
No related tags found
No related merge requests found
image:
# comment
name: renovate/renovate:19.70.8-slim
services:
# comment
- mariadb:10.4.11
# another comment
- name: other/image:1.0.0
alias: imagealias
...@@ -174,3 +174,40 @@ Array [ ...@@ -174,3 +174,40 @@ Array [
}, },
] ]
`; `;
exports[`manager/gitlabci/extract extractAllPackageFiles() extracts named services 1`] = `
Array [
Object {
"deps": Array [
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "19.70.8-slim",
"datasource": "docker",
"depName": "renovate/renovate",
"depType": "image-name",
"replaceString": "renovate/renovate:19.70.8-slim",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "10.4.11",
"datasource": "docker",
"depName": "mariadb",
"depType": "service-image",
"replaceString": "mariadb:10.4.11",
},
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "1.0.0",
"datasource": "docker",
"depName": "other/image",
"depType": "service-image",
"replaceString": "other/image:1.0.0",
},
],
"packageFile": "lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml",
},
]
`;
...@@ -28,6 +28,15 @@ describe(getName(), () => { ...@@ -28,6 +28,15 @@ describe(getName(), () => {
expect(deps).toHaveLength(5); expect(deps).toHaveLength(5);
}); });
it('extracts named services', async () => {
const res = await extractAllPackageFiles({}, [
'lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml',
]);
expect(res).toMatchSnapshot();
expect(res).toHaveLength(1);
expect(res[0].deps).toHaveLength(3);
});
it('extracts multiple image lines', async () => { it('extracts multiple image lines', async () => {
const res = await extractAllPackageFiles({}, [ const res = await extractAllPackageFiles({}, [
'lib/manager/gitlabci/__fixtures__/gitlab-ci.yaml', 'lib/manager/gitlabci/__fixtures__/gitlab-ci.yaml',
......
...@@ -61,7 +61,7 @@ export function extractPackageFile(content: string): PackageFile | null { ...@@ -61,7 +61,7 @@ export function extractPackageFile(content: string): PackageFile | null {
foundImage = false; foundImage = false;
const serviceImageLine = skipCommentLines(lines, lineNumber + 1); const serviceImageLine = skipCommentLines(lines, lineNumber + 1);
logger.trace(`serviceImageLine: "${serviceImageLine.line}"`); logger.trace(`serviceImageLine: "${serviceImageLine.line}"`);
const serviceImageMatch = /^\s*-\s*'?"?([^\s'"]+)'?"?\s*$/.exec( const serviceImageMatch = /^\s*-\s*(?:name:\s*)?'?"?([^\s'"]+)'?"?\s*$/.exec(
serviceImageLine.line serviceImageLine.line
); );
if (serviceImageMatch) { if (serviceImageMatch) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment