-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update build to use 1.18+ to add template support for continue
and break
#1663
Comments
Thanks for the report @jrwren! That is a very weird one. Not sure how the builtin continue can't be found but I'll look into it as soon as I can. |
I tried reproducing this real quick with the script below with some test service definitions I had around and couldn't ( #!/bin/sh
cat > foo.tmpl << EOF
{{ range services }}
{{ .Name }}
{{ if .Name | contains "api" | not }}
{{ continue }}
{{ end }}
{{ range service .Name }}
{{ . }}
{{ end }}
{{ end }}
EOF
consul-template \
-template "foo.tmpl:foo" \
-log-level trace \
-exec "cat foo" \
-once |
This makes no sense! I'm using consul-tempate 0.29.5 as downloaded from https://releases.hashicorp.com/consul-template/0.29.5/consul-template_0.29.5_linux_amd64.zip earlier today I just copied and pasted your foo.tmpl shell example and I get this:
I just tried it with another consul server with the same results. I'm running on The same thing happens in a 20.04 container. I can't imagine what would cause this. |
JFYI, I did it again on an entirely different consul cluster and with the same results. |
Got it! I'm running a local build that is using Go 1.19. The v0.29.5 release was built with Go 1.17. Text templates added support for continue/break in Go 1.18. So they are not supported in the current released version but will be in the next. You can compile it locally with 1.18+ and get the functionality or wait for our next release (no firm timeline for this ATM). I'm going to leave this open for now as a general feature request to get a release out with support for these new keywords. |
continue
and break
Note that the Go version has been updated to 1.19 and will be included in the next release. |
Consul Template version
consul-template v0.29.5 (f07ce88)
Configuration
wtf.tmpl:
Command
Debug output
Provide a link to a GitHub Gist containing the complete debug
output by running with
-log-level=trace
.It is short, I'm putting it here:
Expected behavior
What should have happened?
I should be able to use {{continue}} as defined in https://pkg.go.dev/text/template#hdr-Actions
Actual behavior
What actually happened?
I got an error that continue is not defined.
Steps to reproduce
The text was updated successfully, but these errors were encountered: