fix: cache ttl interpolation
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
All checks were successful
Cadoles/bouncer/pipeline/head This commit looks good
This commit is contained in:
@ -19,7 +19,7 @@ func (is *InterpolatedString) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
str, err := envsubst.EvalEnv(str)
|
||||
str, err := envsubst.Eval(str, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -38,7 +38,7 @@ func (ii *InterpolatedInt) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.Wrapf(err, "could not decode value '%v' (line '%d') into string", value.Value, value.Line)
|
||||
}
|
||||
|
||||
str, err := envsubst.EvalEnv(str)
|
||||
str, err := envsubst.Eval(str, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -62,7 +62,7 @@ func (ifl *InterpolatedFloat) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.Wrapf(err, "could not decode value '%v' (line '%d') into string", value.Value, value.Line)
|
||||
}
|
||||
|
||||
str, err := envsubst.EvalEnv(str)
|
||||
str, err := envsubst.Eval(str, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -86,7 +86,7 @@ func (ib *InterpolatedBool) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.Wrapf(err, "could not decode value '%v' (line '%d') into string", value.Value, value.Line)
|
||||
}
|
||||
|
||||
str, err := envsubst.EvalEnv(str)
|
||||
str, err := envsubst.Eval(str, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -101,9 +101,10 @@ func (ib *InterpolatedBool) UnmarshalYAML(value *yaml.Node) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var getEnv = os.Getenv
|
||||
|
||||
type InterpolatedMap struct {
|
||||
Data map[string]any
|
||||
getEnv func(string) string
|
||||
Data map[string]any
|
||||
}
|
||||
|
||||
func (im *InterpolatedMap) UnmarshalYAML(value *yaml.Node) error {
|
||||
@ -113,10 +114,6 @@ func (im *InterpolatedMap) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.Wrapf(err, "could not decode value '%v' (line '%d') into map", value.Value, value.Line)
|
||||
}
|
||||
|
||||
if im.getEnv == nil {
|
||||
im.getEnv = os.Getenv
|
||||
}
|
||||
|
||||
interpolated, err := im.interpolateRecursive(data)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
@ -140,7 +137,7 @@ func (im InterpolatedMap) interpolateRecursive(data any) (any, error) {
|
||||
}
|
||||
|
||||
case string:
|
||||
value, err := envsubst.Eval(typ, im.getEnv)
|
||||
value, err := envsubst.Eval(typ, getEnv)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
@ -171,7 +168,7 @@ func (iss *InterpolatedStringSlice) UnmarshalYAML(value *yaml.Node) error {
|
||||
}
|
||||
|
||||
for index, value := range data {
|
||||
value, err := envsubst.EvalEnv(value)
|
||||
value, err := envsubst.Eval(value, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
@ -193,7 +190,7 @@ func (id *InterpolatedDuration) UnmarshalYAML(value *yaml.Node) error {
|
||||
return errors.Wrapf(err, "could not decode value '%v' (line '%d') into string", value.Value, value.Line)
|
||||
}
|
||||
|
||||
str, err := envsubst.EvalEnv(str)
|
||||
str, err := envsubst.Eval(str, getEnv)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user