github.com/argoproj/argo-cd@v1.8.7/test/e2e/fixture/tmpl.go (about)

     1  package fixture
     2  
     3  import (
     4  	"bytes"
     5  	"regexp"
     6  	"strings"
     7  	"text/template"
     8  
     9  	. "github.com/argoproj/argo-cd/util/errors"
    10  )
    11  
    12  // utility method to template a string using a map
    13  func Tmpl(text string, values interface{}) string {
    14  	parse, err := template.New(text).Parse(text)
    15  	CheckError(err)
    16  	buf := new(bytes.Buffer)
    17  	err = parse.Execute(buf, values)
    18  	CheckError(err)
    19  	return buf.String()
    20  }
    21  
    22  // utility method to deal with white-space
    23  func NormalizeOutput(text string) string {
    24  	return regexp.MustCompile(` +`).
    25  		ReplaceAllString(strings.TrimSpace(text), " ")
    26  }