Skip to content

Commit

Permalink
chore: add template env func for config item
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Mar 12, 2024
1 parent aff0baa commit 44ab7b9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ func (ci ConfigItem) ConfigJSONStringMap() (map[string]any, error) {
return m, err
}

func (ci ConfigItem) TemplateEnv() (map[string]any, error) {
env := ci.AsMap()
if ci.Config == nil {
return env, nil
}
var m map[string]any
if err := json.Unmarshal([]byte(*ci.Config), &m); err != nil {
return env, err
}
env["config"] = m
return env, nil
}

func (c ConfigItem) GetSelectorID() string {
if c.Config == nil || *c.Config == "" {
return ""
Expand Down

0 comments on commit 44ab7b9

Please sign in to comment.