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

Daniel Pittman daniel at puppetlabs.com
Tue May 10 08:10:44 UTC 2011


The following commit has been merged in the experimental branch:
commit eb4c4fbdc3951c220a76ec01abc33a7654d89e53
Author: Daniel Pittman <daniel at puppetlabs.com>
Date:   Fri Apr 1 10:44:35 2011 -0700

    (#6749) Start porting existing strings to the options API.
    
    This provides a solid test of the new code, by migrating the existing strings
    to match.  This also gives us a chance to determine any weak points in the
    code as written.
    
    Reviewed-By: Pieter van de Bruggen <pieter at puppetlabs.com>

diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb
index b440098..be01833 100644
--- a/lib/puppet/application/configurer.rb
+++ b/lib/puppet/application/configurer.rb
@@ -5,8 +5,8 @@ class Puppet::Application::Configurer < Puppet::Application
   should_parse_config
   run_mode :agent
 
-  option("--debug","-d")
-  option("--verbose","-v")
+  option("--debug", "-d")
+  option("--verbose", "-v")
 
   def setup
     if options[:debug] or options[:verbose]
diff --git a/lib/puppet/application/string.rb b/lib/puppet/application/string.rb
index aa369e6..0a6a798 100644
--- a/lib/puppet/application/string.rb
+++ b/lib/puppet/application/string.rb
@@ -83,7 +83,7 @@ class Puppet::Application::String < Puppet::Application
   def actions(indirection)
     return [] unless string = Puppet::String[indirection, '0.0.1']
     string.load_actions
-    return string.actions.sort { |a,b| a.to_s <=> b.to_s }
+    return string.actions.sort { |a, b| a.to_s <=> b.to_s }
   end
 
   def load_applications
diff --git a/lib/puppet/string/action.rb b/lib/puppet/string/action.rb
index 9e82f4d..ff419c0 100644
--- a/lib/puppet/string/action.rb
+++ b/lib/puppet/string/action.rb
@@ -14,7 +14,7 @@ class Puppet::String::Action
     @string  = string
     @name    = name.to_sym
     @options = {}
-    attrs.each do |k,v| send("#{k}=", v) end
+    attrs.each do |k, v| send("#{k}=", v) end
   end
 
   # Initially, this was defined to allow the @action.invoke pattern, which is
diff --git a/lib/puppet/string/catalog.rb b/lib/puppet/string/catalog.rb
index 0ddd831..c6de477 100644
--- a/lib/puppet/string/catalog.rb
+++ b/lib/puppet/string/catalog.rb
@@ -2,7 +2,7 @@ require 'puppet/string/indirector'
 
 Puppet::String::Indirector.define(:catalog, '0.0.1') do
   action(:apply) do
-    invoke do |catalog|
+    invoke do |catalog, options|
       report = Puppet::Transaction::Report.new("apply")
       report.configuration_version = catalog.version
 
@@ -23,7 +23,7 @@ Puppet::String::Indirector.define(:catalog, '0.0.1') do
   end
 
   action(:download) do
-    invoke do |certname,facts|
+    invoke do |certname, facts, options|
       Puppet::Resource::Catalog.terminus_class = :rest
       facts_to_upload = {:facts_format => :b64_zlib_yaml, :facts => CGI.escape(facts.render(:b64_zlib_yaml))}
       catalog = nil
diff --git a/lib/puppet/string/catalog/select.rb b/lib/puppet/string/catalog/select.rb
index 52c77d3..a8f4480 100644
--- a/lib/puppet/string/catalog/select.rb
+++ b/lib/puppet/string/catalog/select.rb
@@ -1,7 +1,7 @@
 # Select and show a list of resources of a given type.
 Puppet::String.define(:catalog, '0.0.1') do
   action :select do
-    invoke do |host,type|
+    invoke do |host, type, options|
       catalog = Puppet::Resource::Catalog.indirection.find(host)
 
       catalog.resources.reject { |res| res.type != type }.each { |res| puts res }
diff --git a/lib/puppet/string/certificate.rb b/lib/puppet/string/certificate.rb
index 7b2e5f3..53f731e 100644
--- a/lib/puppet/string/certificate.rb
+++ b/lib/puppet/string/certificate.rb
@@ -4,7 +4,7 @@ require 'puppet/ssl/host'
 Puppet::String::Indirector.define(:certificate, '0.0.1') do
 
   action :generate do
-    invoke do |name|
+    invoke do |name, options|
       host = Puppet::SSL::Host.new(name)
       host.generate_certificate_request
       host.certificate_request.class.indirection.save(host.certificate_request)
@@ -12,7 +12,7 @@ Puppet::String::Indirector.define(:certificate, '0.0.1') do
   end
 
   action :list do
-    invoke do
+    invoke do |options|
       Puppet::SSL::Host.indirection.search("*", {
         :for => :certificate_request,
       }).map { |h| h.inspect }
@@ -20,7 +20,7 @@ Puppet::String::Indirector.define(:certificate, '0.0.1') do
   end
 
   action :sign do
-    invoke do |name|
+    invoke do |name, options|
       Puppet::SSL::Host.indirection.save(Puppet::SSL::Host.new(name))
     end
   end
diff --git a/lib/puppet/string/config.rb b/lib/puppet/string/config.rb
index ae1a408..49a1688 100644
--- a/lib/puppet/string/config.rb
+++ b/lib/puppet/string/config.rb
@@ -3,6 +3,7 @@ require 'puppet/string'
 Puppet::String.define(:config, '0.0.1') do
   action(:print) do
     invoke do |*args|
+      options = args.pop
       Puppet.settings[:configprint] = args.join(",")
       Puppet.settings.print_config_options
       nil
diff --git a/lib/puppet/string/configurer.rb b/lib/puppet/string/configurer.rb
index a6ea74b..2520d41 100644
--- a/lib/puppet/string/configurer.rb
+++ b/lib/puppet/string/configurer.rb
@@ -2,7 +2,7 @@ require 'puppet/string'
 
 Puppet::String.define(:configurer, '0.0.1') do
   action(:synchronize) do
-    invoke do |certname|
+    invoke do |certname, options|
       facts = Puppet::String[:facts, '0.0.1'].find(certname)
       catalog = Puppet::String[:catalog, '0.0.1'].download(certname, facts)
       report = Puppet::String[:catalog, '0.0.1'].apply(catalog)
diff --git a/lib/puppet/string/facts.rb b/lib/puppet/string/facts.rb
index 73acb0d..3129881 100644
--- a/lib/puppet/string/facts.rb
+++ b/lib/puppet/string/facts.rb
@@ -6,7 +6,7 @@ Puppet::String::Indirector.define(:facts, '0.0.1') do
 
   # Upload our facts to the server
   action(:upload) do
-    invoke do |*args|
+    invoke do |options|
       Puppet::Node::Facts.indirection.terminus_class = :facter
       facts = Puppet::Node::Facts.indirection.find(Puppet[:certname])
       Puppet::Node::Facts.indirection.terminus_class = :rest
diff --git a/lib/puppet/string/report.rb b/lib/puppet/string/report.rb
index 55a0085..5b617e4 100644
--- a/lib/puppet/string/report.rb
+++ b/lib/puppet/string/report.rb
@@ -2,7 +2,7 @@ require 'puppet/string/indirector'
 
 Puppet::String::Indirector.define(:report, '0.0.1') do
   action(:submit) do
-    invoke do |report|
+    invoke do |report, options|
       begin
         Puppet::Transaction::Report.terminus_class = :rest
         report.save
diff --git a/spec/unit/application/configurer_spec.rb b/spec/unit/application/configurer_spec.rb
old mode 100644
new mode 100755
diff --git a/spec/unit/string/action_builder_spec.rb b/spec/unit/string/action_builder_spec.rb
index 0229fe4..fde010d 100755
--- a/spec/unit/string/action_builder_spec.rb
+++ b/spec/unit/string/action_builder_spec.rb
@@ -6,7 +6,7 @@ require 'puppet/string/action_builder'
 describe Puppet::String::ActionBuilder do
   describe "::build" do
     it "should build an action" do
-      action = Puppet::String::ActionBuilder.build(nil,:foo) do
+      action = Puppet::String::ActionBuilder.build(nil, :foo) do
       end
       action.should be_a(Puppet::String::Action)
       action.name.should == :foo
@@ -24,7 +24,7 @@ describe Puppet::String::ActionBuilder do
     end
 
     it "should require a block" do
-      lambda { Puppet::String::ActionBuilder.build(nil,:foo) }.
+      lambda { Puppet::String::ActionBuilder.build(nil, :foo) }.
         should raise_error("Action :foo must specify a block")
     end
 
diff --git a/spec/unit/string/indirector_spec.rb b/spec/unit/string/indirector_spec.rb
index 89306c4..da5f569 100755
--- a/spec/unit/string/indirector_spec.rb
+++ b/spec/unit/string/indirector_spec.rb
@@ -33,8 +33,8 @@ describe Puppet::String::Indirector do
       Puppet::String::Indirector.should be_action(method)
     end
 
-    it "should just call the indirection method when the '#{method}' action is invoked" do
-      @instance.indirection.expects(method).with(:test, "myargs")
+    it "should call the indirection method when the '#{method}' action is invoked" do
+      @instance.indirection.expects(method).with(:test, "myargs", {})
       @instance.send(method, :test, "myargs")
     end
   end
diff --git a/spec/unit/string/option_spec.rb b/spec/unit/string/option_spec.rb
index fc7b832..f4f62ec 100644
--- a/spec/unit/string/option_spec.rb
+++ b/spec/unit/string/option_spec.rb
@@ -5,7 +5,7 @@ describe Puppet::String::Option do
 
   describe "#optparse_to_name" do
     ["", "=BAR", " BAR", "=bar", " bar"].each do |postfix|
-      { "--foo" => :foo, "-f" => :f,}.each do |base, expect|
+      { "--foo" => :foo, "-f" => :f }.each do |base, expect|
         input = base + postfix
         it "should map #{input.inspect} to #{expect.inspect}" do
           option = Puppet::String::Option.new(string, input)
diff --git a/spec/unit/string_spec.rb b/spec/unit/string_spec.rb
index 7f7489e..ddf8554 100755
--- a/spec/unit/string_spec.rb
+++ b/spec/unit/string_spec.rb
@@ -41,7 +41,7 @@ describe Puppet::String do
     end
 
     it "should instance-eval any provided block" do
-      face = Puppet::String.new(:string_test_block,'0.0.1') do
+      face = Puppet::String.new(:string_test_block, '0.0.1') do
         action(:something) do
           invoke { "foo" }
         end
@@ -52,15 +52,15 @@ describe Puppet::String do
   end
 
   it "should have a name" do
-    Puppet::String.new(:me,'0.0.1').name.should == :me
+    Puppet::String.new(:me, '0.0.1').name.should == :me
   end
 
   it "should stringify with its own name" do
-    Puppet::String.new(:me,'0.0.1').to_s.should =~ /\bme\b/
+    Puppet::String.new(:me, '0.0.1').to_s.should =~ /\bme\b/
   end
 
   it "should allow overriding of the default format" do
-    face = Puppet::String.new(:me,'0.0.1')
+    face = Puppet::String.new(:me, '0.0.1')
     face.set_default_format :foo
     face.default_format.should == :foo
   end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list