_createData.tpl 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. {{/* Configmap Validation */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.imagePullSecret.createData" (dict "objectData" $objectData "root" $rootCtx) -}}
  4. rootCtx: The root context of the chart.
  5. objectData:
  6. data: The data of the imagePullSecret.
  7. */}}
  8. {{- define "ix.v1.common.lib.imagePullSecret.createData" -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $rootCtx := .rootCtx -}}
  11. {{- $registrySecret := dict -}}
  12. {{/* Auth is b64encoded and then the whole secret is b64encoded */}}
  13. {{- $auth := printf "%s:%s" (tpl $objectData.data.username $rootCtx) (tpl $objectData.data.password $rootCtx) | b64enc -}}
  14. {{- $registry := dict -}}
  15. {{- with $objectData.data -}}
  16. {{- $registry = (dict "username" (tpl .username $rootCtx) "password" (tpl .password $rootCtx)
  17. "email" (tpl .email $rootCtx) "auth" $auth) -}}
  18. {{- end -}}
  19. {{- $_ := set $registrySecret "auths" (dict "registry" $registry) -}}
  20. {{/*
  21. This should result in something like this:
  22. {
  23. "auths": {
  24. "$registry": {
  25. "username": "$username",
  26. "password": "$password",
  27. "email": "$email",
  28. "auth": "($username:$password) base64"
  29. }
  30. }
  31. }
  32. */}}
  33. {{/* Return the registrySecret as Json */}}
  34. {{- $registrySecret | toJson -}}
  35. {{- end -}}