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

Luke Kanies luke at puppetlabs.com
Tue May 10 08:05:09 UTC 2011


The following commit has been merged in the experimental branch:
commit cde1baa4a9a27ba95ad2a61bc8e46d43e708b081
Author: Luke Kanies <luke at puppetlabs.com>
Date:   Sun Feb 20 15:39:54 2011 -0800

    Fixing Interface listing
    
    It got broke when the Indirector base class was extracted.
    
    Signed-off-by: Luke Kanies <luke at puppetlabs.com>

diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb
index db926df..8f26658 100644
--- a/lib/puppet/application/interface.rb
+++ b/lib/puppet/application/interface.rb
@@ -17,23 +17,23 @@ class Puppet::Application::Interface < Puppet::Application
     if arguments.empty?
       arguments = %w{terminuses actions}
     end
-    indirections.each do |ind|
-      str = "#{ind}:\n"
+    interfaces.each do |name|
+      str = "#{name}:\n"
       if arguments.include?("terminuses")
         begin
-          terms = terminus_classes(ind.to_sym)
+          terms = terminus_classes(name.to_sym)
           str << "\tTerminuses: #{terms.join(", ")}\n"
         rescue => detail
-          $stderr.puts "Could not load terminuses for #{ind}: #{detail}"
+          $stderr.puts "Could not load terminuses for #{name}: #{detail}"
         end
       end
 
       if arguments.include?("actions")
         begin
-          actions = actions(ind.to_sym)
+          actions = actions(name.to_sym)
           str << "\tActions: #{actions.join(", ")}\n"
         rescue => detail
-          $stderr.puts "Could not load actions for #{ind}: #{detail}"
+          $stderr.puts "Could not load actions for #{name}: #{detail}"
         end
       end
 
@@ -70,12 +70,36 @@ class Puppet::Application::Interface < Puppet::Application
     end
   end
 
-  def indirections
-      Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort
+  def interfaces
+    # Load all of the interfaces
+    unless @interfaces
+      $LOAD_PATH.each do |dir|
+        next unless FileTest.directory?(dir)
+        Dir.chdir(dir) do
+          Dir.glob("puppet/interface/*.rb").collect { |f| f.sub(/\.rb/, '') }.each do |file|
+            begin
+              require file
+            rescue Error => detail
+              puts detail.backtrace if Puppet[:trace]
+              raise "Could not load #{file}: #{detail}"
+            end
+          end
+        end
+      end
+
+      @interfaces = []
+      Puppet::Interface.constants.each do |name|
+        klass = Puppet::Interface.const_get(name)
+        next if klass.abstract? # skip base classes
+
+        @interfaces << name.downcase
+      end
+    end
+    @interfaces
   end
 
   def terminus_classes(indirection)
-      Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort
+    Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort
   end
 
   def actions(indirection)
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 999c38b..2e52de4 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -3,7 +3,12 @@ require 'puppet'
 class Puppet::Interface
 
   class << self
-    attr_accessor :default_format
+    attr_accessor :default_format, :abstract
+
+    # Is this an actual interface, or a base class for others?
+    def abstract?
+      abstract
+    end
 
     def set_default_format(format)
       self.default_format = format.to_sym
diff --git a/lib/puppet/interface/indirector.rb b/lib/puppet/interface/indirector.rb
index f0beb8a..507826b 100644
--- a/lib/puppet/interface/indirector.rb
+++ b/lib/puppet/interface/indirector.rb
@@ -3,6 +3,8 @@ require 'puppet/interface'
 
 class Puppet::Interface::Indirector < Puppet::Interface
 
+  # This is just a base class.
+  @abstract = true
 
   # Here's your opportunity to override the indirection name.  By default
   # it will be the same name as the interface.

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list