The indent function strips empty lines that might be required. In our example the issue occurs while trying to print a PGP public key block. The empty line is required for the PGP PUBLIC KEY BLOCK to be considered valid.
To Reproduce
Create a secret on HashiCorp Vault with the following content
-----BEGIN PGP PUBLIC KEY BLOCK-----
TmV2ZXIgZ29ubmEgZ2l2ZSB5b3UgdXAKTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duCk5ldmVyIGdv
bm5hIHJ1biBhcm91bmQgYW5kIGRlc2VydCB5b3UKTmV2ZXIgZ29ubmEgbWFrZSB5b3UgY3J5Ck5l
dmVyIGdvbm5hIHNheSBnb29kYnllCk5ldmVyIGdvbm5hIHRlbGwgYSBsaWUgYW5kIGh1cnQgeW91
Cg==
-----END PGP PUBLIC KEY BLOCK-----
Create a ConfigMap file with the following content and replace the HashiCorp Vault path. (NOTE: the config key here is a multiline-string. Indentation in a yaml structure is not necessary since is already handled corretly by the plugin)
# Version we have deployed
argocd-vault-plugin_1.17.0_linux_amd64 generate configmap.yaml
# Latest version
argocd-vault-plugin_1.18.1_linux_amd64 generate configmap.yaml
Expected behavior
We expect to have all content returned with proper indentation as below:
Describe the bug
The indent function strips empty lines that might be required. In our example the issue occurs while trying to print a PGP public key block. The empty line is required for the PGP PUBLIC KEY BLOCK to be considered valid.
To Reproduce
Create a secret on HashiCorp Vault with the following content
Create a ConfigMap file with the following content and replace the HashiCorp Vault path. (NOTE: the
config
key here is a multiline-string. Indentation in a yaml structure is not necessary since is already handled corretly by the plugin)Run the argocd-vault-plugin to template the file
Expected behavior
We expect to have all content returned with proper indentation as below:
Screenshots/Verbose output
We receive the output with the empty line removed by the indent plugin.
Additional Infromation
I assume the problem comes from here: https://github.com/argoproj-labs/argocd-vault-plugin/blob/810f1fe9b4a064b145621ac42113860487551bd7/pkg/kube/modifiers.go#L49-L57
I think the function should always write the trailing newline and not only if the length of the line is greater than 0.