From 8d7759662cef289e8cd07b28e0518254488abc2a Mon Sep 17 00:00:00 2001 From: "David J. M. Karlsen" Date: Fri, 11 Jun 2021 00:58:38 +0200 Subject: [PATCH] add toBool func --- functions.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/functions.go b/functions.go index 57fcec1..e63e930 100644 --- a/functions.go +++ b/functions.go @@ -2,6 +2,7 @@ package sprig import ( "errors" + "github.com/spf13/cast" "html/template" "math/rand" "os" @@ -164,6 +165,7 @@ var genericMap = map[string]interface{}{ // Wrap Atoi to stop errors. "atoi": func(a string) int { i, _ := strconv.Atoi(a); return i }, + "toBool": func(a string) bool { return cast.ToBool(a) }, "int64": toInt64, "int": toInt, "float64": toFloat64, @@ -336,20 +338,20 @@ var genericMap = map[string]interface{}{ "mustChunk": mustChunk, // Crypto: - "bcrypt": bcrypt, - "htpasswd": htpasswd, - "genPrivateKey": generatePrivateKey, - "derivePassword": derivePassword, - "buildCustomCert": buildCustomCertificate, - "genCA": generateCertificateAuthority, - "genCAWithKey": generateCertificateAuthorityWithPEMKey, - "genSelfSignedCert": generateSelfSignedCertificate, + "bcrypt": bcrypt, + "htpasswd": htpasswd, + "genPrivateKey": generatePrivateKey, + "derivePassword": derivePassword, + "buildCustomCert": buildCustomCertificate, + "genCA": generateCertificateAuthority, + "genCAWithKey": generateCertificateAuthorityWithPEMKey, + "genSelfSignedCert": generateSelfSignedCertificate, "genSelfSignedCertWithKey": generateSelfSignedCertificateWithPEMKey, - "genSignedCert": generateSignedCertificate, - "genSignedCertWithKey": generateSignedCertificateWithPEMKey, - "encryptAES": encryptAES, - "decryptAES": decryptAES, - "randBytes": randBytes, + "genSignedCert": generateSignedCertificate, + "genSignedCertWithKey": generateSignedCertificateWithPEMKey, + "encryptAES": encryptAES, + "decryptAES": decryptAES, + "randBytes": randBytes, // UUIDs: "uuidv4": uuidv4,