[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5

Richard Crowley r at rcrowley.org
Tue May 10 08:07:27 UTC 2011


The following commit has been merged in the experimental branch:
commit 5d7715b0c56c6f06d916126e8470d7edb66d7687
Author: Richard Crowley <r at rcrowley.org>
Date:   Tue Mar 22 23:46:21 2011 +0000

    Factoring cert status app back into certificate.

diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb
index 4a2b3ef..edb4eef 100644
--- a/lib/puppet/application/certificate.rb
+++ b/lib/puppet/application/certificate.rb
@@ -1,4 +1,17 @@
 require 'puppet/application/indirection_base'
 
 class Puppet::Application::Certificate < Puppet::Application::IndirectionBase
+
+  # Luke used to call this --ca but that's taken by the global boolean --ca.
+  # Since these options map CA terminology to indirector terminology, it's
+  # now called --ca-location.
+  option "--ca-location CA_LOCATION" do |arg|
+    handle_terminus({
+      :local => :file,
+      :remote => :rest,
+      :only => :file,
+      :none => nil,
+    }[arg.to_sym])
+  end
+
 end
diff --git a/lib/puppet/interface/certificate.rb b/lib/puppet/interface/certificate.rb
index 09da0a6..c2101d9 100644
--- a/lib/puppet/interface/certificate.rb
+++ b/lib/puppet/interface/certificate.rb
@@ -1,4 +1,21 @@
 require 'puppet/interface/indirector'
 
 Puppet::Interface::Indirector.interface(:certificate) do
+
+  action :sign do |name|
+    unless indirection.terminus
+      raise ArgumentError, "You must have a CA specified; use --ca-location to specify the location (remote, local, only)"
+    end
+
+    location = Puppet::SSL::Host.ca_location
+    if location == :local && !Puppet::SSL::CertificateAuthority.ca?
+      Puppet::Application[:certificate].class.run_mode("master")
+      set_run_mode Puppet::Application[:certificate].class.run_mode
+    end
+
+    Puppet::SSL::CertificateStatus.indirection.save(
+      Puppet::SSL::CertificateStatus.new(name))
+
+  end
+
 end
diff --git a/spec/unit/application/certificate.rb b/spec/unit/application/certificate.rb
new file mode 100644
index 0000000..0688666
--- /dev/null
+++ b/spec/unit/application/certificate.rb
@@ -0,0 +1,21 @@
+#!/usr/bin/env ruby
+
+require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper.rb')
+require 'puppet/application/certificate'
+
+describe Puppet::Application::Certificate do
+  it "should be a subclass of Puppet::Application::IndirectionBase" do
+    Puppet::Application::Certificate.superclass.should equal(
+      Puppet::Application::IndirectionBase
+    )
+  end
+
+  it "should have a 'ca' option" do
+    Puppet::Application::Certificate.new.should respond_to(:handle_ca_location)
+  end
+
+  it "should set the CA location using the 'ca' option" do
+    Puppet::Application::Certificate.new.handle_ca_location("local")
+    Puppet::SSL::Host.indirection.terminus_class.should == :file
+  end
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list