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

[Feature Request] {{if isvalue "/key" "value"}} {{if containsvalue "/key/*" "value"}} #469

Closed
blaggacao opened this issue Jul 30, 2016 · 1 comment

Comments

@blaggacao
Copy link

blaggacao commented Jul 30, 2016

Situation:
Deploying host-specific config scripts for example for a metric gatherer, I'd like to make some code conditional on a flag's value. Well, querying it's existence is already possible with {{if exists}}, yet this feels somewhat incomplete.

Take:

  • Rancher Server
  • Service Type Labels: io.rancher.appname=nginx , io.rancher.appname=postgres

Want:

  • conditional deploy of a metrics gatherer like:
{{ if containsvalue "/self/host/containers/*/services/*/labels/io.rancher.appname" "postgres"}}
# Read metrics from one or many postgresql servers
[[inputs.postgresql]]
  address = "host=localhost user= password= sslmode=disable dbname="
  # databases = ["app_production", "testing"]
{{ end }}
@okushchenko
Copy link
Collaborator

You can use builtin conditionals from Go text/template, e.g.

{{ if (eq (getv "/key") "value") }}
exists
{{ end }}

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

No branches or pull requests

3 participants