tazjin/kontemplate

Help me to beat my issue

alter opened this issue · 1 comments

alter commented

Hello,
I've a situation with dockerconfig, it's a base64 config, which already include base64 string:
full config: "ewogICJhdXRocyI6ewogICAgInJlZ2lzdHJ5LmV4YW1wbGUuY29tIjp7CiAgICAgICAidXNlcm5hbWUiOiJ1c2VyIiwKICAgICAgICJwYXNzd29yZCI6InBhc3N3b3JkIiwKICAgICAgICJlbWFpbCI6ImFkbWluQGV4YW1wbGUuY29tIiwKICAgICAgICJhdXRoIjoiZFhObGNqcHdZWE56ZDI5eVpBPT0iCiAgICB9CiB9Cn0K"
decoded:

{
  "auths":{
    "registry.example.com":{
       "username":"user",
       "password":"password",
       "email":"admin@example.com",
       "auth":"dXNlcjpwYXNzd29yZA=="
    }
 }
}

where auth is: "user:password" in base64

I've created vars.yaml:

context: Vostok-dev
global:
  NAMESPACE: testme
  USER: "user"
  PASS: "password"
include:
  - name: ns
  - name: secrets
    values:
      dockerconfigjson: |
        {
          "auths":{
            "registry.vostokservices.com":{
               "username":"{{ .USER }}",
               "password":"{{ .PASS }}",
               "email":"admin@wavesplatform.com",
               "auth": "{{ .USER:.PASS | b64enc }}"
            }
         }
        }

and secret.yaml:

apiVersion: v1
kind: Secret
metadata:
  name: regcred
  namespace: {{ .NAMESPACE }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ .dockerconfigjson | b64enc }}

but as result base64 I've a string "{{ .USER }}" instead of value of variable USER "user".

Hmm, the exact thing you're trying to do is unsupported. There is no support for interpolating variables inside of value specs (i.e. there is no "template recursion", if you will). One way to do this might be to use insertTemplate.

Please note that the source of kontemplate has moved to git.tazj.in and issues / patches should now be emailed to depot@tazj.in. For that reason I am closing this issue.