mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 22:46:27 +00:00
fix(manager): support newer kustomize urls (#6206)
This commit is contained in:
parent
9f89157e17
commit
a0b8b87c74
4 changed files with 45 additions and 1 deletions
|
@ -3,8 +3,12 @@ kind: Kustomization
|
||||||
|
|
||||||
bases:
|
bases:
|
||||||
- github.com/user/repo//deploy?ref=v0.0.1
|
- github.com/user/repo//deploy?ref=v0.0.1
|
||||||
|
- github.com/fluxcd/flux/deploy?ref=1.19.0
|
||||||
|
|
||||||
namespace: testing-namespace
|
namespace: testing-namespace
|
||||||
|
|
||||||
resources:
|
resources:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
|
|
||||||
|
images:
|
||||||
|
- name: nginx
|
||||||
|
|
|
@ -8,6 +8,12 @@ Array [
|
||||||
"depName": "github.com/user/repo//deploy",
|
"depName": "github.com/user/repo//deploy",
|
||||||
"lookupName": "github.com/user/repo",
|
"lookupName": "github.com/user/repo",
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"currentValue": "1.19.0",
|
||||||
|
"datasource": "github-tags",
|
||||||
|
"depName": "fluxcd/flux/deploy",
|
||||||
|
"lookupName": "fluxcd/flux",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync } from 'fs';
|
||||||
import * as datasourceDocker from '../../datasource/docker';
|
import * as datasourceDocker from '../../datasource/docker';
|
||||||
import * as datasourceGitTags from '../../datasource/git-tags';
|
import * as datasourceGitTags from '../../datasource/git-tags';
|
||||||
|
import * as datasourceGitHubTags from '../../datasource/github-tags';
|
||||||
import {
|
import {
|
||||||
extractBase,
|
extractBase,
|
||||||
extractImage,
|
extractImage,
|
||||||
|
@ -70,6 +71,20 @@ describe('manager/kustomize/extract', () => {
|
||||||
const pkg = extractBase(`${base}?ref=${version}`);
|
const pkg = extractBase(`${base}?ref=${version}`);
|
||||||
expect(pkg).toEqual(sample);
|
expect(pkg).toEqual(sample);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should extract out the version of an github base', () => {
|
||||||
|
const base = 'fluxcd/flux/deploy';
|
||||||
|
const version = 'v1.0.0';
|
||||||
|
const sample = {
|
||||||
|
currentValue: version,
|
||||||
|
datasource: datasourceGitHubTags.id,
|
||||||
|
depName: base,
|
||||||
|
lookupName: 'fluxcd/flux',
|
||||||
|
};
|
||||||
|
|
||||||
|
const pkg = extractBase(`github.com/${base}?ref=${version}`);
|
||||||
|
expect(pkg).toEqual(sample);
|
||||||
|
});
|
||||||
it('should extract out the version of a git base', () => {
|
it('should extract out the version of a git base', () => {
|
||||||
const base = 'git@github.com:user/repo.git';
|
const base = 'git@github.com:user/repo.git';
|
||||||
const version = 'v1.0.0';
|
const version = 'v1.0.0';
|
||||||
|
@ -193,8 +208,11 @@ describe('manager/kustomize/extract', () => {
|
||||||
it('extracts http dependency', () => {
|
it('extracts http dependency', () => {
|
||||||
const res = extractPackageFile(kustomizeHTTP);
|
const res = extractPackageFile(kustomizeHTTP);
|
||||||
expect(res.deps).toMatchSnapshot();
|
expect(res.deps).toMatchSnapshot();
|
||||||
expect(res.deps).toHaveLength(1);
|
expect(res.deps).toHaveLength(2);
|
||||||
expect(res.deps[0].currentValue).toEqual('v0.0.1');
|
expect(res.deps[0].currentValue).toEqual('v0.0.1');
|
||||||
|
expect(res.deps[1].currentValue).toEqual('1.19.0');
|
||||||
|
expect(res.deps[1].depName).toEqual('fluxcd/flux/deploy');
|
||||||
|
expect(res.deps[1].lookupName).toEqual('fluxcd/flux');
|
||||||
});
|
});
|
||||||
it('should extract out image versions', () => {
|
it('should extract out image versions', () => {
|
||||||
const res = extractPackageFile(gitImages);
|
const res = extractPackageFile(gitImages);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { safeLoad } from 'js-yaml';
|
import { safeLoad } from 'js-yaml';
|
||||||
import * as datasourceDocker from '../../datasource/docker';
|
import * as datasourceDocker from '../../datasource/docker';
|
||||||
import * as datasourceGitTags from '../../datasource/git-tags';
|
import * as datasourceGitTags from '../../datasource/git-tags';
|
||||||
|
import * as datasourceGitHubTags from '../../datasource/github-tags';
|
||||||
import { logger } from '../../logger';
|
import { logger } from '../../logger';
|
||||||
import { PackageDependency, PackageFile } from '../common';
|
import { PackageDependency, PackageFile } from '../common';
|
||||||
|
|
||||||
|
@ -21,7 +22,22 @@ const versionMatch = /(?<basename>.*)\?ref=(?<version>.*)\s*$/;
|
||||||
// extract the url from the base of a url with a subdir
|
// extract the url from the base of a url with a subdir
|
||||||
const extractUrl = /^(?<url>.*)(?:\/\/.*)$/;
|
const extractUrl = /^(?<url>.*)(?:\/\/.*)$/;
|
||||||
|
|
||||||
|
const githubUrl = /^github\.com\/(?<depName>(?<lookupName>[^/]+?\/[^/]+?)(?:\/[^/]+?)*)\?ref=(?<currentValue>.+)$/;
|
||||||
|
|
||||||
export function extractBase(base: string): PackageDependency | null {
|
export function extractBase(base: string): PackageDependency | null {
|
||||||
|
const githubMatch = githubUrl.exec(base);
|
||||||
|
|
||||||
|
if (githubMatch?.groups) {
|
||||||
|
const { currentValue, depName, lookupName } = githubMatch.groups;
|
||||||
|
|
||||||
|
return {
|
||||||
|
datasource: datasourceGitHubTags.id,
|
||||||
|
depName,
|
||||||
|
lookupName,
|
||||||
|
currentValue,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const basenameVersion = versionMatch.exec(base);
|
const basenameVersion = versionMatch.exec(base);
|
||||||
if (basenameVersion) {
|
if (basenameVersion) {
|
||||||
const currentValue = basenameVersion.groups.version;
|
const currentValue = basenameVersion.groups.version;
|
||||||
|
|
Loading…
Reference in a new issue