habitat-sh / core-plans

Core Habitat Plan definitions
130 stars 252 forks source link

ruby-rails-sample database.yml {{~#if bind.database}} #209

Closed sobakasu closed 8 years ago

sobakasu commented 8 years ago

In the ruby-rails-sample plan, there is a section in config/database.yml that looks like this:

{{~#if bind.has_database}}
{{~#each bind.database.members}}
  host: {{ip}}
  port: {{port}}
{{~/each}}
{{~else}}
  host: {{cfg.database_host}}
  port: {{cfg.database_port}}
{{~/if}}

This differs from the documentation on runtime binding at https://www.habitat.sh/docs/run-packages-binding/, which looks like this:

{{#if bind.database}} {{#with bind.database.members}} host: {{ip}}{{/with}} {{/if}}

(one uses ~#if bind.has_database, the other #if bind.database in the #if clause, and one has ~#each and the other has #with)

Also, i'm not sure about this but I have tried {{~#if bind.has_database}}, and {{~#if bind.database}}, but my service does not include host: and port: lines in database.yml. So the else clause is not evaluating when I have no bindings set up

sobakasu commented 8 years ago

after further investigation, it looks like {{~else}} doesn't work. i'm using hab 0.10.2/20160930230245

it should be {{else}} (found correct usage in the kibana plan) The documentation does not mention the else clause syntax

reset commented 8 years ago

@sobakasu thanks for finding this one! As you mentioned, {{else}} is the correct directive. We use Handlebars and anything our documentation doesn't cover you can find there. We'll get this fixed up.