Skip to content

Add tool to extract values from different HelmRelease paths without installing it

Bogdan-Adrian Burciu requested to merge fix-issue-206 into main

What does this MR do and why?

Introduces a tool to help in solving #206 (closed) and #15.
For #206 (closed) we make use of it with parameter --values-path .spec.valuesFrom to get the registry_mirrors from the HelmRelease/sylva-units, without instantiating this HelmRelease (a chicken and egg situation, we need the registry mirrors in order create the Kind cluster on which the HelmRelease would get installed, while we need the Kind cluster to instantiate the HelmRelease and get its values).

What we need to ensure is that for the --values-path .spec.valuesFrom each (Secret or ConfigMap) resource in this HelmRelease.spec.valuesFrom list needs to have contents (at their valuesKey), an empty content would return a None type error.

It's applicability for solving #206 (closed) was already successfully confirmed in multiple ./bootstrap.sh integration testing runs.
CC: @rletrocquer

Related reference(s)

Closes #206 (closed)

Test coverage

[git:fix-issue-206]root@bootstrap-vm:sylva-core- # kustomize build --load-restrictor LoadRestrictionsNone environment-values/rke2-capd-baburciu/ |./tools/extractHelmReleaseValues.py --values-path .spec.valuesFrom | yq .oci_registry_extra_ca_certs
-----BEGIN CERTIFICATE-----
MIIDXzCCAkegAwIBAgIUH344/MkyUtoagAV6vESAJy0dO1kwDQYJKoZIhvcNAQEL
BQAwPzELMAkGA1UEBhMCRlIxCzAJBgNVBAgMAkZSMQwwCgYDVQQHDANWRFIxFTAT
BgNVBAMMDHJvY2tldC5sb2NhbDAeFw0yNDAxMzAxMzEwNTZaFw0yNzAxMjkxMzEw
NTZaMD8xCzAJBgNVBAYTAkZSMQswCQYDVQQIDAJGUjEMMAoGA1UEBwwDVkRSMRUw
EwYDVQQDDAxyb2NrZXQubG9jYWwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
AoIBAQC9CVJ7+2v0xzzf5u+qQFbnllg3XlS66On1sDFzJePX28x2YgYLW8TWyIPk
/aGxKFRaBpsMhQZYH4Vj9k0ThB/2y/HgIn0igLNlxLW7MdzsUOJXv0MWQy4UIy7J
L2rzgdWRxXlmiuIoPULO+Po9MujJWgWeF6IsIRWJEUv7qwwBpFiXtJv4P6yjZjwL
ccwTuEcUdKtnf64eixpGiZ1pghlCSEb1aADrqc+/0wejTrC4tqaE1R9pvmiyAG/u
5bZ4WndQCIUV0NbgQAGyEbOro1hhVXMMtdUPYPYeYRslhPF7/nUxhkVVPzOP372B
LGypHqjRYZ19+UyknOFt5JAEG+01AgMBAAGjUzBRMB0GA1UdDgQWBBTrdI1WzQC+
nXVf6Rr4P42ptNZ+oTAfBgNVHSMEGDAWgBTrdI1WzQC+nXVf6Rr4P42ptNZ+oTAP
BgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCawm9jWR7zxpJDlT3J
vN9N2Su4EsLsDbf08oooCxAzlf6ibAVvlEzLxCtHtmSFn4/k8TfD/RHrmFbGh3MI
QmahM9lxIrHHXrLE1ptDGMHcpxUeMu8eCknnq1PpSA+RukBMCYbK5V4YHUa7Om+l
YShOtrSpcUi8dRYq2fDWM4KMu7Uz1dv1zwBYYl6Ged0BrTeQ8iBN0YjK6HLqQ9RN
ZWFLVau30LB6b6/nwvXSOLQbbExyuajS6ZrFYnwfrfR9Pjcpx11P9+6IrbPC1CfZ
ux7cKFCq4wuhq3hUyVZHrzo23pUfxFq+/5RHzrlw5CB2c/HdcZ0dgqQi2lq681T9
pbve
-----END CERTIFICATE-----
[git:fix-issue-206]root@bootstrap-vm:sylva-core # kustomize build --load-restrictor LoadRestrictionsNone environment-values/rke2-capd-baburciu/ |./tools/extractHelmReleaseValues.py --values-path .spec.chart.spec.valuesFiles
valuesFiles:
- charts/sylva-units/values.yaml
- charts/sylva-units/management.values.yaml

[git:fix-issue-206]root@bootstrap-vm:sylva-core # kustomize build --load-restrictor LoadRestrictionsNone environment-values/rke2-capd-baburciu/ |./tools/extractHelmReleaseValues.py --values-path .spec.values
values:
  source_templates:
    sylva-core:
      existing_source:
        kind: GitRepository
        name: sylva-core

[git:fix-issue-206]root@bootstrap-vm:sylva-core#
Edited by Bogdan-Adrian Burciu

Merge request reports