Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix subscription recompilation every run #42

Merged
merged 1 commit into from
Mar 8, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/puppet/provider/sensu_client_subscription/json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(*args)
super

begin
@conf = {'client' => { 'subscriptions' => JSON.parse(File.read("/etc/sensu/conf.d/subscription_#{resource[:name]}.json")) } }
@conf = JSON.parse(File.read("/etc/sensu/conf.d/subscription_#{resource[:name]}.json"))
rescue
@conf = {}
end
Expand All @@ -28,19 +28,16 @@ def destroy
@conf = nil
end

def exists?
@conf.has_key? 'subscription'
end

def subscriptions
@conf['client']['subscriptions']
end

def subscriptions=(value)
@conf['client']['subscriptions'] = value
munge do |value|
Array(value)
end
end

def exists?
@conf.has_key?('client') && @conf['client'].has_key?('subscriptions')
end
end

7 changes: 5 additions & 2 deletions lib/puppet/type/sensu_client_subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ def initialize(*args)
desc "The subscription name"
end

newproperty(:subscriptions) do
desc "Subscriptions"
newparam(:subscriptions) do
desc "Subscriptions included"
defaultto :name
munge do |value|
Array(value)
end
end

autorequire(:package) do
Expand Down