Skip to content

Commit

Permalink
Switching default implementations to Sprig
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycub committed Nov 9, 2020
1 parent 625dae0 commit d7d7707
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.DS_Store

# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
Expand All @@ -10,6 +12,7 @@ dist/

# Build output directory.
/bin
/pkg

# Architecture specific extensions/prefixes
*.[568vq]
Expand All @@ -31,4 +34,4 @@ _testmain.go
levant-local

.idea
vendor/*/.hg/*
vendor/*/.hg/*
19 changes: 10 additions & 9 deletions template/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,17 @@ func funcMap(consulClient *consul.Client) template.FuncMap {
}
// Add the Sprig functions to the funcmap
for k, v := range sprig.FuncMap() {
// Decorate all of the function names from the sprig library.
if name, err := firstRuneToUpper(k); err == nil {
functionName := "sprig" + name
// Would like to have some sort of trace level event for
// adding these functions.
// println(fmt.Sprintf("adding \"%v\".", functionName))
r[functionName] = v
} else {
log.Error().Msgf("template/funcs: could not add \"%v\" function. error:%v", k, err)
// if there is a name conflict, favor sprig and rename original version
if origFun, ok := r[k]; ok {
if name, err := firstRuneToUpper(k); err == nil {
name = "levant" + name
log.Debug().Msgf("template/funcs: renaming \"%v\" function to \"%v\"", k, name)
r[name] = origFun
} else {
log.Error().Msgf("template/funcs: could not add \"%v\" function. error:%v", k, err)
}
}
r[k] = v
}
r["sprigVersion"] = sprigVersionFunc

Expand Down

0 comments on commit d7d7707

Please sign in to comment.