Skip to content

Commit

Permalink
Merge pull request #831 from alvagante/749bis
Browse files Browse the repository at this point in the history
Added client_registration option #749
  • Loading branch information
ghoneycutt authored Oct 23, 2017
2 parents d6fbaca + dd93426 commit 26f600e
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/puppet/type/sensu_client_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ def insync?(is)
newvalues(/.*/, :absent)
end

newproperty(:registration) do
desc 'Client registration attributes'
newvalues(/.*/, :absent)
end

newproperty(:keepalive) do
desc "Keepalive config"

Expand Down
1 change: 1 addition & 0 deletions manifests/client.pp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
redact => $::sensu::redact,
deregister => $::sensu::client_deregister,
deregistration => $::sensu::client_deregistration,
registration => $::sensu::client_registration,
http_socket => $::sensu::client_http_socket,
servicenow => $::sensu::client_servicenow,
ec2 => $::sensu::client_ec2,
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@
# status, and issued timestamp. The following attributes are provided as
# recommendations for controlling client deregistration behavior.
#
# @param client_registration [Attributes](https://sensuapp.org/docs/latest/reference/clients#registration-attributes)
# used to generate check result data for the registration event. Client
# registration attributes are merged with some default check definition
# attributes by the Sensu server during client registration.
#
# @param client_keepalive Client keepalive configuration
#
# @param client_http_socket Client http_socket configuration. Must be an Hash of
Expand Down Expand Up @@ -371,6 +376,7 @@
Hash $client_custom = {},
Variant[Undef,Boolean] $client_deregister = undef,
Variant[Undef,Hash] $client_deregistration = undef,
Variant[Undef,Hash] $client_registration = undef,
Hash $client_keepalive = {},
Hash $client_http_socket = {},
Hash $client_servicenow = {},
Expand Down
18 changes: 18 additions & 0 deletions spec/classes/sensu_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,24 @@
end
end

describe 'client_registration' do
let(:params_override) { {client_registration: registration} }
context "=> {'handler': 'register_client'}" do
let(:registration) { {'handler' => 'register_client'} }
it { is_expected.to contain_sensu_client_config(title).with(registration: registration) }
end

context "=> {}" do
let(:registration) { {} }
it { is_expected.to contain_sensu_client_config(title).with(registration: registration) }
end

context "=> 'absent' (error)" do
let(:registration) { 'absent' }
it { is_expected.to raise_error(Puppet::Error) }
end
end

describe 'http_socket' do
http_socket = {
'bind' => '127.0.0.1',
Expand Down
15 changes: 15 additions & 0 deletions spec/unit/sensu_client_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
end
end

describe 'registration' do
subject { described_class.new(resource_hash)[:registration] }
context 'in the default case' do
it { is_expected.to be_nil }
end
context '=> {}' do
let(:resource_hash_override) { {registration: {}} }
it { is_expected.to eq({}) }
end
context '=> absent' do
let(:resource_hash_override) { {registration: 'absent'} }
it { is_expected.to eq(:absent) }
end
end

describe 'notifications' do
let(:resource_hash) do
c = Puppet::Resource::Catalog.new
Expand Down

0 comments on commit 26f600e

Please sign in to comment.