Skip to content

Commit

Permalink
changes related to adding support for comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Bode committed May 17, 2010
1 parent 8c3af58 commit 9f69773
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/puppet/provider/sudoers/parsed.rb
Expand Up @@ -22,6 +22,8 @@
# shameful NAMEVAR hack :(
if record[:line] =~ /Puppet NAMEVAR (.+)\s*$/
record[:name] = $1
elsif record[:line] =~ /#(.*)/
record[:comment] = $1
end
}

Expand Down Expand Up @@ -115,7 +117,7 @@ def type=(value)
# NAMEVAR comments leave me in need of a shower, but it seems to be the only way.
def self.prefetch_hook(records)
# store comment name vars when we find them
name=nil
name,comment=nil
results = records.each do |record|
if(record[:record_type] == :comment)
# if we are a namevar comment
Expand All @@ -124,17 +126,24 @@ def self.prefetch_hook(records)
#puts "found a comment with :name"
name = record[:name]
record[:skip] = true
elsif record[:comment] != nil
comment = record[:comment]
record[:skip] = true
end
elsif(record[:record_type] == :parsed)
record[:comment] = comment
comment = nil
# if we are a spec record, check the namevar
elsif record[:type] == 'user_spec'
if name
#puts "adding to a record"
record[:name] = name
name = nil
else
Puppet.info "spec record not created by puppet"
# probably a pre-exting record not created by puppet
end
if record[:type] == 'user_spec'
if name
#puts "adding to a record"
record[:name] = name
name = nil
else
Puppet.info "spec record not created by puppet"
# probably a pre-exting record not created by puppet
end
end
end
end.reject{|record| record[:skip]}
results
Expand All @@ -157,6 +166,9 @@ def self.to_line(hash)
raise Puppet::Error, "dont understand how to write out record \n|#{hash.to_yaml}\n|"
end
self.verify_sudo_line(line)
if hash[:comment]
line = "##{hash[:comment]}\n#{line}"
end
line
end

Expand Down

0 comments on commit 9f69773

Please sign in to comment.