@@ -16,14 +16,15 @@ limitations under the License.
1616package controllers
1717
1818import (
19- "cdap.io/cdap-operator/controllers/cdapmaster"
2019 "fmt"
21- batchv1 "k8s.io/api/batch/v1"
22- "sigs.k8s.io/controller-reconciler/pkg/finalizer"
2320 "strconv"
2421 "strings"
2522 "text/template"
2623
24+ "cdap.io/cdap-operator/controllers/cdapmaster"
25+ batchv1 "k8s.io/api/batch/v1"
26+ "sigs.k8s.io/controller-reconciler/pkg/finalizer"
27+
2728 "github.com/go-logr/logr"
2829 "k8s.io/apimachinery/pkg/runtime"
2930 gr "sigs.k8s.io/controller-reconciler/pkg/genericreconciler"
@@ -165,12 +166,19 @@ func (h *ConfigMapHandler) Objects(rsrc interface{}, rsrclabels map[string]strin
165166 }
166167
167168 fillTemplate := func (templateFile string ) (string , error ) {
168- template , err := template .New (templateFile ).ParseFiles (templateDir + templateFile )
169+ tmpl , err := template .New (templateFile ).Funcs (template.FuncMap {
170+ "hasPrefix" : func (str , prefix string ) bool {
171+ return strings .HasPrefix (str , prefix )
172+ },
173+ "trimPrefix" : func (str , prefix string ) string {
174+ return strings .TrimPrefix (str , prefix )
175+ },
176+ }).ParseFiles (templateDir + templateFile )
169177 if err != nil {
170178 return "" , err
171179 }
172180 var output strings.Builder
173- if err := template .Execute (& output , templateData ); err != nil {
181+ if err := tmpl .Execute (& output , templateData ); err != nil {
174182 return "" , err
175183 }
176184 return output .String (), nil
0 commit comments