sous-chefs / consul

Development repository for the consul cookbook
https://supermarket.chef.io/cookbooks/consul
Apache License 2.0
192 stars 244 forks source link

consul_definition doesn't allow lazy evaluation #483

Closed jescholl closed 5 years ago

jescholl commented 6 years ago

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"
  }
}
quulah commented 6 years ago

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

damacus commented 5 years ago

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

lock[bot] commented 4 years ago

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.