summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/sshkey
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-14 17:49:19 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-03-14 17:49:19 +0000
commitdf4595e98f953432267756c84a37a5495e9720ef (patch)
treededa10a6947d4c6ce4777d3f9ea9922a0ddc7a70 /lib/puppet/provider/sshkey
parentb05ae2ae1262469df264e3a35b30f7a1d1805c18 (diff)
downloadpuppet-df4595e98f953432267756c84a37a5495e9720ef.tar.gz
puppet-df4595e98f953432267756c84a37a5495e9720ef.tar.xz
puppet-df4595e98f953432267756c84a37a5495e9720ef.zip
Significantly reworking the internals of the fileparsing code. It now
passes around an instance of a FileRecord, rather than just a hash, which I think makes it much easier to understand. Moved the sshkey parsed provider test to its own directory and made it better. This work is all being done so I can move cron jobs to using providers instead of the current unmaintainable state of affairs. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2281 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/provider/sshkey')
-rwxr-xr-xlib/puppet/provider/sshkey/parsed.rb42
1 files changed, 17 insertions, 25 deletions
diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb
index e247502ff..d6e175cf8 100755
--- a/lib/puppet/provider/sshkey/parsed.rb
+++ b/lib/puppet/provider/sshkey/parsed.rb
@@ -1,6 +1,5 @@
require 'puppet/provider/parsedfile'
-
known = nil
case Facter.value(:operatingsystem)
when "Darwin": known = "/etc/ssh_known_hosts"
@@ -15,30 +14,23 @@ Puppet::Type.type(:sshkey).provide(:parsed,
) do
text_line :comment, :match => /^#/
text_line :blank, :match => /^\s+/
- record_line :parsed, :fields => %w{name type key}
-
- # Override the line parsing a bit, so we can split the aliases out.
- def self.parse_line(line)
- hash = super
- if hash[:name] =~ /,/
- names = hash[:name].split(",")
- hash[:name] = names.shift
- hash[:alias] = names
- end
- hash
- end
-
-
- def self.to_line(hash)
- if hash[:alias]
- hash = hash.dup
- names = [hash[:name], hash[:alias]].flatten
-
- hash[:name] = [hash[:name], hash[:alias]].flatten.join(",")
- hash.delete(:alias)
- end
- super(hash)
- end
+
+ record_line :parsed, :fields => %w{name type key},
+ :post_parse => proc { |hash|
+ if hash[:name] =~ /,/
+ names = hash[:name].split(",")
+ hash[:name] = names.shift
+ hash[:alias] = names
+ end
+ },
+ :pre_gen => proc { |hash|
+ if hash[:alias]
+ names = [hash[:name], hash[:alias]].flatten
+
+ hash[:name] = [hash[:name], hash[:alias]].flatten.join(",")
+ hash.delete(:alias)
+ end
+ }
end
# $Id$