janeczku / go-rancher-gen

:cow: Generate configuration files using templates and Rancher Metadata
MIT License
32 stars 4 forks source link

provide build with Go >= 1.6 #3

Open leoschweizer opened 7 years ago

leoschweizer commented 7 years ago

First of all, let me say thanks for this project, it is much appreciated.

I don't know much about go, but it looks like whitespace suppression in Go text templates ({{- and -}}) became available with Go 1.6, and the provided build of rancher-gen is based on Go 1.5. So currently I don't see a possibility to not generate a lot of useless whitspace and blank newlines while keeping a sound structure in my templates.

Consider something like

{{range $service := services}}
{{range $container := .Containers}}
{{if $container.Labels.Exists "foo"}}
bar
{{end}}
{{end}}
{{end}}

This would create 6 empty lines for each container in an environment where the foo label is not present, which is not very nice at all.

Would it be feasible for you to provide a build / docker image wich is built with at least Go 1.6?