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

Bug fixes, lint, rubocop, spec tests etc. #53

Merged
merged 35 commits into from
Sep 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
921aa0a
Fix incorrect variable names in `forwarder.pp`
alexjfisher Sep 26, 2016
913e62d
Fix `::include` bug
alexjfisher Sep 26, 2016
105bd23
Fix remaining lint errors
alexjfisher Sep 26, 2016
290fb3d
`Fix` tests
alexjfisher Sep 26, 2016
ec1d448
Rename spec file
alexjfisher Sep 26, 2016
da5d112
Rename `README.markdown` to `README.md`
alexjfisher Sep 26, 2016
71a3c8c
rubocop: fix Style/HashSyntax
bastelfreak Sep 26, 2016
246b660
rubocop: fix Style/StringLiterals
bastelfreak Sep 26, 2016
680fe50
rubocop: fix Style/BracesAroundHashParameters
bastelfreak Sep 26, 2016
5b0c408
rubocop: fix Style/SpaceAfterComma
bastelfreak Sep 26, 2016
459843c
rubocop: fix Style/IndentationWidth
bastelfreak Sep 26, 2016
79cc694
rubocop: fix Style/EmptyLinesAroundBlockBody
bastelfreak Sep 26, 2016
5f570e5
rubocop: fix Style/TrailingWhitespace
bastelfreak Sep 26, 2016
d653d76
rubocop: fix Style/EmptyLines
bastelfreak Sep 26, 2016
a6a53a3
rubocop: fix Style/TrailingBlankLines
bastelfreak Sep 26, 2016
357905b
rubocop: fix Style/SpaceInsideBrackets
bastelfreak Sep 26, 2016
3c28a93
rubocop: fix Style/EmptyLiteral
bastelfreak Sep 26, 2016
6d8fe0e
rubocop: fix Style/IndentationConsistency
bastelfreak Sep 26, 2016
f84881e
rubocop: fix Style/SpaceInsideBlockBraces
bastelfreak Sep 26, 2016
953eee8
rubocop: fix Style/SpaceBeforeBlockBraces
bastelfreak Sep 26, 2016
e9662f5
rubocop: fix Style/EmptyLinesAroundModuleBody
bastelfreak Sep 26, 2016
d8b7a69
rubocop: fix RSpec/ExampleWording
bastelfreak Sep 26, 2016
efa7781
rubocop: fix Style/IndentArray
bastelfreak Sep 26, 2016
1281e52
rubocop: fix Style/SpaceAroundOperators
bastelfreak Sep 26, 2016
3037bd7
rubocop: fix Style/Lambda
bastelfreak Sep 26, 2016
dfce398
rubocop: fix Style/RedundantReturn
alexjfisher Sep 26, 2016
be947ee
rubocop: fix Lint/BlockAlignment
alexjfisher Sep 26, 2016
038a667
rubocop: fix Style/IfUnlessModifier
alexjfisher Sep 26, 2016
4fdc6c9
rubocop: fix Style/MultilineArrayBraceLayout
alexjfisher Sep 26, 2016
762d19c
rubocop: fix Style/EmptyLinesAroundBlockBody
alexjfisher Sep 26, 2016
3ed559d
rubocop: fix Style/RedundantSelf
alexjfisher Sep 26, 2016
4be4b26
rubocop: fix Style/Next
alexjfisher Sep 26, 2016
099079e
rubocop: fix Lint/Void
alexjfisher Sep 26, 2016
161019c
rubocop: fix Style/RegexpLiteral
alexjfisher Sep 26, 2016
bead52a
rubocop: fix Style/AccessorMethodName
crayfishx Sep 28, 2016
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
7 changes: 7 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fixtures:
repositories:
stdlib: 'https://github.com/puppetlabs/puppetlabs-stdlib.git'
inifile: 'https://github.com/puppetlabs/puppetlabs-inifile.git'
staging: 'https://github.com/voxpupuli/puppet-staging.git'
symlinks:
splunk: "#{source_dir}"
File renamed without changes.
16 changes: 8 additions & 8 deletions lib/puppet/provider/ini_setting/splunk.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Puppet::Type.type(:ini_setting).provide(
:splunk,
:parent => Puppet::Type.type(:ini_setting).provider(:ruby)
parent: Puppet::Type.type(:ini_setting).provider(:ruby)
) do

confine :true => false # Never automatically select this provider
confine true: false # Never automatically select this provider

@file_path = nil

def self.file_path
raise Puppet::Error, "file_path must be set with splunk_config type before provider can be used" if @file_path.nil?
raise Puppet::Error, "Child provider class does not support a file_name method" unless self.respond_to?(:file_name)
File.join(@file_path, file_name)
class << self
attr_writer :file_path
end

def self.set_file_path(path)
@file_path=path
def self.file_path
raise Puppet::Error, 'file_path must be set with splunk_config type before provider can be used' if @file_path.nil?
raise Puppet::Error, 'Child provider class does not support a file_name method' unless respond_to?(:file_name)
File.join(@file_path, file_name)
end
end
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_authentication/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_authentication).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/authentication.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_authorize/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_authorize).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/authorize.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_distsearch/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_distsearch).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/distsearch.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_indexes/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_indexes).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/indexes.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_input/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_input).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/inputs.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_limits/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_limits).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/limits.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_output/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_output).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/outputs.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_props/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_props).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/props.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_server/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_server).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/server.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_transforms/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_transforms).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/transforms.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunk_web/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunk_web).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/web.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunkforwarder_input/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunkforwarder_input).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/inputs.conf'
Expand Down
5 changes: 2 additions & 3 deletions lib/puppet/provider/splunkforwarder_output/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
Puppet::Type.type(:splunkforwarder_output).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
"system/local/outputs.conf"
'system/local/outputs.conf'
end
end

2 changes: 1 addition & 1 deletion lib/puppet/provider/splunkforwarder_props/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunkforwarder_props).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/props.conf'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunkforwarder_transforms).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/transforms.conf'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/splunkforwarder_web/ini_setting.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet::Type.type(:splunkforwarder_web).provide(
:ini_setting,
:parent => Puppet::Type.type(:ini_setting).provider(:splunk)
parent: Puppet::Type.type(:ini_setting).provider(:splunk)
) do
def self.file_name
'system/local/web.conf'
Expand Down
3 changes: 1 addition & 2 deletions lib/puppet/type/splunk_authentication.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_authentication) do
@doc = "Manage splunk authentication settings in authentication.conf"
@doc = 'Manage splunk authentication settings in authentication.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end

2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_authorize.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_authorize) do
@doc = "Manage splunk authorize settings in authorize.conf"
@doc = 'Manage splunk authorize settings in authorize.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
82 changes: 38 additions & 44 deletions lib/puppet/type/splunk_config.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
# Require all of our types so the class names are resolvable for purging
Dir[File.dirname(__FILE__) + '/*.rb'].each do |file|
unless file == __FILE__
require file
end
Dir[File.dirname(__FILE__) + '/*.rb'].each do |file|
require file unless file == __FILE__
end

Puppet::Type.newtype(:splunk_config) do
newparam(:name, :namevar => true) do
newparam(:name, namevar: true) do
desc 'splunk config'
end

Expand All @@ -23,26 +21,26 @@
end

## Generate purge parameters for the splunk_config type
[
:purge_inputs,
:purge_outputs,
:purge_authentication,
:purge_authorize,
:purge_distsearch,
:purge_indexes,
:purge_limits,
:purge_props,
:purge_server,
:purge_transforms,
:purge_web,
:purge_forwarder_inputs,
:purge_forwarder_outputs,
:purge_forwarder_props,
:purge_forwarder_transforms,
:purge_forwarder_web
[
:purge_inputs,
:purge_outputs,
:purge_authentication,
:purge_authorize,
:purge_distsearch,
:purge_indexes,
:purge_limits,
:purge_props,
:purge_server,
:purge_transforms,
:purge_web,
:purge_forwarder_inputs,
:purge_forwarder_outputs,
:purge_forwarder_props,
:purge_forwarder_transforms,
:purge_forwarder_web
].each do |p|
newparam(p) do
newvalues(:true,:false)
newvalues(:true, :false)
defaultto :false
end
end
Expand All @@ -53,7 +51,7 @@
def generate
set_provider_paths

resources = Array.new
resources = []

{
Puppet::Type::Splunk_output => self[:purge_outputs],
Expand All @@ -71,14 +69,13 @@ def generate
Puppet::Type::Splunkforwarder_props => self[:purge_forwarder_props],
Puppet::Type::Splunkforwarder_transforms => self[:purge_forwarder_transforms],
Puppet::Type::Splunkforwarder_web => self[:purge_forwarder_web]
}.each do |k,purge|
}.each do |k, purge|
resources.concat(purge_splunk_resources(k)) if purge == :true
end

return resources
resources
end


def set_provider_paths
[
:splunk_authentication,
Expand All @@ -92,7 +89,7 @@ def set_provider_paths
:splunk_transforms,
:splunk_web
].each do |res_type|
Puppet::Type.type(res_type).provider(:ini_setting).set_file_path(self[:server_confdir])
Puppet::Type.type(res_type).provider(:ini_setting).file_path = self[:server_confdir]
end
[
:splunkforwarder_input,
Expand All @@ -101,40 +98,37 @@ def set_provider_paths
:splunkforwarder_transforms,
:splunkforwarder_web
].each do |res_type|
Puppet::Type.type(res_type).provider(:ini_setting).set_file_path(self[:forwarder_confdir])
Puppet::Type.type(res_type).provider(:ini_setting).file_path = self[:forwarder_confdir]
end
end

def purge_splunk_resources(klass)
type_name = klass.name
purge_resources = Array.new
puppet_resources = Array.new
purge_resources = []
puppet_resources = []

# Search the catalog for resource types matching the provided class
# type and build an array of puppet resources matching the namevar
# as section/setting
#
catalog_resources = catalog.resources.select { |r| r.is_a?(klass) }
catalog_resources.each do |res|
puppet_resources << res[:section] + "/" + res[:setting]
puppet_resources << res[:section] + '/' + res[:setting]
end


# Search the configured instances of the class type and purge them if
# the instance name (setion/setting) isn't found in puppet_resources
#
Puppet::Type.type(type_name).instances.each do |instance|
unless puppet_resources.include?(instance.name)
purge_resources << Puppet::Type.type(type_name).new(
:name => instance.name,
:section => instance[:section],
:setting => instance[:setting],
:ensure => :absent
)
end
next if puppet_resources.include?(instance.name)
purge_resources << Puppet::Type.type(type_name).new(
name: instance.name,
section: instance[:section],
setting: instance[:setting],
ensure: :absent
)
end

return purge_resources
purge_resources
end

end
3 changes: 1 addition & 2 deletions lib/puppet/type/splunk_distsearch.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_distsearch) do
@doc= "Manage distsearch entries in distsearch.conf"
@doc = 'Manage distsearch entries in distsearch.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end

3 changes: 1 addition & 2 deletions lib/puppet/type/splunk_indexes.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_indexes) do
@doc = "Manage splunk index settings in indexes.conf"
@doc = 'Manage splunk index settings in indexes.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end

2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_input.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_input) do
@doc = "Manage splunk input settings in inputs.conf"
@doc = 'Manage splunk input settings in inputs.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_limits.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_limits) do
@doc = "Manage splunk limits settings in limits.conf"
@doc = 'Manage splunk limits settings in limits.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_output.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_output) do
@doc = "Manage splunk output settings in outputs.conf"
@doc = 'Manage splunk output settings in outputs.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_props.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_props) do
@doc = "Manage splunk prop settings in props.conf"
@doc = 'Manage splunk prop settings in props.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
2 changes: 1 addition & 1 deletion lib/puppet/type/splunk_server.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', '..', 'puppet_x/puppetlabs/splunk/type')

Puppet::Type.newtype(:splunk_server) do
@doc = "Manage splunk server settings in server.conf"
@doc = 'Manage splunk server settings in server.conf'
PuppetX::Puppetlabs::Splunk::Type.clone_type(self)
end
Loading