-
Notifications
You must be signed in to change notification settings - Fork 614
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "New postgresql_conf provider, handles multiple configs"
This reverts commit 179472b.
- Loading branch information
Showing
8 changed files
with
218 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'puppet/provider/parsedfile' | ||
|
||
Puppet::Type.type(:postgresql_conf).provide( | ||
:parsed, | ||
parent: Puppet::Provider::ParsedFile, | ||
default_target: '/etc/postgresql.conf', | ||
filetype: :flat, | ||
) do | ||
desc 'Set key/values in postgresql.conf.' | ||
|
||
text_line :comment, match: %r{^\s*#} | ||
text_line :blank, match: %r{^\s*$} | ||
|
||
record_line :parsed, | ||
fields: ['name', 'value', 'comment'], | ||
optional: ['comment'], | ||
match: %r{^\s*([\w.]+)\s*=?\s*(.*?)(?:\s*#\s*(.*))?\s*$}, | ||
to_line: proc { |h| | ||
# simple string and numeric values don't need to be enclosed in quotes | ||
val = if h[:value].is_a?(Numeric) | ||
h[:value].to_s | ||
elsif h[:value].is_a?(Array) | ||
# multiple listen_addresses specified as a string containing a comma-speparated list | ||
h[:value].join(', ') | ||
else | ||
h[:value] | ||
end | ||
dontneedquote = val.match(%r{^(\d+.?\d+|\w+)$}) | ||
dontneedequal = h[:name].match(%r{^(include|include_if_exists)$}i) | ||
|
||
str = h[:name].downcase # normalize case | ||
str += dontneedequal ? ' ' : ' = ' | ||
str += "'" unless dontneedquote && !dontneedequal | ||
str += val | ||
str += "'" unless dontneedquote && !dontneedequal | ||
str += " # #{h[:comment]}" unless h[:comment].nil? || h[:comment] == :absent | ||
str | ||
}, | ||
post_parse: proc { |h| | ||
h[:name].downcase! # normalize case | ||
h[:value].gsub!(%r{(^'|'$)}, '') # strip out quotes | ||
} | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.