summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-02-16 00:44:44 -0800
committerLuke Kanies <luke@puppetlabs.com>2011-02-16 00:44:44 -0800
commitb3f903af34c0e27dccb1d043d84c35ea68f44830 (patch)
tree3be902079da77f2dae8846e10080932b1b28cdc3 /lib
parent782ca8df60c0adc6c264a196292032479d2c2f7c (diff)
downloadpuppet-b3f903af34c0e27dccb1d043d84c35ea68f44830.tar.gz
puppet-b3f903af34c0e27dccb1d043d84c35ea68f44830.tar.xz
puppet-b3f903af34c0e27dccb1d043d84c35ea68f44830.zip
Enabling arbitrary interface names
Previously the app, indirection, and interface names had to match exactly; now they can be arbitrary by just defining an overriding 'indirection_name' class method on the interface. I also renamed the file_bucket_file classes accordingly. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/application/data_baseclass.rb2
-rw-r--r--lib/puppet/application/file.rb4
-rw-r--r--lib/puppet/application/file_bucket_file.rb4
-rw-r--r--lib/puppet/interface.rb11
-rw-r--r--lib/puppet/interface/file.rb7
-rw-r--r--lib/puppet/interface/file_bucket_file.rb4
6 files changed, 21 insertions, 11 deletions
diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb
index 8da624c60..b7393f96c 100644
--- a/lib/puppet/application/data_baseclass.rb
+++ b/lib/puppet/application/data_baseclass.rb
@@ -65,7 +65,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application
validate
- raise "Could not find data type #{type} for application #{self.class.name}" unless @indirection = Puppet::Indirector::Indirection.instance(type)
+ raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection
@interface.set_terminus(from) if from
end
diff --git a/lib/puppet/application/file.rb b/lib/puppet/application/file.rb
new file mode 100644
index 000000000..2acedda86
--- /dev/null
+++ b/lib/puppet/application/file.rb
@@ -0,0 +1,4 @@
+require 'puppet/application/data_baseclass'
+
+class Puppet::Application::File < Puppet::Application::DataBaseclass
+end
diff --git a/lib/puppet/application/file_bucket_file.rb b/lib/puppet/application/file_bucket_file.rb
deleted file mode 100644
index f08a37f90..000000000
--- a/lib/puppet/application/file_bucket_file.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/application/data_baseclass'
-
-class Puppet::Application::File_bucket_file < Puppet::Application::DataBaseclass
-end
diff --git a/lib/puppet/interface.rb b/lib/puppet/interface.rb
index 97e726a76..08a26db90 100644
--- a/lib/puppet/interface.rb
+++ b/lib/puppet/interface.rb
@@ -38,11 +38,17 @@ class Puppet::Interface
end).sort { |a,b| a.to_s <=> b.to_s }
end
+ # Here's your opportunity to override the indirection name. By default
+ # it will be the same name as the interface.
+ def self.indirection_name
+ name.to_sym
+ end
+
# Return an indirection associated with an interface, if one exists
# One usually does.
def self.indirection
unless @indirection
- raise "Could not find data type '#{name}' for interface '#{name}'" unless @indirection = Puppet::Indirector::Indirection.instance(name.to_sym)
+ raise "Could not find data type '#{indirection_name}' for interface '#{name}'" unless @indirection = Puppet::Indirector::Indirection.instance(indirection_name)
end
@indirection
end
@@ -52,6 +58,7 @@ class Puppet::Interface
require "puppet/interface/#{name.to_s.downcase}"
self.const_get(name.to_s.capitalize)
rescue Exception => detail
+ puts detail.backtrace if Puppet[:trace]
$stderr.puts "Unable to find interface '#{name.to_s}': #{detail}."
Kernel::exit(1)
end
@@ -61,7 +68,7 @@ class Puppet::Interface
path = "puppet/interface/#{name}"
autoloader.search_directories.each do |dir|
- fdir = File.join(dir, path)
+ fdir = ::File.join(dir, path)
next unless FileTest.directory?(fdir)
Dir.glob("#{fdir}/*.rb").each do |file|
diff --git a/lib/puppet/interface/file.rb b/lib/puppet/interface/file.rb
new file mode 100644
index 000000000..53c476d7c
--- /dev/null
+++ b/lib/puppet/interface/file.rb
@@ -0,0 +1,7 @@
+require 'puppet/interface'
+
+class Puppet::Interface::File < Puppet::Interface
+ def self.indirection_name
+ :file_bucket_file
+ end
+end
diff --git a/lib/puppet/interface/file_bucket_file.rb b/lib/puppet/interface/file_bucket_file.rb
deleted file mode 100644
index f34ebc4c4..000000000
--- a/lib/puppet/interface/file_bucket_file.rb
+++ /dev/null
@@ -1,4 +0,0 @@
-require 'puppet/interface'
-
-class Puppet::Interface::File_bucket_file < Puppet::Interface
-end