Add Templates to pretty config
This commit is contained in:
parent
4477c558f2
commit
1fcae4445c
@ -1,11 +1,13 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
b64 "encoding/base64"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"git.badhouseplants.net/softplayer/softplayer-backend/internal/helpers/helm"
|
||||
"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 {
|
||||
for key, val := range app.Data.Config {
|
||||
logrus.Info(key)
|
||||
logrus.Info(val)
|
||||
logrus.Info(cfgSchema)
|
||||
value, ok := cfgSchema[key]
|
||||
if !ok {
|
||||
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{
|
||||
Key: key,
|
||||
Path: value.Path,
|
||||
Value: val,
|
||||
Value: tmplRes.String(),
|
||||
})
|
||||
}
|
||||
} else if len(app.Data.RawConfig) > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user