sous-chefs / consul

Development repository for the consul cookbook

Home Page:https://supermarket.chef.io/cookbooks/consul

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consul_definition doesn't allow lazy evaluation

jescholl opened this issue · comments

consul_definition serializes to JSON, then writes the serialized content out with a file resource's content attribute. The serialization process makes it impossible to use chef's lazy evaluator within the parameters.

Here is a simple example.

consul_definition "test" do
  type "service"
  parameters tags: 'testing123'
end

results in a config file like this.

{
  "service": {
    "tags": "testing123",
    "name": "test"
  }
}

If, however you try to use the lazy evaluator...

consul_definition "test" do
  type "service"
  parameters tags: lazy { 'testing123' }
end

the lazy evaluator gets serialized instead of called.

{
  "service": {
    "tags": "#<Chef::DelayedEvaluator:0x000000058b7040@/var/chef/cache/cookbooks/test/recipes/default.rb:3>",
    "name": "test"
  }
}

I'm currently creating the files through templates directly, but it would be nice to have lazy evaluation available.

Closing due to inactivity.

If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help!

Thanks,
Sous-Chefs

commented

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.