Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #19 from 2opremio/fix-configmap-template
Browse files Browse the repository at this point in the history
Fix TLS CA configmap template
  • Loading branch information
2opremio authored Aug 13, 2019
2 parents f21b6bd + 072c9ce commit 0c769f5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
14 changes: 7 additions & 7 deletions pkg/install/generated_templates.gogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 9 additions & 4 deletions pkg/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package install

import (
"bytes"
"encoding/base64"
"fmt"
"io"
"io/ioutil"
Expand All @@ -18,7 +17,7 @@ type TemplateParameters struct {
TillerNamespace string
SSHSecretName string
EnableTillerTLS bool
TillerTLSCACertContent []byte
TillerTLSCACertContent string
TillerTLSCertSecretName string
}

Expand All @@ -35,9 +34,15 @@ func FillInTemplates(params TemplateParameters) (map[string][]byte, error) {
if err != nil {
return fmt.Errorf("cannot read embedded file %q: %s", info.Name(), err)
}

indent := func(n int, s string) string {
lines := strings.Split(s, "\n")
for i, l := range lines {
lines[i] = strings.Repeat(" ", n) + l
}
return strings.Join(lines, "\n")
}
manifestTemplate, err := template.New(info.Name()).
Funcs(template.FuncMap{"Base64Encode": base64.StdEncoding.EncodeToString}).
Funcs(template.FuncMap{"indent": indent}).
Parse(string(manifestTemplateBytes))
if err != nil {
return fmt.Errorf("cannot parse embedded file %q: %s", info.Name(), err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/install/install_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestFillInTemplates(t *testing.T) {
TillerNamespace: "tiller",
SSHSecretName: "mysshsecretname",
EnableTillerTLS: true,
TillerTLSCACertContent: []byte("foo bar"),
TillerTLSCACertContent: "foo\nbar\n",
TillerTLSCertSecretName: "mytlssecretname",
}, 4)
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/install/templates/tiller-ca-cert-configmap.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: flux-helm-tls-ca-config
{{ if .Namespace }}
name: flux-helm-tls-ca-config{{ if .Namespace }}
namespace: {{ .Namespace }}{{ end }}
data:
ca.crt: |
{{ Base64Encode .TillerTLSCACertContent }}
{{- end -}}
{{ indent 4 .TillerTLSCACertContent }}{{ end }}

0 comments on commit 0c769f5

Please sign in to comment.