Skip to content

Commit

Permalink
expand postgresql_conf type and provider
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonHoenscheid committed Jul 6, 2023
1 parent e2e82d3 commit b3cbf1e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
8 changes: 4 additions & 4 deletions lib/puppet/provider/postgresql_conf/parsed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
text_line :blank, match: %r{^\s*$}

record_line :parsed,
fields: ['name', 'value', 'comment'],
fields: ['key', 'value', 'comment'],
optional: ['comment'],
match: %r{^\s*([\w.]+)\s*=?\s*(.*?)(?:\s*#\s*(.*))?\s*$},
to_line: proc { |h|
Expand All @@ -28,9 +28,9 @@
h[:value]
end
dontneedquote = val.match(%r{^(\d+.?\d+|\w+)$})
dontneedequal = h[:name].match(%r{^(include|include_if_exists)$}i)
dontneedequal = h[:key].match(%r{^(include|include_if_exists)$}i)

str = h[:name].downcase # normalize case
str = h[:key].downcase # normalize case
str += dontneedequal ? ' ' : ' = '
str += "'" unless dontneedquote && !dontneedequal
str += val
Expand All @@ -39,7 +39,7 @@
str
},
post_parse: proc { |h|
h[:name].downcase! # normalize case
h[:key].downcase! # normalize case
h[:value].gsub!(%r{(^'|'$)}, '') # strip out quotes
}
end
8 changes: 6 additions & 2 deletions lib/puppet/type/postgresql_conf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
ensurable

newparam(:name) do
desc 'The postgresql parameter name to manage.'
isnamevar
desc 'A unique title for the resource.'

newvalues(%r{^[\w.]+$})
end

newproperty(:key) do
desc 'The Postgresql parameter to manage.'
newvalues(%r{^[\w.]+$})
end

newproperty(:value) do
desc 'The value to set for this parameter.'
end
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/config_entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
postgresql_conf { $name:
ensure => $ensure,
target => $path,
name => $key,
key => $key,
value => $value,
require => Class['postgresql::server::initdb'],
}
Expand Down

0 comments on commit b3cbf1e

Please sign in to comment.