Skip to content

Commit

Permalink
Merge pull request #7979 from rochacon/fix-ext-core-file-indent
Browse files Browse the repository at this point in the history
Add indent template function and use it to fix KubeDNS.ExternalCoreFile rendering
  • Loading branch information
k8s-ci-robot authored Nov 23, 2019
2 parents d87fcf1 + 9b0d0aa commit 33089f9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ metadata:
data:
Corefile: |
{{- if KubeDNS.ExternalCoreFile }}
{{ KubeDNS.ExternalCoreFile }}
{{ KubeDNS.ExternalCoreFile | indent 4 }}
{{- else }}
.:53 {
errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ metadata:
data:
Corefile: |
{{- if KubeDNS.ExternalCoreFile }}
{{ KubeDNS.ExternalCoreFile }}
{{ KubeDNS.ExternalCoreFile | indent 4 }}
{{- else }}
.:53 {
errors
Expand Down
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ go_library(
"//util/pkg/hashing:go_default_library",
"//util/pkg/reflectutils:go_default_library",
"//util/pkg/vfs:go_default_library",
"//vendor/github.com/Masterminds/sprig:go_default_library",
"//vendor/github.com/blang/semver:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
Expand Down
4 changes: 4 additions & 0 deletions upup/pkg/fi/cloudup/template_functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"strings"
"text/template"

"github.com/Masterminds/sprig"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/klog"
Expand Down Expand Up @@ -78,6 +79,9 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS
return strings.Join(a, sep)
}

sprigTxtFuncMap := sprig.TxtFuncMap()
dest["indent"] = sprigTxtFuncMap["indent"]

dest["ClusterName"] = tf.modelContext.ClusterName
dest["HasTag"] = tf.HasTag
dest["WithDefaultBool"] = func(v *bool, defaultValue bool) bool {
Expand Down

0 comments on commit 33089f9

Please sign in to comment.