fix per-host scope
This commit is contained in:
@ -54,7 +54,6 @@ func main() {
|
||||
|
||||
log.Print("rendering host ", host.Name)
|
||||
ctx, err := newRenderContext(host, src)
|
||||
log.Printf(" ctx: %p", ctx)
|
||||
|
||||
if err != nil {
|
||||
log.Fatal("failed to create render context for host ", host.Name, ": ", err)
|
||||
|
@ -23,7 +23,6 @@ type renderContext struct {
|
||||
|
||||
func newRenderContext(host *clustersconfig.Host, cfg *clustersconfig.Config) (ctx *renderContext, err error) {
|
||||
cluster := cfg.Cluster(host.Cluster)
|
||||
log.Printf("===> newRenderContext: cluster: %v", cluster.Name)
|
||||
if cluster == nil {
|
||||
err = fmt.Errorf("no cluster named %q", host.Cluster)
|
||||
return
|
||||
@ -69,7 +68,6 @@ func (ctx *renderContext) Config() string {
|
||||
templateFuncs := ctx.templateFuncs(ctxMap)
|
||||
|
||||
render := func(what string, t *clustersconfig.Template) (s string, err error) {
|
||||
log.Printf("render %q %p", what, t)
|
||||
buf := &bytes.Buffer{}
|
||||
err = t.Execute(buf, ctxMap, templateFuncs)
|
||||
if err != nil {
|
||||
@ -120,8 +118,6 @@ func (ctx *renderContext) templateFuncs(ctxMap map[string]interface{}) map[strin
|
||||
cluster := ctx.Cluster.Name
|
||||
|
||||
getKeyCert := func(name, funcName string) (s string, err error) {
|
||||
log.Print("=====> getKeyCert ", funcName, ": cluster: ", cluster)
|
||||
|
||||
req := ctx.clusterConfig.CSR(name)
|
||||
if req == nil {
|
||||
err = fmt.Errorf("no certificate request named %q", name)
|
||||
@ -139,6 +135,10 @@ func (ctx *renderContext) templateFuncs(ctxMap map[string]interface{}) map[strin
|
||||
return
|
||||
}
|
||||
|
||||
if req.PerHost {
|
||||
name = name + "/" + ctx.Host.Name
|
||||
}
|
||||
|
||||
s = fmt.Sprintf("{{ %s %q %q %q %q %q %q }}", funcName,
|
||||
cluster, req.CA, name, req.Profile, req.Label, buf.String())
|
||||
return
|
||||
@ -173,7 +173,6 @@ func (ctx *renderContext) templateFuncs(ctxMap map[string]interface{}) map[strin
|
||||
},
|
||||
|
||||
"tls_dir": func(name string) (s string, err error) {
|
||||
log.Printf(" CTX: %p", ctx)
|
||||
return getKeyCert(name, "tls_dir")
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user