Only change the version, don't format
cwrau opened this issue · 3 comments
cwrau commented
Currently, when I run heluxup .
it successfully updates my Helm charts, but also formats and document splits(?) my YAML files:
Before:
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: external-dns
namespace: ingress
spec:
releaseName: external-dns
chart:
repository: https://kubernetes-charts.storage.googleapis.com/
name: external-dns
version: 2.10.2
values:
sources:
- service
- ingress
- crd
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
privileged: false
capabilities:
drop:
- ALL
runAsGroup: 1001
runAsUser: 1001
After:
---
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
name: external-dns
namespace: ingress
spec:
releaseName: external-dns
chart:
repository: https://kubernetes-charts.storage.googleapis.com/
name: external-dns
version: 2.10.3
values:
sources:
- service
- ingress
- crd
securityContext:
runAsNonRoot: true
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
privileged: false
capabilities:
drop:
- ALL
runAsGroup: 1001
runAsUser: 1001
Diff:
diff --git a/ingress/external-dns.yaml b/ingress/external-dns.yaml
index 53c5cde..ee1054b 100644
--- a/ingress/external-dns.yaml
+++ b/ingress/external-dns.yaml
@@ -1,3 +1,4 @@
+---
apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
@@ -8,7 +9,7 @@ spec:
chart:
repository: https://kubernetes-charts.storage.googleapis.com/
name: external-dns
- version: 2.10.2
+ version: 2.10.3
values:
cloudflare:
apiKey: SEEEEEEECREEEEEEEET
@@ -16,9 +17,9 @@ spec:
proxied: false
provider: cloudflare
sources:
- - service
- - ingress
- - crd
+ - service
+ - ingress
+ - crd
rbac:
create: true
crd:
@@ -34,7 +35,7 @@ spec:
privileged: false
capabilities:
drop:
- - ALL
+ - ALL
runAsGroup: 1001
runAsUser: 1001
resources:
Therefore I have to reformat the YAML files after each update and also remove the ---
.
It would be awesome if you could only change the version 🤗
ekeih commented
Maybe we can use load_yaml_guess_indent
https://bitbucket.org/ruamel/yaml/src/bace8dc0e8f5d950b4e9a62457a7d892626f8e81/util.py#lines-60 to guess the original indentation and preserve it.
cwrau commented
This seems to work, but this only allows single documents?
We'd have to somehow split the files into documents and then use this.
And then we'd have to join the documents again.
cwrau commented
release, indent, block_seq_indent = util.load_yaml_guess_indent(file_read)
if release is not None and 'kind' in release and release['kind'] == 'HelmRelease':
helm_release = HelmRelease(
release_name=release['spec']['releaseName'],
chart_name=release['spec']['chart']['name'],
repository=release['spec']['chart']['repository'],
git_version=release['spec']['chart']['version'],
unstable=unstable,
)
if helm_release.git_version != helm_release.latest_version:
click.echo('{}Updating release {} ({}) from {} to {}'
.format(dry_run_marker, helm_release.release_name, helm_release.chart_name,
helm_release.git_version, helm_release.latest_version))
update_count += 1
if not dry_run:
release['spec']['chart']['version'] = helm_release.latest_version
print(ym.round_trip_dump(release, indent=indent, block_seq_indent=block_seq_indent))
This keeps the indentation, but only works for single documents