Skip to content
Snippets Groups Projects
Unverified Commit d80bc01e authored by Sebastian Poxhofer's avatar Sebastian Poxhofer Committed by GitHub
Browse files

feat(helm-values): support inline image definitions (#12041)

parent 9b4b6ce2
No related merge requests found
---
inline_image: docker.io/library/nginx:1.18-alpine
api:
image:
image:
......
......@@ -3,6 +3,14 @@
exports[`manager/helm-values/extract extractPackageFile() extracts from complex values file correctly" 1`] = `
Object {
"deps": Array [
Object {
"autoReplaceStringTemplate": "{{depName}}{{#if newValue}}:{{newValue}}{{/if}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
"currentValue": "1.18-alpine",
"datasource": "docker",
"depName": "docker.io/library/nginx",
"replaceString": "docker.io/library/nginx:1.18-alpine",
},
Object {
"autoReplaceStringTemplate": "{{newValue}}{{#if newDigest}}@{{newDigest}}{{/if}}",
"currentDigest": undefined,
......
......@@ -40,7 +40,7 @@ describe('manager/helm-values/extract', () => {
it('extracts from complex values file correctly"', () => {
const result = extractPackageFile(helmMultiAndNestedImageValues);
expect(result).toMatchSnapshot();
expect(result.deps).toHaveLength(4);
expect(result.deps).toHaveLength(5);
});
});
});
......@@ -4,7 +4,10 @@ import { id as dockerVersioning } from '../../versioning/docker';
import { getDep } from '../dockerfile/extract';
import type { PackageDependency, PackageFile } from '../types';
import type { HelmDockerImageDependency } from './types';
import { matchesHelmValuesDockerHeuristic } from './util';
import {
matchesHelmValuesDockerHeuristic,
matchesHelmValuesInlineImage,
} from './util';
function getHelmDep({
registry,
......@@ -45,6 +48,9 @@ function findDependencies(
const repository = String(currentItem.repository);
const tag = String(currentItem.tag);
packageDependencies.push(getHelmDep({ repository, tag, registry }));
} else if (matchesHelmValuesInlineImage(key, parsedContent[key])) {
const currentItem = parsedContent[key];
packageDependencies.push(getDep(currentItem));
} else {
findDependencies(parsedContent[key], packageDependencies);
}
......
......@@ -30,3 +30,10 @@ export function matchesHelmValuesDockerHeuristic(
hasKey('tag', data)
);
}
export function matchesHelmValuesInlineImage(
parentKey: string,
data: unknown
): data is string {
return parentKeyRe.test(parentKey) && data && typeof data === 'string';
}
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