From f71e44e26b82f28a5046b7ec45bc6e607a7c8583 Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer <secustor@users.noreply.github.com> Date: Thu, 23 Jul 2020 12:41:42 +0200 Subject: [PATCH] fix(ansible-galaxy): add alternative galaxy role declaration (#6830) Co-authored-by: Michael Kriese <michael.kriese@visualon.de> --- .../ansible-galaxy/__fixtures__/requirements01.yml | 3 +++ .../ansible-galaxy/__snapshots__/extract.spec.ts.snap | 6 ++++++ lib/manager/ansible-galaxy/extract.spec.ts | 2 +- lib/manager/ansible-galaxy/extract.ts | 8 +++++++- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/manager/ansible-galaxy/__fixtures__/requirements01.yml b/lib/manager/ansible-galaxy/__fixtures__/requirements01.yml index ea0ff5a7d4..ad476fc795 100644 --- a/lib/manager/ansible-galaxy/__fixtures__/requirements01.yml +++ b/lib/manager/ansible-galaxy/__fixtures__/requirements01.yml @@ -2,6 +2,9 @@ - src: yatesr.timezone version: "0.1.0" +- name: 'cloudalchemy.node-exporter' + version: '0.19.0' + # GitHub repo, accessible by http(s) - version: master src: https://github.com/bennojoy/nginx diff --git a/lib/manager/ansible-galaxy/__snapshots__/extract.spec.ts.snap b/lib/manager/ansible-galaxy/__snapshots__/extract.spec.ts.snap index 929c35432d..ba9628cf6c 100644 --- a/lib/manager/ansible-galaxy/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/ansible-galaxy/__snapshots__/extract.spec.ts.snap @@ -25,6 +25,12 @@ Array [ "depName": "yatesr.timezone", "lookupName": "yatesr.timezone", }, + Object { + "currentValue": "0.19.0", + "datasource": "galaxy", + "depName": "cloudalchemy.node-exporter", + "lookupName": "cloudalchemy.node-exporter", + }, Object { "currentValue": "master", "datasource": "git-tags", diff --git a/lib/manager/ansible-galaxy/extract.spec.ts b/lib/manager/ansible-galaxy/extract.spec.ts index 830f13184f..dd387286ac 100644 --- a/lib/manager/ansible-galaxy/extract.spec.ts +++ b/lib/manager/ansible-galaxy/extract.spec.ts @@ -22,7 +22,7 @@ describe('lib/manager/ansible-galaxy/extract', () => { it('extracts multiple dependencies from requirements.yml', () => { const res = extractPackageFile(yamlFile1); expect(res.deps).toMatchSnapshot(); - expect(res.deps).toHaveLength(9); + expect(res.deps).toHaveLength(10); }); it('extracts dependencies from a not beautified requirements file', () => { const res = extractPackageFile(yamlFile2); diff --git a/lib/manager/ansible-galaxy/extract.ts b/lib/manager/ansible-galaxy/extract.ts index 865131a242..846dae7a73 100644 --- a/lib/manager/ansible-galaxy/extract.ts +++ b/lib/manager/ansible-galaxy/extract.ts @@ -4,6 +4,8 @@ import { logger } from '../../logger'; import { SkipReason } from '../../types'; import { PackageDependency, PackageFile } from '../common'; +const galaxyRoleRegex = /.+\..+/; + function interpretLine( lineMatch: RegExpMatchArray, lineNumber: number, @@ -54,10 +56,14 @@ function finalize(dependency: PackageDependency): boolean { dep.depName = sourceMatch[4]; // remove leading `git+` from URLs like `git+https://...` dep.lookupName = source.replace(/git\+/, ''); - } else if (new RegExp(/.+\..+/).exec(source)) { + } else if (galaxyRoleRegex.exec(source)) { dep.datasource = datasourceGalaxy.id; dep.depName = dep.managerData.src; dep.lookupName = dep.managerData.src; + } else if (galaxyRoleRegex.exec(dep.managerData.name)) { + dep.datasource = datasourceGalaxy.id; + dep.depName = dep.managerData.name; + dep.lookupName = dep.managerData.name; } else { dep.skipReason = SkipReason.NoSourceMatch; return false; -- GitLab