Commit 5f85787c
5f85787c0671Merged
Svyatoslav Dumchenko <[email protected]> · 5 years ago · 4 files · ~4 modified
Description
tune config for gomplate datasources
Details
- Commit
- 5f85787c0671
- Parent
- 3eb569e74e3d
pkg/template/config.gomodifiedView file
@@ -1,6 +1,8 @@
11
package template22
33
import (4+
"net/url"5+
46
"github.com/hairyhenderson/gomplate/v3/data"57
)68
@@ -9,12 +11,55 @@
911
}1012
1113
type GomplateConfig struct {12-
Data *data.Data13-
Enabled bool14+
Datasources map[string]Source15+
data *data.Data16+
Enabled bool1417
}1518
19+
type Source struct {20+
URL *url.URL21+
}22+
23+
func (s *Source) UnmarshalYAML(unmarshal func(v interface{}) error) error {24+
type raw struct {25+
URL string26+
}27+
28+
r := raw{}29+
err := unmarshal(&r)30+
if err != nil {31+
return err32+
}33+
34+
u, err := url.Parse(r.URL)35+
if err != nil {36+
return err37+
}38+
39+
*s = Source{40+
URL: u,41+
}42+
return nil43+
}44+
1645
var cfg *Config1746
1847
func SetConfig(config *Config) {1948
cfg = config49+
50+
if cfg == nil {51+
return52+
}53+
54+
sources := map[string]*data.Source{}55+
for k, v := range cfg.Gomplate.Datasources {56+
sources[k] = &data.Source{57+
Alias: k,58+
URL: v.URL,59+
}60+
}61+
62+
cfg.Gomplate.data = &data.Data{63+
Sources: sources,64+
}2065
}pkg/template/func.gomodifiedView file
Loading diff…
tests/08_helmwave.ymlmodifiedView file
Loading diff…
tests/08_values.yamlmodifiedView file
Loading diff…