mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 15:06:27 +00:00
feat(helmfile): Parse multidoc yaml (#9113)
This commit is contained in:
parent
edfac73a08
commit
f4f2a088ee
4 changed files with 110 additions and 2 deletions
62
lib/manager/helmfile/__fixtures__/multidoc.yaml
Normal file
62
lib/manager/helmfile/__fixtures__/multidoc.yaml
Normal file
|
@ -0,0 +1,62 @@
|
|||
environments:
|
||||
templated-environment: &templated-environment
|
||||
values:
|
||||
- ./environment/_shared/env.yaml
|
||||
- ./environment/{{ .Environment.Name }}/env.yaml
|
||||
beta:
|
||||
<<: *templated-environment
|
||||
support:
|
||||
<<: *templated-environment
|
||||
---
|
||||
|
||||
helmDefaults:
|
||||
# {{- if eq false (hasKey .Values "noKubeConf") }}
|
||||
kubeContext: "{{ .Values.global.kube_context | getOrNil .Environment.Name | default .Environment.Name }}"
|
||||
# {{- end }}
|
||||
|
||||
---
|
||||
|
||||
repositories:
|
||||
- name: stable
|
||||
url: https://charts.helm.sh/stable/
|
||||
- name: incubator
|
||||
url: https://charts.helm.sh/incubator/
|
||||
- name: bitnami
|
||||
url: https://charts.bitnami.com/bitnami
|
||||
- name: prometheus-community
|
||||
url: https://prometheus-community.github.io/helm-charts
|
||||
|
||||
templates:
|
||||
external-chart: &external-chart
|
||||
missingFileHandler: Debug
|
||||
installedTemplate: '{{`{{ .Values | getOrNil .Release.Name | getOrNil "enabled" | default false }}`}}'
|
||||
namespace: '{{`{{ .Values | getOrNil .Release.Name | getOrNil "namespace" | default "default" }}`}}'
|
||||
version: '{{`{{ .Values | getOrNil .Release.Name | getOrNil "version" | default "*" }}`}}'
|
||||
values:
|
||||
- "./environment/_shared/{{`{{ .Release.Name }}`}}.yaml"
|
||||
- "./environment/_shared/{{`{{ .Release.Name }}`}}.yaml.gotmpl"
|
||||
- "./environment/{{`{{ .Environment.Name }}`}}/{{`{{ .Release.Name }}`}}.yaml"
|
||||
- "./environment/{{`{{ .Environment.Name }}`}}/{{`{{ .Release.Name }}`}}.yaml.gotmpl"
|
||||
secrets:
|
||||
# {{- if eq false (hasKey .Values "noSecrets") }}
|
||||
- "./environment/{{`{{ .Environment.Name }}`}}/{{`{{ .Release.Name }}`}}-secrets.yaml"
|
||||
# {{- end }}
|
||||
|
||||
releases:
|
||||
- name: manifests
|
||||
chart: "./environment/{{`{{ .Environment.Name }}`}}/static"
|
||||
installedTemplate: '{{`{{ .Values | getOrNil .Release.Name | getOrNil "enabled" | default false }}`}}'
|
||||
|
||||
- name: rabbitmq
|
||||
<<: *external-chart
|
||||
chart: bitnami/rabbitmq
|
||||
needs:
|
||||
- manifests
|
||||
version: 7.4.3
|
||||
|
||||
- name: prometheus-operator
|
||||
<<: *external-chart
|
||||
chart: prometheus-community/kube-prometheus-stack
|
||||
needs:
|
||||
- manifests
|
||||
version: 13.7.2
|
|
@ -1,5 +1,31 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`lib/manager/helmfile/extract extractPackageFile() parses multidoc yaml 1`] = `
|
||||
Object {
|
||||
"datasource": "helm",
|
||||
"deps": Array [
|
||||
Object {
|
||||
"depName": "./environment/{{\`{{ .Environment.Name }}\`}}/static",
|
||||
"skipReason": "local-chart",
|
||||
},
|
||||
Object {
|
||||
"currentValue": "7.4.3",
|
||||
"depName": "rabbitmq",
|
||||
"registryUrls": Array [
|
||||
"https://charts.bitnami.com/bitnami",
|
||||
],
|
||||
},
|
||||
Object {
|
||||
"currentValue": "13.7.2",
|
||||
"depName": "kube-prometheus-stack",
|
||||
"registryUrls": Array [
|
||||
"https://prometheus-community.github.io/helm-charts",
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`lib/manager/helmfile/extract extractPackageFile() skip chart that does not have specified version 1`] = `
|
||||
Object {
|
||||
"datasource": "helm",
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
import { readFileSync } from 'fs';
|
||||
import { extractPackageFile } from './extract';
|
||||
|
||||
const multidocYaml = readFileSync(
|
||||
'lib/manager/helmfile/__fixtures__/multidoc.yaml',
|
||||
'utf8'
|
||||
);
|
||||
describe('lib/manager/helmfile/extract', () => {
|
||||
describe('extractPackageFile()', () => {
|
||||
beforeEach(() => {
|
||||
|
@ -167,5 +172,16 @@ describe('lib/manager/helmfile/extract', () => {
|
|||
expect(result).toMatchSnapshot();
|
||||
expect(result.deps.every((dep) => dep.skipReason)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('parses multidoc yaml', () => {
|
||||
const fileName = 'helmfile.yaml';
|
||||
const result = extractPackageFile(multidocYaml, fileName, {
|
||||
aliases: {
|
||||
stable: 'https://charts.helm.sh/stable',
|
||||
},
|
||||
});
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -35,8 +35,7 @@ export function extractPackageFile(
|
|||
}
|
||||
for (const doc of docs) {
|
||||
if (!(doc && is.array(doc.releases))) {
|
||||
logger.debug({ fileName }, 'helmfile.yaml has no releases');
|
||||
return null;
|
||||
continue; // eslint-disable-line no-continue
|
||||
}
|
||||
|
||||
if (doc.repositories) {
|
||||
|
@ -94,5 +93,10 @@ export function extractPackageFile(
|
|||
});
|
||||
}
|
||||
|
||||
if (!deps.length) {
|
||||
logger.debug({ fileName }, 'helmfile.yaml has no releases');
|
||||
return null;
|
||||
}
|
||||
|
||||
return { deps, datasource: datasourceHelm.id } as PackageFile;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue