Add Templates to pretty config
This commit is contained in:
parent
4477c558f2
commit
1fcae4445c
@ -1,11 +1,13 @@
|
|||||||
package controllers
|
package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
b64 "encoding/base64"
|
b64 "encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"text/template"
|
||||||
|
|
||||||
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/helm"
|
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/helm"
|
||||||
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/kube"
|
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/kube"
|
||||||
@ -109,17 +111,23 @@ func (app *Application) Create(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
if len(app.Data.Config) > 0 {
|
if len(app.Data.Config) > 0 {
|
||||||
for key, val := range app.Data.Config {
|
for key, val := range app.Data.Config {
|
||||||
logrus.Info(key)
|
|
||||||
logrus.Info(val)
|
|
||||||
logrus.Info(cfgSchema)
|
|
||||||
value, ok := cfgSchema[key]
|
value, ok := cfgSchema[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("unsuported config entry: %s", key)
|
return fmt.Errorf("unsuported config entry: %s", key)
|
||||||
}
|
}
|
||||||
|
tmpl, err := template.New("prettyconfig").Parse(val)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
var tmplRes bytes.Buffer
|
||||||
|
if err := tmpl.Execute(&tmplRes, tmpl); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
cfg.Config.Pretty = append(cfg.Config.Pretty, helmrelease.PrettyConfig{
|
cfg.Config.Pretty = append(cfg.Config.Pretty, helmrelease.PrettyConfig{
|
||||||
Key: key,
|
Key: key,
|
||||||
Path: value.Path,
|
Path: value.Path,
|
||||||
Value: val,
|
Value: tmplRes.String(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else if len(app.Data.RawConfig) > 0 {
|
} else if len(app.Data.RawConfig) > 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user