diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-06 16:37:29 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-06 16:37:29 -0700 |
commit | 91069f36bcfe5b67f2ef0189360d55b607438c92 (patch) | |
tree | 66eebc03390c427db1a1579e7093b3e014edb012 /lib/puppet/string | |
parent | f732d69552969698fdae7905284f01682bfd3441 (diff) | |
parent | 27bd1adb7cc43bfdeb8fb941418cfce3a7f694ef (diff) | |
download | puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.gz puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.tar.xz puppet-91069f36bcfe5b67f2ef0189360d55b607438c92.zip |
Merge branch 'bug/master/6972-setting-CA-location-for-cert-string-no-longer-works'
Diffstat (limited to 'lib/puppet/string')
-rw-r--r-- | lib/puppet/string/certificate.rb | 18 | ||||
-rw-r--r-- | lib/puppet/string/option.rb | 4 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/puppet/string/certificate.rb b/lib/puppet/string/certificate.rb index b231cafb1..e8773ae2e 100644 --- a/lib/puppet/string/certificate.rb +++ b/lib/puppet/string/certificate.rb @@ -2,9 +2,24 @@ require 'puppet/string/indirector' require 'puppet/ssl/host' Puppet::String::Indirector.define(:certificate, '0.0.1') do + # REVISIT: This should use a pre-invoke hook to run the common code that + # needs to happen before we invoke any action; that would be much nicer than + # the "please repeat yourself" stuff found in here right now. + # + # option "--ca-location LOCATION" do + # type [:whatever, :location, :symbols] + # hook :before do |value| + # Puppet::SSL::Host.ca_location = value + # end + # end + # + # ...but should I pass the arguments as well? + # --daniel 2011-04-05 + option "--ca-location LOCATION" action :generate do when_invoked do |name, options| + Puppet::SSL::Host.ca_location = options[:ca_location].to_sym host = Puppet::SSL::Host.new(name) host.generate_certificate_request host.certificate_request.class.indirection.save(host.certificate_request) @@ -13,6 +28,7 @@ Puppet::String::Indirector.define(:certificate, '0.0.1') do action :list do when_invoked do |options| + Puppet::SSL::Host.ca_location = options[:ca_location].to_sym Puppet::SSL::Host.indirection.search("*", { :for => :certificate_request, }).map { |h| h.inspect } @@ -21,10 +37,10 @@ Puppet::String::Indirector.define(:certificate, '0.0.1') do action :sign do when_invoked do |name, options| + Puppet::SSL::Host.ca_location = options[:ca_location].to_sym host = Puppet::SSL::Host.new(name) host.desired_state = 'signed' Puppet::SSL::Host.indirection.save(host) end end - end diff --git a/lib/puppet/string/option.rb b/lib/puppet/string/option.rb index f499e4b95..be7bbb76e 100644 --- a/lib/puppet/string/option.rb +++ b/lib/puppet/string/option.rb @@ -70,10 +70,10 @@ class Puppet::String::Option end def optparse_to_name(declaration) - unless found = declaration.match(/^-+([^= ]+)/) or found.length != 1 then + unless found = declaration.match(/^-+(?:\[no-\])?([^ =]+)/) then raise ArgumentError, "Can't find a name in the declaration #{declaration.inspect}" end - name = found.captures.first.sub('[no-]', '').tr('-', '_') + name = found.captures.first.tr('-', '_') raise "#{name.inspect} is an invalid option name" unless name.to_s =~ /^[a-z]\w*$/ name.to_sym end |