Skip to content
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

Error parsing CONSUL_HTTP_ADDR address #1209

Closed
cofiem opened this issue Sep 14, 2021 · 1 comment · Fixed by #1210
Closed

Error parsing CONSUL_HTTP_ADDR address #1209

cofiem opened this issue Sep 14, 2021 · 1 comment · Fixed by #1210
Labels

Comments

@cofiem
Copy link

cofiem commented Sep 14, 2021

gomplate version: 3.9.0

Expected:

Running this command should successfully render the template.

env var: CONSUL_HTTP_ADDR=127.0.0.1:8501 (which is valid as per consul docs)

gomplate -d consul=consul+https://localhost:8501/foo -i '{{ ds "consul" }}'

Actual:

Fails with error:

ERR error="template: :1:3: executing "" at <ds "consul">: error calling ds: Couldn't read datasource 'consul': invalid URL '127.0.0.1:8501' in CONSUL_HTTP_ADDR: parse "127.0.0.1:8501": first path segment in URL cannot contain colon"

Additional info

This looks like it is due to url.Parse treating 127.0.0.1:8501 as a relative url at line 82 in consul.go.
This might be an instance of this issue.

Is there a suggested workaround /fix for this? I guess the most obvious is to add the optional scheme to the CONSUL_HTTP_ADDR env var?

@hairyhenderson
Copy link
Owner

Hmm... The gomplate docs implies that environment variable is a URL, I'm not sure I was aware that the consul package also understood that env var!

What's also concerning to me is that it looks like you're specifying the consul server address in both the env var and on the -d flag, and gomplate should use the -d value rather than the env var.

So there are two bugs here unfortunately. I'll take a look at these soon. FYI I'm gearing up to release gomplate 3.10.0 soon, and I'll make sure to get this fixed in that release 😉

As for workaround - you should be able to simply omit CONSUL_HTTP_ADDR entirely. Or setting the schema on CONSUL_HTTP_ADDR as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants