Skip to content

Commit

Permalink
added event watch lwrp
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Fode committed Nov 6, 2014
1 parent d6fb75f commit a856108
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ Include `consul::ui` in your node's `run_list`:

### LWRP

##### Adding event watch
consul_event_watch_def 'event-name' do
handler "chef-client"
end

##### Adding service without check
consul_service_def 'voice1' do
port 5060
Expand Down
3 changes: 2 additions & 1 deletion resources/event_watch_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ def to_hash
type: "event"
}
hash[:name] = name
hash[:handler] = handler
hash[:handler] = handler unless handler.nil?
hash
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include_recipe "consul"
consul_event_watch_def "dummy" do
script "chef-client"
handler "chef-client"
end
3 changes: 1 addition & 2 deletions spec/unit/resources/event_watch_def.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let(:example_recipe) { "consul_spec::event_watch_create" }

it "register the service" do
['"name": "dummy"', '"type": event',
['"name": "dummy"', '"type": "event"',
'"handler": "chef-client"'].each do |content|
expect(chef_run).to render_file(service_def_path)
.with_content(content)
Expand All @@ -22,7 +22,6 @@
it "de-register the service" do
expect(chef_run).to delete_file(service_def_path)
expect(chef_run.file(service_def_path))
.to notify('service[consul]').to(:reload).delayed
end
end
end

0 comments on commit a856108

Please sign in to comment.