Skip to content

Commit

Permalink
fix(gitlabci): Support named services (#9732)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
caiofbpa and viceice committed Apr 27, 2021
1 parent 54b99bd commit 3d29ce3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/manager/gitlabci/__fixtures__/gitlab-ci.5.yaml
@@ -0,0 +1,10 @@
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
37 changes: 37 additions & 0 deletions lib/manager/gitlabci/__snapshots__/extract.spec.ts.snap
Expand Up @@ -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",
},
]
`;
9 changes: 9 additions & 0 deletions lib/manager/gitlabci/extract.spec.ts
Expand Up @@ -28,6 +28,15 @@ describe(getName(), () => {
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 () => {
const res = await extractAllPackageFiles({}, [
'lib/manager/gitlabci/__fixtures__/gitlab-ci.yaml',
Expand Down
2 changes: 1 addition & 1 deletion lib/manager/gitlabci/extract.ts
Expand Up @@ -61,7 +61,7 @@ export function extractPackageFile(content: string): PackageFile | null {
foundImage = false;
const serviceImageLine = skipCommentLines(lines, lineNumber + 1);
logger.trace(`serviceImageLine: "${serviceImageLine.line}"`);
const serviceImageMatch = /^\s*-\s*'?"?([^\s'"]+)'?"?\s*$/.exec(
const serviceImageMatch = /^\s*-\s*(?:name:\s*)?'?"?([^\s'"]+)'?"?\s*$/.exec(
serviceImageLine.line
);
if (serviceImageMatch) {
Expand Down

0 comments on commit 3d29ce3

Please sign in to comment.