github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/atc/creds/eval.go (about) 1 package creds 2 3 import ( 4 "encoding/json" 5 6 "github.com/pf-qiu/concourse/v6/vars" 7 "sigs.k8s.io/yaml" 8 ) 9 10 func evaluate(variablesResolver vars.Variables, in, out interface{}) error { 11 byteParams, err := json.Marshal(in) 12 if err != nil { 13 return err 14 } 15 16 tpl := vars.NewTemplate(byteParams) 17 18 bytes, err := tpl.Evaluate(variablesResolver, vars.EvaluateOpts{ 19 ExpectAllKeys: true, 20 }) 21 if err != nil { 22 return err 23 } 24 25 return yaml.Unmarshal(bytes, out) 26 }