mirror of
https://github.com/inspec/inspec
synced 2024-11-22 20:53:11 +00:00
make rubocop happy
Signed-off-by: Christoph Hartmann <chris@lollyrock.com>
This commit is contained in:
parent
15c03cf8fc
commit
afadc896f2
1 changed files with 27 additions and 18 deletions
|
@ -9,6 +9,28 @@ module Inspec::Resources
|
|||
|
||||
attr_reader :service, :data_dir, :conf_dir, :conf_path, :version, :cluster
|
||||
def initialize
|
||||
# determine dirs and service based on versions
|
||||
determine_dirs
|
||||
determine_service
|
||||
|
||||
# print warnings if the dirs do not exist
|
||||
verify_dirs
|
||||
|
||||
if !@version.nil? && !@conf_dir.empty?
|
||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
||||
else
|
||||
@conf_path = nil
|
||||
return skip_resource 'Seems like PostgreSQL is not installed on your system'
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
'PostgreSQL'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def determine_dirs
|
||||
if inspec.os.debian?
|
||||
#
|
||||
# https://wiki.debian.org/PostgreSql
|
||||
|
@ -33,30 +55,17 @@ module Inspec::Resources
|
|||
end
|
||||
@data_dir = locate_data_dir_location_by_version(@version)
|
||||
end
|
||||
@conf_dir ||= @data_dir
|
||||
end
|
||||
|
||||
def determine_service
|
||||
@service = 'postgresql'
|
||||
if @version.to_i >= 10
|
||||
@service += "-#{@version.to_i}"
|
||||
elsif @version.to_f >= 9.4
|
||||
@service += "-#{@version}"
|
||||
end
|
||||
|
||||
@conf_dir ||= @data_dir
|
||||
|
||||
verify_dirs
|
||||
if !@version.nil? && !@conf_dir.empty?
|
||||
@conf_path = File.join @conf_dir, 'postgresql.conf'
|
||||
else
|
||||
@conf_path = nil
|
||||
return skip_resource 'Seems like PostgreSQL is not installed on your system'
|
||||
end
|
||||
end
|
||||
|
||||
def to_s
|
||||
'PostgreSQL'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def verify_dirs
|
||||
warn "Default postgresql configuration directory: #{@conf_dir} does not exist. " \
|
||||
|
|
Loading…
Reference in a new issue