Helmfile: readFile reads only first line

Created on 29 Jun 2019  路  7Comments  路  Source: roboll/helmfile

Hi,

I have the following folder structure for openldap:
image

in common.yaml.gotmpl I have the following lines:

customLdifFiles:
    init.ldif: |
        {{ readFile "../files/ldif/init.ldif" }}

Content of init.ldif is:

dn: ou=groups,dc=example,dc=app
changetype: add
objectClass: top
objectClass: organizationalUnit
ou: groups

... and so on

Everything looks ok until I apply my helmfile:
(below is partial output of helmfile apply)

apiVersion: v1
  kind: ConfigMap
  metadata:
    name: openldap-customldif
    labels:
      app: openldap
      chart: openldap-1.1.0
      release: openldap
      heritage: Tiller
  data:
    init.ldif: |-
+     dn: ou=groups,dc=example,dc=app
identified at least one change, exiting with non-zero exit code (detailed-exitcode parameter enabled)

As you can see, all the lines except first one of file are omitted and ignored.
Why it could happen? Is it bug? Is there any another way to read file and make it part of values?

question

Most helpful comment

Closing this as answered. But please feel free to reopen if necessary!

All 7 comments

Found workaround solution ... Looks ugly, but works

      set:
          - name: "customLdifFiles.init\\.ldif"
            file: files/ldif/init.ldif

Same for sonar:

          - name: "sonarProperties.sonar\\.auth\\.oidc\\.providerConfiguration"
            file: files/openid_provider.json

Can we load it and pass as string to template to make it further-processaible by tpl function?

Seems, that readFile reads file content as Go map structure ...

sonar.auth.oidc.providerConfiguration=map[authorization_endpoint:https://keycloak.cicd.example.app/auth/realms/master/protocol/openid-connect/auth ... and so on

In documentation said readFile reads the specified local file and generate a golang string. There is defect ...

{{ exec "sh" (list "-c" "cat ../files/openid_provider.json") }} also returns content as Go structure. What is wrong?

Seems, that readFile reads file content as Go map structure ...

Nope. It actually reads the file as text!

customLdifFiles:
    init.ldif: |
        {{ readFile "../files/ldif/init.ldif" }}

this results in:

customLdifFiles:
    init.ldif: |
        dn: ou=groups,dc=example,dc=app
changetype: add
objectClass: top
objectClass: organizationalUnit
ou: groups

... and so on

Try

customLdifFiles:
  init.ldif: |
{{ readFile "../files/ldif/init.ldif" | indent 4 }}

I prefer 2-spaces per indentation level so init.ldif has 2-spaces and {{ readFile must have the 2 more spaces before it. That's why I added indent 4. Tweak it according to your preference tho.

Closing this as answered. But please feel free to reopen if necessary!

Thanks, correct indentation solved the problem

Glad it worked 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

machine424 picture machine424  路  3Comments

michaelpporter picture michaelpporter  路  3Comments

GoldenMouse picture GoldenMouse  路  3Comments

madAndroid picture madAndroid  路  3Comments

willejs picture willejs  路  4Comments