Skip to content
Snippets Groups Projects
Unverified Commit a0b8b87c authored by Michael Kriese's avatar Michael Kriese Committed by GitHub
Browse files

fix(manager): support newer kustomize urls (#6206)

parent 9f89157e
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,12 @@ kind: Kustomization
bases:
- github.com/user/repo//deploy?ref=v0.0.1
- github.com/fluxcd/flux/deploy?ref=1.19.0
namespace: testing-namespace
resources:
- deployment.yaml
images:
- name: nginx
......@@ -8,6 +8,12 @@ Array [
"depName": "github.com/user/repo//deploy",
"lookupName": "github.com/user/repo",
},
Object {
"currentValue": "1.19.0",
"datasource": "github-tags",
"depName": "fluxcd/flux/deploy",
"lookupName": "fluxcd/flux",
},
]
`;
......
import { readFileSync } from 'fs';
import * as datasourceDocker from '../../datasource/docker';
import * as datasourceGitTags from '../../datasource/git-tags';
import * as datasourceGitHubTags from '../../datasource/github-tags';
import {
extractBase,
extractImage,
......@@ -70,6 +71,20 @@ describe('manager/kustomize/extract', () => {
const pkg = extractBase(`${base}?ref=${version}`);
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', () => {
const base = 'git@github.com:user/repo.git';
const version = 'v1.0.0';
......@@ -193,8 +208,11 @@ describe('manager/kustomize/extract', () => {
it('extracts http dependency', () => {
const res = extractPackageFile(kustomizeHTTP);
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[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', () => {
const res = extractPackageFile(gitImages);
......
import { safeLoad } from 'js-yaml';
import * as datasourceDocker from '../../datasource/docker';
import * as datasourceGitTags from '../../datasource/git-tags';
import * as datasourceGitHubTags from '../../datasource/github-tags';
import { logger } from '../../logger';
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
const extractUrl = /^(?<url>.*)(?:\/\/.*)$/;
const githubUrl = /^github\.com\/(?<depName>(?<lookupName>[^/]+?\/[^/]+?)(?:\/[^/]+?)*)\?ref=(?<currentValue>.+)$/;
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);
if (basenameVersion) {
const currentValue = basenameVersion.groups.version;
......
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