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

can't get key /something/with_an_underscore from env backend #531

Closed
bvdeenen opened this issue Feb 15, 2017 · 3 comments
Closed

can't get key /something/with_an_underscore from env backend #531

bvdeenen opened this issue Feb 15, 2017 · 3 comments

Comments

@bvdeenen
Copy link

I have a key defined as /kafka/broker_id/host1 and I can't find a way to set it from the env backend.
Is there no way ?
I've tried export KAFKA_BROKER_ID_KAFKA1=... but I get (with -log-level debug)

confd[98]: DEBUG Key Map: map[string]string{"/kafka/broker/id/kafka1":"5"}
confd[98]: DEBUG Using source template /etc/confd/templates/server.properties.tmpl
confd[98]: DEBUG Compiling source template /etc/confd/templates/server.properties.tmpl
confd[98]: ERROR template: server.properties.tmpl:24:13: executing "server.properties.tmpl" at <getv (print "/kafka/...>: error calling getv: key does not exist: /kafka/broker_id/kafka1

Is there a workaround, apart from removing the underscores in my keys?

@HeavyHorst
Copy link
Contributor

For the env backend every _ is replaced with an / at the moment. Your key is /kafka/broker/id/kafka1.
There is no way to treat the _ not as a path separator.

@stela
Copy link

stela commented Jun 2, 2017

This bit me too, I have an existing docker image with which works together with the consul backend, containing
{{getv "/xmpp_domain"}}
Now I'd like to use the "env" backend (for a kubernetes environment) instead, but the same docker image.
Prefix-matching is done against XMPP_DOMAIN which is the name of my environment variable. However, before returning the configuration mappings, the key is converted to /xmpp/domain which later on causes errors: ... error calling getv: key does not exist: /xmpp_domain

When you request for a key containing an underscore, that's probably what you want the backend to return. What would happen if you modified env/client.go like this:

			if strings.HasPrefix(envKey, k) {
				envPostfix := envKey[len(k):]
				vars[key + clean(envPostfix)] = envValue
			}

instead of
vars[clean(envKey)] = envValue?

At last the integration tests in integration/env/test.sh still pass after that change.

Update: above isn't quite correct, keys returned have trailing/intermediate slashes, I'll try to make a proper pull request for this...

@stela
Copy link

stela commented Jun 2, 2017

Posted pull request #567, let me know what you think about it.

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

No branches or pull requests

4 participants