feat(dir2config): defaults
This commit is contained in:
@ -14,7 +14,9 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
dir = flag.String("in", ".", "Source directory")
|
||||
dir = flag.String("in", ".", "Source directory")
|
||||
outPath = flag.String("out", "config.yaml", "Output file")
|
||||
defaultsPath = flag.String("defaults", "defaults", "Path to the defaults")
|
||||
|
||||
src *clustersconfig.Config
|
||||
dst *localconfig.Config
|
||||
@ -22,15 +24,13 @@ var (
|
||||
|
||||
func loadSrc() {
|
||||
var err error
|
||||
|
||||
src, err = clustersconfig.FromDir(*dir)
|
||||
src, err = clustersconfig.FromDir(*dir, *defaultsPath)
|
||||
if err != nil {
|
||||
log.Fatal("failed to load config from dir: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
outPath := flag.String("out", "config.yaml", "Output file")
|
||||
flag.Parse()
|
||||
|
||||
loadSrc()
|
||||
|
@ -81,7 +81,12 @@ func (ctx *renderContext) Config() string {
|
||||
|
||||
extraFuncs := ctx.templateFuncs(ctxMap)
|
||||
|
||||
extraFuncs["static_pods"] = func(name string) (string, error) {
|
||||
extraFuncs["static_pods"] = func() (string, error) {
|
||||
name := ctx.Group.StaticPods
|
||||
if len(name) == 0 {
|
||||
return "", fmt.Errorf("group %q has no static pods defined", ctx.Group.Name)
|
||||
}
|
||||
|
||||
t := ctx.clusterConfig.StaticPodsTemplate(name)
|
||||
if t == nil {
|
||||
return "", fmt.Errorf("no static pods template named %q", name)
|
||||
|
Reference in New Issue
Block a user