diff --git a/libraries/consul_watch.rb b/libraries/consul_watch.rb index 1be9192e..b7e3231a 100644 --- a/libraries/consul_watch.rb +++ b/libraries/consul_watch.rb @@ -35,7 +35,7 @@ class ConsulWatch < Chef::Resource attribute(:parameters, option_collector: true, default: {}) def to_json - JSON.pretty_generate({ type: type }.merge(parameters)) + JSON.pretty_generate(watches: [{ type: type }.merge(parameters)]) end action(:create) do diff --git a/test/spec/libraries/consul_watch_spec.rb b/test/spec/libraries/consul_watch_spec.rb index 5aeaba8a..b68f885c 100644 --- a/test/spec/libraries/consul_watch_spec.rb +++ b/test/spec/libraries/consul_watch_spec.rb @@ -19,9 +19,13 @@ .with(user: 'consul', group: 'consul', mode: '0640') .with(content: JSON.pretty_generate( { - type: 'key', - key: 'foo/bar/baz', - handler: '/bin/false' + watches: [ + { + type: 'key', + key: 'foo/bar/baz', + handler: '/bin/false' + } + ] } )) end