remove escaped semicolons and additional spaces from dig query output for certain types
This commit is contained in:
parent
15d61bcefc
commit
4ac574742a
@ -76,6 +76,14 @@ module PuppetBind
|
|||||||
%w(TXT SPF).include?(type)
|
%w(TXT SPF).include?(type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def escaped_type?(type)
|
||||||
|
%w(TXT).include?(type)
|
||||||
|
end
|
||||||
|
|
||||||
|
def spaced_type?(type)
|
||||||
|
%w(DS TLSA).include?(type)
|
||||||
|
end
|
||||||
|
|
||||||
def maybe_quote(type, datum)
|
def maybe_quote(type, datum)
|
||||||
quoted_type?(type) ? "\"#{datum}\"" : datum
|
quoted_type?(type) ? "\"#{datum}\"" : datum
|
||||||
end
|
end
|
||||||
@ -84,6 +92,14 @@ module PuppetBind
|
|||||||
quoted_type?(type) ? datum.gsub(/^\"(.*)\"$/, '\1') : datum
|
quoted_type?(type) ? datum.gsub(/^\"(.*)\"$/, '\1') : datum
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def maybe_unescape(type, datum)
|
||||||
|
escaped_type?(type) ? datum.gsub(/\\;/, ';') : datum
|
||||||
|
end
|
||||||
|
|
||||||
|
def maybe_unspace(type, datum)
|
||||||
|
spaced_type?(type) ? datum.gsub(/^(\d+)\s+(\d+)\s+(\d+)\s+(\w+)\s+(\w+)$/, '\1 \2 \3 \4\5') : datum
|
||||||
|
end
|
||||||
|
|
||||||
def rrdata_adds
|
def rrdata_adds
|
||||||
resource[:ensure] === :absent ? [] : newdata - rrdata
|
resource[:ensure] === :absent ? [] : newdata - rrdata
|
||||||
end
|
end
|
||||||
@ -141,12 +157,15 @@ module PuppetBind
|
|||||||
end
|
end
|
||||||
@query = dig_text.lines.map do |line|
|
@query = dig_text.lines.map do |line|
|
||||||
linearray = line.chomp.split(/\s+/, 5)
|
linearray = line.chomp.split(/\s+/, 5)
|
||||||
|
linearray[4] = maybe_unquote(linearray[3], linearray[4])
|
||||||
|
linearray[4] = maybe_unescape(linearray[3], linearray[4])
|
||||||
|
linearray[4] = maybe_unspace(linearray[3], linearray[4])
|
||||||
{
|
{
|
||||||
:name => linearray[0],
|
:name => linearray[0],
|
||||||
:ttl => linearray[1],
|
:ttl => linearray[1],
|
||||||
:rrclass => linearray[2],
|
:rrclass => linearray[2],
|
||||||
:type => linearray[3],
|
:type => linearray[3],
|
||||||
:rrdata => maybe_unquote(linearray[3], linearray[4])
|
:rrdata => linearray[4]
|
||||||
}
|
}
|
||||||
end.select do |record|
|
end.select do |record|
|
||||||
record[:name] == "#{name}."
|
record[:name] == "#{name}."
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user