From 809aebec7a54be90990b9ee5fea1f85204598f17 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sun, 30 Jan 2011 17:33:28 -0800 Subject: Moving data executables to their own module Signed-off-by: Luke Kanies --- lib/puppet/application/catalog.rb | 4 ++ lib/puppet/application/certificate.rb | 4 ++ lib/puppet/application/certificate_request.rb | 4 ++ .../application/certificate_revocation_list.rb | 4 ++ lib/puppet/application/data.rb | 84 ++++++++++++++++++++++ lib/puppet/application/data_baseclass.rb | 80 +++++++++++++++++++++ lib/puppet/application/facts.rb | 4 ++ lib/puppet/application/file_bucket_file.rb | 4 ++ lib/puppet/application/inventory.rb | 4 ++ lib/puppet/application/key.rb | 4 ++ lib/puppet/application/node.rb | 4 ++ lib/puppet/application/report.rb | 4 ++ lib/puppet/application/resource_type.rb | 4 ++ lib/puppet/application/status.rb | 4 ++ 14 files changed, 212 insertions(+) create mode 100644 lib/puppet/application/catalog.rb create mode 100644 lib/puppet/application/certificate.rb create mode 100644 lib/puppet/application/certificate_request.rb create mode 100644 lib/puppet/application/certificate_revocation_list.rb create mode 100644 lib/puppet/application/data.rb create mode 100644 lib/puppet/application/data_baseclass.rb create mode 100644 lib/puppet/application/facts.rb create mode 100644 lib/puppet/application/file_bucket_file.rb create mode 100644 lib/puppet/application/inventory.rb create mode 100644 lib/puppet/application/key.rb create mode 100644 lib/puppet/application/node.rb create mode 100644 lib/puppet/application/report.rb create mode 100644 lib/puppet/application/resource_type.rb create mode 100644 lib/puppet/application/status.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/catalog.rb b/lib/puppet/application/catalog.rb new file mode 100644 index 000000000..536d79c29 --- /dev/null +++ b/lib/puppet/application/catalog.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Catalog < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb new file mode 100644 index 000000000..708de07bb --- /dev/null +++ b/lib/puppet/application/certificate.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Certificate < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/certificate_request.rb b/lib/puppet/application/certificate_request.rb new file mode 100644 index 000000000..4363fc1ae --- /dev/null +++ b/lib/puppet/application/certificate_request.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Certificate_request < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/certificate_revocation_list.rb b/lib/puppet/application/certificate_revocation_list.rb new file mode 100644 index 000000000..158ed7b20 --- /dev/null +++ b/lib/puppet/application/certificate_revocation_list.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Certificate_revocation_list < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/data.rb b/lib/puppet/application/data.rb new file mode 100644 index 000000000..cfbf4305a --- /dev/null +++ b/lib/puppet/application/data.rb @@ -0,0 +1,84 @@ +require 'puppet/application' + +class Puppet::Application::Data < Puppet::Application + + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + def list(*arguments) + if arguments.empty? + arguments = %w{terminuses actions} + end + indirections.each do |ind| + str = "#{ind}:\n" + if arguments.include?("terminuses") + begin + terms = terminus_classes(ind.to_sym) + str << "\tTerminuses: #{terms.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + end + end + + if arguments.include?("actions") + begin + actions = actions(ind.to_sym) + str << "\tActions: #{actions.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load actions for #{ind}: #{detail}" + end + end + + print str + end + exit(0) + end + + attr_accessor :verb, :name, :arguments + + def main + # Call the method associated with the provided action (e.g., 'find'). + send(verb, *arguments) + end + + def setup + Puppet::Util::Log.newdestination :console + + @verb, @arguments = command_line.args + @arguments ||= [] + + validate + end + + def validate + unless verb + raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" + end + + unless respond_to?(verb) + raise "Command '#{verb}' not found for 'data'" + end + end + + def indirections + Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort + end + + def terminus_classes(indirection) + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + end + + def actions(indirection) + return [] unless app = Puppet::Application.find(indirection) + return app.actions.sort { |a,b| a.to_s <=> b.to_s } + end +end + diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb new file mode 100644 index 000000000..95142b8ba --- /dev/null +++ b/lib/puppet/application/data_baseclass.rb @@ -0,0 +1,80 @@ +require 'puppet/application' +require 'puppet/interface' + +class Puppet::Application::DataBaseclass < Puppet::Application + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + option("--from TERMINUS", "-f") do |arg| + @from = arg + end + + option("--format FORMAT") do |arg| + @format = arg + end + + # XXX this doesn't work, I think + option("--list") do + indirections.each do |ind| + begin + classes = terminus_classes(ind.to_sym) + rescue => detail + $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + next + end + puts "%-30s: #{classes.join(", ")}" % ind + end + exit(0) + end + + option("--mode RUNMODE", "-r") do |arg| + raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) + self.class.run_mode(arg.to_sym) + set_run_mode self.class.run_mode + end + + + attr_accessor :interface, :from, :type, :verb, :name, :arguments, :indirection, :format + + def main + # Call the method associated with the provided action (e.g., 'find'). + interface.send(verb, name, *arguments) + end + + def setup + @format ||= :yaml + + Puppet::Util::Log.newdestination :console + + @verb, @name, @arguments = command_line.args + @arguments ||= [] + + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + + @interface = Puppet::Interface.interface(@type).new + + validate + + raise "Could not find data type #{type} for application #{self.class.name}" unless @indirection = Puppet::Indirector::Indirection.instance(type) + + @interface.set_terminus(from) if from + end + + def validate + unless verb + raise "You must specify #{interface.actions.join(", ")} as a verb; 'save' probably does not work right now" + end + + unless interface.action?(verb) + raise "Command '#{verb}' not found for #{type}" + end + end +end diff --git a/lib/puppet/application/facts.rb b/lib/puppet/application/facts.rb new file mode 100644 index 000000000..dd79a00d9 --- /dev/null +++ b/lib/puppet/application/facts.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Facts < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/file_bucket_file.rb b/lib/puppet/application/file_bucket_file.rb new file mode 100644 index 000000000..f08a37f90 --- /dev/null +++ b/lib/puppet/application/file_bucket_file.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::File_bucket_file < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/inventory.rb b/lib/puppet/application/inventory.rb new file mode 100644 index 000000000..f54708f24 --- /dev/null +++ b/lib/puppet/application/inventory.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Inventory < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/key.rb b/lib/puppet/application/key.rb new file mode 100644 index 000000000..1197ae026 --- /dev/null +++ b/lib/puppet/application/key.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Key < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/node.rb b/lib/puppet/application/node.rb new file mode 100644 index 000000000..4d7de1ab2 --- /dev/null +++ b/lib/puppet/application/node.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Node < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/report.rb b/lib/puppet/application/report.rb new file mode 100644 index 000000000..e4b5cf440 --- /dev/null +++ b/lib/puppet/application/report.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Report < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/resource_type.rb b/lib/puppet/application/resource_type.rb new file mode 100644 index 000000000..5bd001e88 --- /dev/null +++ b/lib/puppet/application/resource_type.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Resource_type < Puppet::Application::DataBaseclass +end diff --git a/lib/puppet/application/status.rb b/lib/puppet/application/status.rb new file mode 100644 index 000000000..382532f7f --- /dev/null +++ b/lib/puppet/application/status.rb @@ -0,0 +1,4 @@ +require 'puppet/application/data_baseclass' + +class Puppet::Application::Status < Puppet::Application::DataBaseclass +end -- cgit From efca35cbea836fac954fb655d76493f03b36e96f Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Feb 2011 16:24:30 -0800 Subject: Finishing migration from puppet repo The whole system seems to work again, as long as you run it against 2.6.next. Signed-off-by: Luke Kanies --- lib/puppet/application/data.rb | 13 +++++++++++-- lib/puppet/application/data_baseclass.rb | 1 + 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data.rb b/lib/puppet/application/data.rb index cfbf4305a..8d98d4416 100644 --- a/lib/puppet/application/data.rb +++ b/lib/puppet/application/data.rb @@ -52,6 +52,8 @@ class Puppet::Application::Data < Puppet::Application def setup Puppet::Util::Log.newdestination :console + load_applications # Call this to load all of the apps + @verb, @arguments = command_line.args @arguments ||= [] @@ -77,8 +79,15 @@ class Puppet::Application::Data < Puppet::Application end def actions(indirection) - return [] unless app = Puppet::Application.find(indirection) - return app.actions.sort { |a,b| a.to_s <=> b.to_s } + return [] unless interface = Puppet::Interface.interface(indirection) + interface.load_actions + return interface.actions.sort { |a,b| a.to_s <=> b.to_s } + end + + def load_applications + command_line.available_subcommands.each do |app| + command_line.require_application app + end end end diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb index 95142b8ba..3f498f56f 100644 --- a/lib/puppet/application/data_baseclass.rb +++ b/lib/puppet/application/data_baseclass.rb @@ -60,6 +60,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym @interface = Puppet::Interface.interface(@type).new + @interface.format = format if format validate -- cgit From 264a43c835a8131f3a2df5b5cf5c29c8bfcabb67 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Feb 2011 16:26:10 -0800 Subject: Renaming "data" app to "interface" Signed-off-by: Luke Kanies --- lib/puppet/application/data.rb | 93 ------------------------------------- lib/puppet/application/interface.rb | 93 +++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 lib/puppet/application/data.rb create mode 100644 lib/puppet/application/interface.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data.rb b/lib/puppet/application/data.rb deleted file mode 100644 index 8d98d4416..000000000 --- a/lib/puppet/application/data.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'puppet/application' - -class Puppet::Application::Data < Puppet::Application - - should_parse_config - run_mode :agent - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - def list(*arguments) - if arguments.empty? - arguments = %w{terminuses actions} - end - indirections.each do |ind| - str = "#{ind}:\n" - if arguments.include?("terminuses") - begin - terms = terminus_classes(ind.to_sym) - str << "\tTerminuses: #{terms.join(", ")}\n" - rescue => detail - $stderr.puts "Could not load terminuses for #{ind}: #{detail}" - end - end - - if arguments.include?("actions") - begin - actions = actions(ind.to_sym) - str << "\tActions: #{actions.join(", ")}\n" - rescue => detail - $stderr.puts "Could not load actions for #{ind}: #{detail}" - end - end - - print str - end - exit(0) - end - - attr_accessor :verb, :name, :arguments - - def main - # Call the method associated with the provided action (e.g., 'find'). - send(verb, *arguments) - end - - def setup - Puppet::Util::Log.newdestination :console - - load_applications # Call this to load all of the apps - - @verb, @arguments = command_line.args - @arguments ||= [] - - validate - end - - def validate - unless verb - raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" - end - - unless respond_to?(verb) - raise "Command '#{verb}' not found for 'data'" - end - end - - def indirections - Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort - end - - def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort - end - - def actions(indirection) - return [] unless interface = Puppet::Interface.interface(indirection) - interface.load_actions - return interface.actions.sort { |a,b| a.to_s <=> b.to_s } - end - - def load_applications - command_line.available_subcommands.each do |app| - command_line.require_application app - end - end -end - diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb new file mode 100644 index 000000000..8d98d4416 --- /dev/null +++ b/lib/puppet/application/interface.rb @@ -0,0 +1,93 @@ +require 'puppet/application' + +class Puppet::Application::Data < Puppet::Application + + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + def list(*arguments) + if arguments.empty? + arguments = %w{terminuses actions} + end + indirections.each do |ind| + str = "#{ind}:\n" + if arguments.include?("terminuses") + begin + terms = terminus_classes(ind.to_sym) + str << "\tTerminuses: #{terms.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + end + end + + if arguments.include?("actions") + begin + actions = actions(ind.to_sym) + str << "\tActions: #{actions.join(", ")}\n" + rescue => detail + $stderr.puts "Could not load actions for #{ind}: #{detail}" + end + end + + print str + end + exit(0) + end + + attr_accessor :verb, :name, :arguments + + def main + # Call the method associated with the provided action (e.g., 'find'). + send(verb, *arguments) + end + + def setup + Puppet::Util::Log.newdestination :console + + load_applications # Call this to load all of the apps + + @verb, @arguments = command_line.args + @arguments ||= [] + + validate + end + + def validate + unless verb + raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" + end + + unless respond_to?(verb) + raise "Command '#{verb}' not found for 'data'" + end + end + + def indirections + Puppet::Indirector::Indirection.instances.collect { |t| t.to_s }.sort + end + + def terminus_classes(indirection) + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + end + + def actions(indirection) + return [] unless interface = Puppet::Interface.interface(indirection) + interface.load_actions + return interface.actions.sort { |a,b| a.to_s <=> b.to_s } + end + + def load_applications + command_line.available_subcommands.each do |app| + command_line.require_application app + end + end +end + -- cgit From 9cb594f898496e36c76f0717b73897f07e8aca5a Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Feb 2011 16:46:47 -0800 Subject: Finishing the s/data/interface/ in the application Signed-off-by: Luke Kanies --- lib/puppet/application/interface.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index 8d98d4416..db926df86 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -1,6 +1,6 @@ require 'puppet/application' -class Puppet::Application::Data < Puppet::Application +class Puppet::Application::Interface < Puppet::Application should_parse_config run_mode :agent @@ -66,7 +66,7 @@ class Puppet::Application::Data < Puppet::Application end unless respond_to?(verb) - raise "Command '#{verb}' not found for 'data'" + raise "Command '#{verb}' not found for 'interface'" end end -- cgit From 3ffb9abd3a500f1fb3246e04f737b79d232c082d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Feb 2011 21:27:24 -0800 Subject: Moving 'format' support to the application This allows easier use of the Interfaces in ruby. Signed-off-by: Luke Kanies --- lib/puppet/application/data_baseclass.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb index 3f498f56f..e67b1b368 100644 --- a/lib/puppet/application/data_baseclass.rb +++ b/lib/puppet/application/data_baseclass.rb @@ -18,7 +18,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application end option("--format FORMAT") do |arg| - @format = arg + @format = arg.to_sym end # XXX this doesn't work, I think @@ -46,11 +46,11 @@ class Puppet::Application::DataBaseclass < Puppet::Application def main # Call the method associated with the provided action (e.g., 'find'). - interface.send(verb, name, *arguments) + result = interface.send(verb, name, *arguments) + puts result.render(format) end def setup - @format ||= :yaml Puppet::Util::Log.newdestination :console @@ -60,7 +60,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym @interface = Puppet::Interface.interface(@type).new - @interface.format = format if format + @format ||= @interface.class.default_format || :pson validate -- cgit From 9e124e1b3e3f3cd06db7ac58c3aefca3382cd870 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 10 Feb 2011 14:55:23 -0800 Subject: Fixing rendering to support arrays This isn't 100% - it will probably only work for Yaml and JSON - but it's a good start. Signed-off-by: Luke Kanies --- lib/puppet/application/data_baseclass.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb index e67b1b368..8da624c60 100644 --- a/lib/puppet/application/data_baseclass.rb +++ b/lib/puppet/application/data_baseclass.rb @@ -47,7 +47,8 @@ class Puppet::Application::DataBaseclass < Puppet::Application def main # Call the method associated with the provided action (e.g., 'find'). result = interface.send(verb, name, *arguments) - puts result.render(format) + render_method = Puppet::Network::FormatHandler.format(format).render_method + puts result.send(render_method) end def setup -- cgit From b3f903af34c0e27dccb1d043d84c35ea68f44830 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 16 Feb 2011 00:44:44 -0800 Subject: 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 --- lib/puppet/application/data_baseclass.rb | 2 +- lib/puppet/application/file.rb | 4 ++++ lib/puppet/application/file_bucket_file.rb | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 lib/puppet/application/file.rb delete mode 100644 lib/puppet/application/file_bucket_file.rb (limited to 'lib/puppet/application') 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 -- cgit From 7e3a02339a660a76019bf20243a7068325f1af68 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 16 Feb 2011 01:16:15 -0800 Subject: Only printing output if there is any Signed-off-by: Luke Kanies --- lib/puppet/application/data_baseclass.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb index b7393f96c..15ea961dc 100644 --- a/lib/puppet/application/data_baseclass.rb +++ b/lib/puppet/application/data_baseclass.rb @@ -48,7 +48,7 @@ class Puppet::Application::DataBaseclass < Puppet::Application # Call the method associated with the provided action (e.g., 'find'). result = interface.send(verb, name, *arguments) render_method = Puppet::Network::FormatHandler.format(format).render_method - puts result.send(render_method) + puts result.send(render_method) if result end def setup -- cgit From eff4eec9d53d4fb8270799458455fe4bdc47d1df Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Sun, 13 Feb 2011 02:53:23 -0600 Subject: (#3) Base application should catch SYSINT We should exit cleanly rather than throw traces. --- lib/puppet/application/data_baseclass.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb index 15ea961dc..599a217e9 100644 --- a/lib/puppet/application/data_baseclass.rb +++ b/lib/puppet/application/data_baseclass.rb @@ -5,6 +5,14 @@ class Puppet::Application::DataBaseclass < Puppet::Application should_parse_config run_mode :agent + def preinit + super + trap(:INT) do + $stderr.puts "Cancelling Interface" + exit(0) + end + end + option("--debug", "-d") do |arg| Puppet::Util::Log.level = :debug end -- cgit From cde1baa4a9a27ba95ad2a61bc8e46d43e708b081 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sun, 20 Feb 2011 15:39:54 -0800 Subject: Fixing Interface listing It got broke when the Indirector base class was extracted. Signed-off-by: Luke Kanies --- lib/puppet/application/interface.rb | 42 +++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 9 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index db926df86..8f26658c9 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) -- cgit From 0cbdbce0f518d43f0d0160a58dd5ec7253a5af87 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 09:25:21 -0800 Subject: Renaming 'data_baseclass' to 'interface_base' Signed-off-by: Luke Kanies --- lib/puppet/application/catalog.rb | 4 +- lib/puppet/application/certificate.rb | 4 +- lib/puppet/application/certificate_request.rb | 4 +- .../application/certificate_revocation_list.rb | 4 +- lib/puppet/application/data_baseclass.rb | 90 ---------------------- lib/puppet/application/facts.rb | 4 +- lib/puppet/application/file.rb | 4 +- lib/puppet/application/interface_base.rb | 90 ++++++++++++++++++++++ lib/puppet/application/inventory.rb | 4 +- lib/puppet/application/key.rb | 4 +- lib/puppet/application/node.rb | 4 +- lib/puppet/application/report.rb | 4 +- lib/puppet/application/resource_type.rb | 4 +- lib/puppet/application/status.rb | 4 +- 14 files changed, 114 insertions(+), 114 deletions(-) delete mode 100644 lib/puppet/application/data_baseclass.rb create mode 100644 lib/puppet/application/interface_base.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/catalog.rb b/lib/puppet/application/catalog.rb index 536d79c29..0151781a4 100644 --- a/lib/puppet/application/catalog.rb +++ b/lib/puppet/application/catalog.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Catalog < Puppet::Application::DataBaseclass +class Puppet::Application::Catalog < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index 708de07bb..5033372eb 100644 --- a/lib/puppet/application/certificate.rb +++ b/lib/puppet/application/certificate.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Certificate < Puppet::Application::DataBaseclass +class Puppet::Application::Certificate < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/certificate_request.rb b/lib/puppet/application/certificate_request.rb index 4363fc1ae..f92876e95 100644 --- a/lib/puppet/application/certificate_request.rb +++ b/lib/puppet/application/certificate_request.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Certificate_request < Puppet::Application::DataBaseclass +class Puppet::Application::Certificate_request < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/certificate_revocation_list.rb b/lib/puppet/application/certificate_revocation_list.rb index 158ed7b20..9dd3bbba4 100644 --- a/lib/puppet/application/certificate_revocation_list.rb +++ b/lib/puppet/application/certificate_revocation_list.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Certificate_revocation_list < Puppet::Application::DataBaseclass +class Puppet::Application::Certificate_revocation_list < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/data_baseclass.rb b/lib/puppet/application/data_baseclass.rb deleted file mode 100644 index 599a217e9..000000000 --- a/lib/puppet/application/data_baseclass.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'puppet/application' -require 'puppet/interface' - -class Puppet::Application::DataBaseclass < Puppet::Application - should_parse_config - run_mode :agent - - def preinit - super - trap(:INT) do - $stderr.puts "Cancelling Interface" - exit(0) - end - end - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - option("--from TERMINUS", "-f") do |arg| - @from = arg - end - - option("--format FORMAT") do |arg| - @format = arg.to_sym - end - - # XXX this doesn't work, I think - option("--list") do - indirections.each do |ind| - begin - classes = terminus_classes(ind.to_sym) - rescue => detail - $stderr.puts "Could not load terminuses for #{ind}: #{detail}" - next - end - puts "%-30s: #{classes.join(", ")}" % ind - end - exit(0) - end - - option("--mode RUNMODE", "-r") do |arg| - raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) - self.class.run_mode(arg.to_sym) - set_run_mode self.class.run_mode - end - - - attr_accessor :interface, :from, :type, :verb, :name, :arguments, :indirection, :format - - def main - # Call the method associated with the provided action (e.g., 'find'). - result = interface.send(verb, name, *arguments) - render_method = Puppet::Network::FormatHandler.format(format).render_method - puts result.send(render_method) if result - end - - def setup - - Puppet::Util::Log.newdestination :console - - @verb, @name, @arguments = command_line.args - @arguments ||= [] - - @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - - @interface = Puppet::Interface.interface(@type).new - @format ||= @interface.class.default_format || :pson - - validate - - raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection - - @interface.set_terminus(from) if from - end - - def validate - unless verb - raise "You must specify #{interface.actions.join(", ")} as a verb; 'save' probably does not work right now" - end - - unless interface.action?(verb) - raise "Command '#{verb}' not found for #{type}" - end - end -end diff --git a/lib/puppet/application/facts.rb b/lib/puppet/application/facts.rb index dd79a00d9..dfded58f7 100644 --- a/lib/puppet/application/facts.rb +++ b/lib/puppet/application/facts.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Facts < Puppet::Application::DataBaseclass +class Puppet::Application::Facts < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/file.rb b/lib/puppet/application/file.rb index 2acedda86..abf6230a3 100644 --- a/lib/puppet/application/file.rb +++ b/lib/puppet/application/file.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::File < Puppet::Application::DataBaseclass +class Puppet::Application::File < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb new file mode 100644 index 000000000..1dd1f76c2 --- /dev/null +++ b/lib/puppet/application/interface_base.rb @@ -0,0 +1,90 @@ +require 'puppet/application' +require 'puppet/interface' + +class Puppet::Application::InterfaceBase < Puppet::Application + should_parse_config + run_mode :agent + + def preinit + super + trap(:INT) do + $stderr.puts "Cancelling Interface" + exit(0) + end + end + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + option("--from TERMINUS", "-f") do |arg| + @from = arg + end + + option("--format FORMAT") do |arg| + @format = arg.to_sym + end + + # XXX this doesn't work, I think + option("--list") do + indirections.each do |ind| + begin + classes = terminus_classes(ind.to_sym) + rescue => detail + $stderr.puts "Could not load terminuses for #{ind}: #{detail}" + next + end + puts "%-30s: #{classes.join(", ")}" % ind + end + exit(0) + end + + option("--mode RUNMODE", "-r") do |arg| + raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) + self.class.run_mode(arg.to_sym) + set_run_mode self.class.run_mode + end + + + attr_accessor :interface, :from, :type, :verb, :name, :arguments, :indirection, :format + + def main + # Call the method associated with the provided action (e.g., 'find'). + result = interface.send(verb, name, *arguments) + render_method = Puppet::Network::FormatHandler.format(format).render_method + puts result.send(render_method) if result + end + + def setup + + Puppet::Util::Log.newdestination :console + + @verb, @name, @arguments = command_line.args + @arguments ||= [] + + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + + @interface = Puppet::Interface.interface(@type).new + @format ||= @interface.class.default_format || :pson + + validate + + raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection + + @interface.set_terminus(from) if from + end + + def validate + unless verb + raise "You must specify #{interface.actions.join(", ")} as a verb; 'save' probably does not work right now" + end + + unless interface.action?(verb) + raise "Command '#{verb}' not found for #{type}" + end + end +end diff --git a/lib/puppet/application/inventory.rb b/lib/puppet/application/inventory.rb index f54708f24..8a7e466df 100644 --- a/lib/puppet/application/inventory.rb +++ b/lib/puppet/application/inventory.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Inventory < Puppet::Application::DataBaseclass +class Puppet::Application::Inventory < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/key.rb b/lib/puppet/application/key.rb index 1197ae026..1458b9466 100644 --- a/lib/puppet/application/key.rb +++ b/lib/puppet/application/key.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Key < Puppet::Application::DataBaseclass +class Puppet::Application::Key < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/node.rb b/lib/puppet/application/node.rb index 4d7de1ab2..b5f566efc 100644 --- a/lib/puppet/application/node.rb +++ b/lib/puppet/application/node.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Node < Puppet::Application::DataBaseclass +class Puppet::Application::Node < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/report.rb b/lib/puppet/application/report.rb index e4b5cf440..994bc9ef1 100644 --- a/lib/puppet/application/report.rb +++ b/lib/puppet/application/report.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Report < Puppet::Application::DataBaseclass +class Puppet::Application::Report < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/resource_type.rb b/lib/puppet/application/resource_type.rb index 5bd001e88..ecc9f11f6 100644 --- a/lib/puppet/application/resource_type.rb +++ b/lib/puppet/application/resource_type.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Resource_type < Puppet::Application::DataBaseclass +class Puppet::Application::Resource_type < Puppet::Application::InterfaceBase end diff --git a/lib/puppet/application/status.rb b/lib/puppet/application/status.rb index 382532f7f..c34b89013 100644 --- a/lib/puppet/application/status.rb +++ b/lib/puppet/application/status.rb @@ -1,4 +1,4 @@ -require 'puppet/application/data_baseclass' +require 'puppet/application/interface_base' -class Puppet::Application::Status < Puppet::Application::DataBaseclass +class Puppet::Application::Status < Puppet::Application::InterfaceBase end -- cgit From 04fb6de5e2108799e47a081e5331d932fcf53109 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 11:59:19 -0800 Subject: Switching Interfaces to be instances They were previously classes, which made a lot of things stupider than they needed to be. This will likely involve some porting, but not much. Signed-off-by: Luke Kanies --- lib/puppet/application/interface_base.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 1dd1f76c2..9a6c8d9ec 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -68,8 +68,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - @interface = Puppet::Interface.interface(@type).new - @format ||= @interface.class.default_format || :pson + unless @interface = Puppet::Interface.interface(@type) + raise "Could not find interface '#{@type}'" + end + @format ||= @interface.default_format || :pson validate -- cgit From c2715c0f20d916de0284e2d161eb5de32e508244 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 17:13:52 -0800 Subject: Splitting the Application base class We now have an indirection_base class along with interface_base. I've also added some basic tests for most of the interfaces. Signed-off-by: Luke Kanies --- lib/puppet/application/catalog.rb | 4 ++-- lib/puppet/application/certificate.rb | 4 ++-- lib/puppet/application/certificate_request.rb | 4 ++-- .../application/certificate_revocation_list.rb | 4 ++-- lib/puppet/application/facts.rb | 4 ++-- lib/puppet/application/file.rb | 4 ++-- lib/puppet/application/indirection_base.rb | 27 ++++++++++++++++++++++ lib/puppet/application/interface_base.rb | 27 ++-------------------- lib/puppet/application/inventory.rb | 4 ---- lib/puppet/application/key.rb | 4 ++-- lib/puppet/application/node.rb | 4 ++-- lib/puppet/application/report.rb | 4 ++-- lib/puppet/application/resource_type.rb | 4 ++-- lib/puppet/application/status.rb | 4 ++-- 14 files changed, 51 insertions(+), 51 deletions(-) create mode 100644 lib/puppet/application/indirection_base.rb delete mode 100644 lib/puppet/application/inventory.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/catalog.rb b/lib/puppet/application/catalog.rb index 0151781a4..10ce05be7 100644 --- a/lib/puppet/application/catalog.rb +++ b/lib/puppet/application/catalog.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Catalog < Puppet::Application::InterfaceBase +class Puppet::Application::Catalog < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index 5033372eb..4a2b3ef70 100644 --- a/lib/puppet/application/certificate.rb +++ b/lib/puppet/application/certificate.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Certificate < Puppet::Application::InterfaceBase +class Puppet::Application::Certificate < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/certificate_request.rb b/lib/puppet/application/certificate_request.rb index f92876e95..1b1b0830c 100644 --- a/lib/puppet/application/certificate_request.rb +++ b/lib/puppet/application/certificate_request.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Certificate_request < Puppet::Application::InterfaceBase +class Puppet::Application::Certificate_request < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/certificate_revocation_list.rb b/lib/puppet/application/certificate_revocation_list.rb index 9dd3bbba4..60b9d97d6 100644 --- a/lib/puppet/application/certificate_revocation_list.rb +++ b/lib/puppet/application/certificate_revocation_list.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Certificate_revocation_list < Puppet::Application::InterfaceBase +class Puppet::Application::Certificate_revocation_list < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/facts.rb b/lib/puppet/application/facts.rb index dfded58f7..d18b21ea7 100644 --- a/lib/puppet/application/facts.rb +++ b/lib/puppet/application/facts.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Facts < Puppet::Application::InterfaceBase +class Puppet::Application::Facts < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/file.rb b/lib/puppet/application/file.rb index abf6230a3..32a81c7c6 100644 --- a/lib/puppet/application/file.rb +++ b/lib/puppet/application/file.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::File < Puppet::Application::InterfaceBase +class Puppet::Application::File < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb new file mode 100644 index 000000000..3e907696e --- /dev/null +++ b/lib/puppet/application/indirection_base.rb @@ -0,0 +1,27 @@ +require 'puppet/application/interface_base' +require 'puppet/interface' + +class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase + option("--from TERMINUS", "-f") do |arg| + @from = arg + end + + attr_accessor :from, :indirection + + def main + # Call the method associated with the provided action (e.g., 'find'). + result = interface.send(verb, name, *arguments) + render_method = Puppet::Network::FormatHandler.format(format).render_method + puts result.send(render_method) if result + end + + def setup + super + + if interface.respond_to?(:indirection) + raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection + + interface.set_terminus(from) if from + end + end +end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 9a6c8d9ec..9e8ea9948 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -21,28 +21,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application Puppet::Util::Log.level = :info end - option("--from TERMINUS", "-f") do |arg| - @from = arg - end - option("--format FORMAT") do |arg| @format = arg.to_sym end - # XXX this doesn't work, I think - option("--list") do - indirections.each do |ind| - begin - classes = terminus_classes(ind.to_sym) - rescue => detail - $stderr.puts "Could not load terminuses for #{ind}: #{detail}" - next - end - puts "%-30s: #{classes.join(", ")}" % ind - end - exit(0) - end - option("--mode RUNMODE", "-r") do |arg| raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) self.class.run_mode(arg.to_sym) @@ -50,7 +32,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application end - attr_accessor :interface, :from, :type, :verb, :name, :arguments, :indirection, :format + attr_accessor :interface, :type, :verb, :name, :arguments, :format def main # Call the method associated with the provided action (e.g., 'find'). @@ -60,7 +42,6 @@ class Puppet::Application::InterfaceBase < Puppet::Application end def setup - Puppet::Util::Log.newdestination :console @verb, @name, @arguments = command_line.args @@ -71,13 +52,9 @@ class Puppet::Application::InterfaceBase < Puppet::Application unless @interface = Puppet::Interface.interface(@type) raise "Could not find interface '#{@type}'" end - @format ||= @interface.default_format || :pson + @format ||= @interface.default_format validate - - raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection - - @interface.set_terminus(from) if from end def validate diff --git a/lib/puppet/application/inventory.rb b/lib/puppet/application/inventory.rb deleted file mode 100644 index 8a7e466df..000000000 --- a/lib/puppet/application/inventory.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'puppet/application/interface_base' - -class Puppet::Application::Inventory < Puppet::Application::InterfaceBase -end diff --git a/lib/puppet/application/key.rb b/lib/puppet/application/key.rb index 1458b9466..57835b627 100644 --- a/lib/puppet/application/key.rb +++ b/lib/puppet/application/key.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Key < Puppet::Application::InterfaceBase +class Puppet::Application::Key < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/node.rb b/lib/puppet/application/node.rb index b5f566efc..38c1f8610 100644 --- a/lib/puppet/application/node.rb +++ b/lib/puppet/application/node.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Node < Puppet::Application::InterfaceBase +class Puppet::Application::Node < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/report.rb b/lib/puppet/application/report.rb index 994bc9ef1..f7f961edd 100644 --- a/lib/puppet/application/report.rb +++ b/lib/puppet/application/report.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Report < Puppet::Application::InterfaceBase +class Puppet::Application::Report < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/resource_type.rb b/lib/puppet/application/resource_type.rb index ecc9f11f6..59594262c 100644 --- a/lib/puppet/application/resource_type.rb +++ b/lib/puppet/application/resource_type.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Resource_type < Puppet::Application::InterfaceBase +class Puppet::Application::Resource_type < Puppet::Application::IndirectionBase end diff --git a/lib/puppet/application/status.rb b/lib/puppet/application/status.rb index c34b89013..1c3ca054e 100644 --- a/lib/puppet/application/status.rb +++ b/lib/puppet/application/status.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/indirection_base' -class Puppet::Application::Status < Puppet::Application::InterfaceBase +class Puppet::Application::Status < Puppet::Application::IndirectionBase end -- cgit From 368210e8a8a35cf2cae509b1d357337f9958cdff Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 17:38:04 -0800 Subject: Adding a simple "config" app Signed-off-by: Luke Kanies --- lib/puppet/application/config.rb | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 lib/puppet/application/config.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb new file mode 100644 index 000000000..90c5f53c4 --- /dev/null +++ b/lib/puppet/application/config.rb @@ -0,0 +1,4 @@ +require 'puppet/application/interface_base' + +class Puppet::Application::Config < Puppet::Application::InterfaceBase +end -- cgit From bec807e5a12e24c11aedb40a997b154f1bed62c0 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 23:04:45 -0800 Subject: Fixing 'puppet interface list' Also added a test to hopefully confirm it won't break again. Signed-off-by: Luke Kanies --- lib/puppet/application/interface.rb | 30 ++++-------------------------- 1 file changed, 4 insertions(+), 26 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index 8f26658c9..10823e920 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -1,4 +1,5 @@ require 'puppet/application' +require 'puppet/interface' class Puppet::Application::Interface < Puppet::Application @@ -24,6 +25,7 @@ class Puppet::Application::Interface < Puppet::Application terms = terminus_classes(name.to_sym) str << "\tTerminuses: #{terms.join(", ")}\n" rescue => detail + puts detail.backtrace if Puppet[:trace] $stderr.puts "Could not load terminuses for #{name}: #{detail}" end end @@ -33,13 +35,13 @@ class Puppet::Application::Interface < Puppet::Application actions = actions(name.to_sym) str << "\tActions: #{actions.join(", ")}\n" rescue => detail + puts detail.backtrace if Puppet[:trace] $stderr.puts "Could not load actions for #{name}: #{detail}" end end print str end - exit(0) end attr_accessor :verb, :name, :arguments @@ -71,31 +73,7 @@ class Puppet::Application::Interface < Puppet::Application end 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 + Puppet::Interface.interfaces end def terminus_classes(indirection) -- cgit From 4fa54d02a2806e8fde54da9bb7e4d6735b3cffe4 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 22 Feb 2011 23:49:01 -0800 Subject: Adding render and exit_code override support This is mostly in response to feature requests from Dan. Signed-off-by: Luke Kanies --- lib/puppet/application/interface_base.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 9e8ea9948..49c2e9622 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -33,12 +33,26 @@ class Puppet::Application::InterfaceBase < Puppet::Application attr_accessor :interface, :type, :verb, :name, :arguments, :format + attr_writer :exit_code + + # This allows you to set the exit code if you don't want to just exit + # immediately but you need to indicate a failure. + def exit_code + @exit_code || 0 + end def main # Call the method associated with the provided action (e.g., 'find'). - result = interface.send(verb, name, *arguments) + if result = interface.send(verb, name, *arguments) + puts render(result) + end + exit(exit_code) + end + + # Override this if you need custom rendering. + def render(result) render_method = Puppet::Network::FormatHandler.format(format).render_method - puts result.send(render_method) if result + result.send(render_method) end def setup -- cgit From 59a648502a8f09948bd2d25a72a9099f7740e108 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 23 Feb 2011 00:20:15 -0800 Subject: Adding Application options to Interfaces This allows all of the actions to react to the CLI options. I've also removed the unnecessary 'name' variables I was using in various places - they were just the first of the arguments, and they weren't actually always names. Signed-off-by: Luke Kanies --- lib/puppet/application/interface_base.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 49c2e9622..044249d39 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -32,7 +32,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application end - attr_accessor :interface, :type, :verb, :name, :arguments, :format + attr_accessor :interface, :type, :verb, :arguments, :format attr_writer :exit_code # This allows you to set the exit code if you don't want to just exit @@ -43,7 +43,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application def main # Call the method associated with the provided action (e.g., 'find'). - if result = interface.send(verb, name, *arguments) + if result = interface.send(verb, *arguments) puts render(result) end exit(exit_code) @@ -58,7 +58,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application def setup Puppet::Util::Log.newdestination :console - @verb, @name, @arguments = command_line.args + @verb, @arguments = command_line.args @arguments ||= [] @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym @@ -68,6 +68,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application end @format ||= @interface.default_format + # We copy all of the app options to the interface. + # This allows each action to read in the options. + @interface.options = options + validate end -- cgit From 21b541d6ca4b1b76a4e0cd525fa66192c0857a5e Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 24 Feb 2011 08:34:24 -0800 Subject: Fixing plugin usage I had broken some usages of plugins by incorrectly selecting command-line arguments. The fix was to remove the #main method contained in the IndirectionBase subclass. Signed-off-by: Luke Kanies --- lib/puppet/application/indirection_base.rb | 7 ------- lib/puppet/application/interface_base.rb | 2 ++ 2 files changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 3e907696e..e6d172ced 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -8,13 +8,6 @@ class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase attr_accessor :from, :indirection - def main - # Call the method associated with the provided action (e.g., 'find'). - result = interface.send(verb, name, *arguments) - render_method = Puppet::Network::FormatHandler.format(format).render_method - puts result.send(render_method) if result - end - def setup super diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 044249d39..70022f17d 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -61,6 +61,8 @@ class Puppet::Application::InterfaceBase < Puppet::Application @verb, @arguments = command_line.args @arguments ||= [] + @arguments = Array(@arguments) + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym unless @interface = Puppet::Interface.interface(@type) -- cgit From 905ff3aee31775e3fff3ebf8a2eaa6bb2cf0f431 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Sun, 27 Feb 2011 16:34:10 -0800 Subject: Pretty-printing json using "jj" Signed-off-by: Luke Kanies --- lib/puppet/application/interface_base.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 70022f17d..d54ac7922 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -52,7 +52,12 @@ class Puppet::Application::InterfaceBase < Puppet::Application # Override this if you need custom rendering. def render(result) render_method = Puppet::Network::FormatHandler.format(format).render_method - result.send(render_method) + if render_method == "to_pson" + jj result + exit(0) + else + result.send(render_method) + end end def setup -- cgit From 353b9145e465a002f1b66f2a616cce3a8647d370 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Tue, 1 Mar 2011 19:09:20 -0600 Subject: (14) updated interface_base to support multiple command line arguments --- lib/puppet/application/interface_base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index d54ac7922..58fc3b80b 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -63,7 +63,8 @@ class Puppet::Application::InterfaceBase < Puppet::Application def setup Puppet::Util::Log.newdestination :console - @verb, @arguments = command_line.args + @verb = command_line.args.shift + @arguments = command_line.args @arguments ||= [] @arguments = Array(@arguments) -- cgit From 23064bb601622f8a0efaf47c66a9fefec6e62f95 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 2 Mar 2011 17:13:44 -0800 Subject: Adding a test for fix to #14 Signed-off-by: Luke Kanies --- lib/puppet/application/interface_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 58fc3b80b..88f97b69b 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -63,7 +63,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application def setup Puppet::Util::Log.newdestination :console - @verb = command_line.args.shift + @verb = command_line.args.shift @arguments = command_line.args @arguments ||= [] -- cgit From a7173dc2054c4167c71a23fb70e3ca54d07c7447 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Mon, 21 Mar 2011 15:00:17 -0700 Subject: (#6786) Fixing a number of failing tests. The initial merge of this branch hadn't actually been run against the full suite of specs; a number of specs began failing shortly afterward. Reviewed-By: Daniel Pittman --- lib/puppet/application/indirection_base.rb | 2 +- lib/puppet/application/interface_base.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index e6d172ced..764098925 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -2,7 +2,7 @@ require 'puppet/application/interface_base' require 'puppet/interface' class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase - option("--from TERMINUS", "-f") do |arg| + option("--terminus TERMINUS") do |arg| @from = arg end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 88f97b69b..1f18b086c 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -71,7 +71,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - unless @interface = Puppet::Interface.interface(@type) + unless @interface = Puppet::Interface.const_get(@type) raise "Could not find interface '#{@type}'" end @format ||= @interface.default_format -- cgit From ba67cc8a39012a9c28a509d797f46decfdeb32d5 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Mon, 21 Mar 2011 15:04:42 -0700 Subject: (#6785) Internal consistency for `--terminus`. Paired-With: Richard Crowley --- lib/puppet/application/indirection_base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 764098925..2d30aa707 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -3,10 +3,10 @@ require 'puppet/interface' class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase option("--terminus TERMINUS") do |arg| - @from = arg + @terminus = arg end - attr_accessor :from, :indirection + attr_accessor :terminus, :indirection def setup super @@ -14,7 +14,7 @@ class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase if interface.respond_to?(:indirection) raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection - interface.set_terminus(from) if from + interface.set_terminus(terminus) if terminus end end end -- cgit From 84ba21e66660a67e20c1194780138317e6a39d49 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 21 Mar 2011 15:51:21 -0700 Subject: Fixing a load-order issue in Puppet::Interface The application classes were having issues loading the Interface class in certain circumstances because of load order. This just pushes the loading as late as possible. Signed-off-by: Luke Kanies --- lib/puppet/application/indirection_base.rb | 1 - lib/puppet/application/interface_base.rb | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 2d30aa707..7d1c851cf 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,5 +1,4 @@ require 'puppet/application/interface_base' -require 'puppet/interface' class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase option("--terminus TERMINUS") do |arg| diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 1f18b086c..f2c147f1f 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -1,5 +1,4 @@ require 'puppet/application' -require 'puppet/interface' class Puppet::Application::InterfaceBase < Puppet::Application should_parse_config @@ -41,6 +40,11 @@ class Puppet::Application::InterfaceBase < Puppet::Application @exit_code || 0 end + def initialize(*args) + require 'puppet/interface' + super + end + def main # Call the method associated with the provided action (e.g., 'find'). if result = interface.send(verb, *arguments) -- cgit From 63f33d078429a9f589474f9c0778b21d82f38682 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Mon, 21 Mar 2011 14:21:53 -0700 Subject: (#6805) Add a "configurer" application This application is similar in basic functionality to the "agent" application, but implemented in terms of interfaces. It currently will retrieve facts, retrieve a catalog, apply the catalog, and submit a report. Options such as noop and daemonize are still to come. Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/configurer.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 lib/puppet/application/configurer.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb new file mode 100644 index 000000000..70d24814e --- /dev/null +++ b/lib/puppet/application/configurer.rb @@ -0,0 +1,23 @@ +require 'puppet/application' +require 'puppet/interface' + +class Puppet::Application::Configurer < Puppet::Application + should_parse_config + run_mode :agent + + option("--debug","-d") + option("--verbose","-v") + + def setup + if options[:debug] or options[:verbose] + Puppet::Util::Log.level = options[:debug] ? :debug : :info + end + + Puppet::Util::Log.newdestination(:console) + end + + def run_command + report = Puppet::Interface::Configurer.synchronize(Puppet[:certname]) + Puppet::Interface::Report.submit(report) + end +end -- cgit From a58bf959ec49c033e0498916a09e77e303c5792e Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Tue, 22 Mar 2011 13:19:25 -0700 Subject: (#6786) Change interface storage and access. Ruby's namespace mechanism introduced a number of problems, including incorrect name resolution for common and simple cases. Given that, we've refactored back to class-level data structures with accessor methods available. The current method names are unlikely to be the final UI. Reviewed-By: Daniel Pittman --- lib/puppet/application/configurer.rb | 4 ++-- lib/puppet/application/interface_base.rb | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index 70d24814e..378364430 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::Interface::Configurer.synchronize(Puppet[:certname]) - Puppet::Interface::Report.submit(report) + report = Puppet::Interface.interface(:configurer).synchronize(Puppet[:certname]) + Puppet::Interface.interface(:report).submit(report) end end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index f2c147f1f..654674df5 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -75,9 +75,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - unless @interface = Puppet::Interface.const_get(@type) + unless Puppet::Interface.interface?(@type) raise "Could not find interface '#{@type}'" end + @interface = Puppet::Interface.interface(@type) @format ||= @interface.default_format # We copy all of the app options to the interface. -- cgit From 847ac203f9c0b5fce299e87a63b0de5d3ef416f6 Mon Sep 17 00:00:00 2001 From: Nick Lewis Date: Tue, 22 Mar 2011 16:44:01 -0700 Subject: maint: Implement an InterfaceCollection class to manage interfaces Having an instance variable on class Interface is insufficient for Interface::Indirector. This also changes the semantics of "Interface.interface" to handle registration and loading actions, and for "Interface.new" to only instantiate an Interface. Thus, consumers of the API should typically use "Interface.interface", unless they have reasons to not want an interface automatically registered. Paired-With: Pieter van de Bruggen --- lib/puppet/application/interface_base.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 654674df5..7a31ce323 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -1,4 +1,5 @@ require 'puppet/application' +require 'puppet/interface' class Puppet::Application::InterfaceBase < Puppet::Application should_parse_config @@ -40,11 +41,6 @@ class Puppet::Application::InterfaceBase < Puppet::Application @exit_code || 0 end - def initialize(*args) - require 'puppet/interface' - super - end - def main # Call the method associated with the provided action (e.g., 'find'). if result = interface.send(verb, *arguments) -- cgit From 5d7715b0c56c6f06d916126e8470d7edb66d7687 Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Tue, 22 Mar 2011 23:46:21 +0000 Subject: Factoring cert status app back into certificate. --- lib/puppet/application/certificate.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index 4a2b3ef70..edb4eefd3 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 -- cgit From 562bd0f10be966bef725896af9ec3cdc30771ac6 Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Wed, 23 Mar 2011 00:14:59 +0000 Subject: Use the new name for the terminus. --- lib/puppet/application/certificate.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index edb4eefd3..48736fc84 100644 --- a/lib/puppet/application/certificate.rb +++ b/lib/puppet/application/certificate.rb @@ -6,12 +6,7 @@ class Puppet::Application::Certificate < Puppet::Application::IndirectionBase # 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]) + Puppet::SSL::Host.ca_location = arg.to_sym end end -- cgit From 961c7163f336c0dd96f7f72122af9155e1a2260a Mon Sep 17 00:00:00 2001 From: Richard Crowley Date: Wed, 23 Mar 2011 17:45:46 +0000 Subject: Added list action. The common tasks of checking the --ca-location argument and becoming a CA process if necessary (that is, acting like a master) have been abstracted into the Application where they belong. --- lib/puppet/application/certificate.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index 48736fc84..f4b13ffe0 100644 --- a/lib/puppet/application/certificate.rb +++ b/lib/puppet/application/certificate.rb @@ -9,4 +9,19 @@ class Puppet::Application::Certificate < Puppet::Application::IndirectionBase Puppet::SSL::Host.ca_location = arg.to_sym end + def setup + + unless Puppet::SSL::Host.ca_location + raise ArgumentError, "You must have a CA location 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? + self.class.run_mode("master") + self.set_run_mode self.class.run_mode + end + + super + end + end -- cgit From 1187a0eb2550f04d9b6c3dcfdcacdfbb32de0e56 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Wed, 23 Mar 2011 13:59:44 -0700 Subject: (#6770) Add basic versioning for interfaces. Reviewed-By: Nick Lewis --- lib/puppet/application/configurer.rb | 4 ++-- lib/puppet/application/interface.rb | 2 +- lib/puppet/application/interface_base.rb | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index 378364430..a76aaaf01 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::Interface.interface(:configurer).synchronize(Puppet[:certname]) - Puppet::Interface.interface(:report).submit(report) + report = Puppet::Interface.interface(:configurer, 1).synchronize(Puppet[:certname]) + Puppet::Interface.interface(:report, 1).submit(report) end end diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index 10823e920..99c10dc16 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -81,7 +81,7 @@ class Puppet::Application::Interface < Puppet::Application end def actions(indirection) - return [] unless interface = Puppet::Interface.interface(indirection) + return [] unless interface = Puppet::Interface.interface(indirection, 1) interface.load_actions return interface.actions.sort { |a,b| a.to_s <=> b.to_s } end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 7a31ce323..78772833e 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -71,10 +71,11 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - unless Puppet::Interface.interface?(@type) - raise "Could not find interface '#{@type}'" + # TODO: These should be configurable versions. + unless Puppet::Interface.interface?(@type, 1) + raise "Could not find version #{1} of interface '#{@type}'" end - @interface = Puppet::Interface.interface(@type) + @interface = Puppet::Interface.interface(@type, 1) @format ||= @interface.default_format # We copy all of the app options to the interface. -- cgit From 7aa8f2252c7b0512c929fb87a6c3a09a952a142a Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Wed, 23 Mar 2011 16:10:45 -0700 Subject: (#6770) Changing versioning to semver. More information about the versioning scheme can be found at http://semver.org. Paired-With: Nick Lewis --- lib/puppet/application/configurer.rb | 4 ++-- lib/puppet/application/interface.rb | 2 +- lib/puppet/application/interface_base.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index a76aaaf01..92c8d69d0 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::Interface.interface(:configurer, 1).synchronize(Puppet[:certname]) - Puppet::Interface.interface(:report, 1).submit(report) + report = Puppet::Interface.interface(:configurer, '0.0.1').synchronize(Puppet[:certname]) + Puppet::Interface.interface(:report, '0.0.1').submit(report) end end diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index 99c10dc16..3771ecead 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -81,7 +81,7 @@ class Puppet::Application::Interface < Puppet::Application end def actions(indirection) - return [] unless interface = Puppet::Interface.interface(indirection, 1) + return [] unless interface = Puppet::Interface.interface(indirection, '0.0.1') interface.load_actions return interface.actions.sort { |a,b| a.to_s <=> b.to_s } end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 78772833e..7d8885b3f 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -72,10 +72,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym # TODO: These should be configurable versions. - unless Puppet::Interface.interface?(@type, 1) + unless Puppet::Interface.interface?(@type, '0.0.1') raise "Could not find version #{1} of interface '#{@type}'" end - @interface = Puppet::Interface.interface(@type, 1) + @interface = Puppet::Interface.interface(@type, '0.0.1') @format ||= @interface.default_format # We copy all of the app options to the interface. -- cgit From c25fb94725c9abfb36e67938356f97823f8b605e Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Wed, 23 Mar 2011 16:28:28 -0700 Subject: (#6770) Rename Puppet::Interface::interface method. Puppet::Interface::interface is now Puppet::Interface::define, also aliased to Puppet::Interface::[] for convenience. Paired-With: Nick Lewis --- lib/puppet/application/configurer.rb | 4 ++-- lib/puppet/application/interface.rb | 2 +- lib/puppet/application/interface_base.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index 92c8d69d0..5c9af37d7 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::Interface.interface(:configurer, '0.0.1').synchronize(Puppet[:certname]) - Puppet::Interface.interface(:report, '0.0.1').submit(report) + report = Puppet::Interface[:configurer, '0.0.1'].synchronize(Puppet[:certname]) + Puppet::Interface[:report, '0.0.1'].submit(report) end end diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb index 3771ecead..f447dc30d 100644 --- a/lib/puppet/application/interface.rb +++ b/lib/puppet/application/interface.rb @@ -81,7 +81,7 @@ class Puppet::Application::Interface < Puppet::Application end def actions(indirection) - return [] unless interface = Puppet::Interface.interface(indirection, '0.0.1') + return [] unless interface = Puppet::Interface[indirection, '0.0.1'] interface.load_actions return interface.actions.sort { |a,b| a.to_s <=> b.to_s } end diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index 7d8885b3f..c1c02040a 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -75,7 +75,7 @@ class Puppet::Application::InterfaceBase < Puppet::Application unless Puppet::Interface.interface?(@type, '0.0.1') raise "Could not find version #{1} of interface '#{@type}'" end - @interface = Puppet::Interface.interface(@type, '0.0.1') + @interface = Puppet::Interface[@type, '0.0.1'] @format ||= @interface.default_format # We copy all of the app options to the interface. -- cgit From 6aea116701b8e03558ef7a5a15766b267af14281 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Thu, 24 Mar 2011 18:55:32 -0700 Subject: (#6770) Add support for version :latest. Specifying a version of `:latest` will find the most recent version of the named interface installed in your RUBYLIB, and attempt to load that. This is unlikely to provide a stable dependency in the future, so should be used sparingly, acknowledging the dangers. Reviewed-By: Daniel Pittman --- lib/puppet/application/interface_base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb index c1c02040a..841f3ca12 100644 --- a/lib/puppet/application/interface_base.rb +++ b/lib/puppet/application/interface_base.rb @@ -72,10 +72,10 @@ class Puppet::Application::InterfaceBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym # TODO: These should be configurable versions. - unless Puppet::Interface.interface?(@type, '0.0.1') - raise "Could not find version #{1} of interface '#{@type}'" + unless Puppet::Interface.interface?(@type, :latest) + raise "Could not find any version of interface '#{@type}'" end - @interface = Puppet::Interface[@type, '0.0.1'] + @interface = Puppet::Interface[@type, :latest] @format ||= @interface.default_format # We copy all of the app options to the interface. -- cgit From b859baa04737644e40002f511c5941d002a956e3 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Sat, 26 Mar 2011 00:12:17 -0700 Subject: MAINT: the API is officially named "string" as of this moment. Now that we have settled on the final public name for the API, "Puppet::String", mass-rename and mass-edit all the files to follow. Reviewed-By: Randall Hansen --- lib/puppet/application/config.rb | 4 +- lib/puppet/application/configurer.rb | 6 +- lib/puppet/application/indirection_base.rb | 10 +-- lib/puppet/application/interface.rb | 95 ----------------------------- lib/puppet/application/interface_base.rb | 97 ------------------------------ lib/puppet/application/string.rb | 95 +++++++++++++++++++++++++++++ lib/puppet/application/string_base.rb | 97 ++++++++++++++++++++++++++++++ 7 files changed, 202 insertions(+), 202 deletions(-) delete mode 100644 lib/puppet/application/interface.rb delete mode 100644 lib/puppet/application/interface_base.rb create mode 100644 lib/puppet/application/string.rb create mode 100644 lib/puppet/application/string_base.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb index 90c5f53c4..f6559277b 100644 --- a/lib/puppet/application/config.rb +++ b/lib/puppet/application/config.rb @@ -1,4 +1,4 @@ -require 'puppet/application/interface_base' +require 'puppet/application/string_base' -class Puppet::Application::Config < Puppet::Application::InterfaceBase +class Puppet::Application::Config < Puppet::Application::StringBase end diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index 5c9af37d7..b440098ee 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -1,5 +1,5 @@ require 'puppet/application' -require 'puppet/interface' +require 'puppet/string' class Puppet::Application::Configurer < Puppet::Application should_parse_config @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::Interface[:configurer, '0.0.1'].synchronize(Puppet[:certname]) - Puppet::Interface[:report, '0.0.1'].submit(report) + report = Puppet::String[:configurer, '0.0.1'].synchronize(Puppet[:certname]) + Puppet::String[:report, '0.0.1'].submit(report) end end diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 7d1c851cf..da61f408d 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,6 +1,6 @@ -require 'puppet/application/interface_base' +require 'puppet/application/string_base' -class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase +class Puppet::Application::IndirectionBase < Puppet::Application::StringBase option("--terminus TERMINUS") do |arg| @terminus = arg end @@ -10,10 +10,10 @@ class Puppet::Application::IndirectionBase < Puppet::Application::InterfaceBase def setup super - if interface.respond_to?(:indirection) - raise "Could not find data type #{type} for application #{self.class.name}" unless interface.indirection + if string.respond_to?(:indirection) + raise "Could not find data type #{type} for application #{self.class.name}" unless string.indirection - interface.set_terminus(terminus) if terminus + string.set_terminus(terminus) if terminus end end end diff --git a/lib/puppet/application/interface.rb b/lib/puppet/application/interface.rb deleted file mode 100644 index f447dc30d..000000000 --- a/lib/puppet/application/interface.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'puppet/application' -require 'puppet/interface' - -class Puppet::Application::Interface < Puppet::Application - - should_parse_config - run_mode :agent - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - def list(*arguments) - if arguments.empty? - arguments = %w{terminuses actions} - end - interfaces.each do |name| - str = "#{name}:\n" - if arguments.include?("terminuses") - begin - terms = terminus_classes(name.to_sym) - str << "\tTerminuses: #{terms.join(", ")}\n" - rescue => detail - puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not load terminuses for #{name}: #{detail}" - end - end - - if arguments.include?("actions") - begin - actions = actions(name.to_sym) - str << "\tActions: #{actions.join(", ")}\n" - rescue => detail - puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not load actions for #{name}: #{detail}" - end - end - - print str - end - end - - attr_accessor :verb, :name, :arguments - - def main - # Call the method associated with the provided action (e.g., 'find'). - send(verb, *arguments) - end - - def setup - Puppet::Util::Log.newdestination :console - - load_applications # Call this to load all of the apps - - @verb, @arguments = command_line.args - @arguments ||= [] - - validate - end - - def validate - unless verb - raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" - end - - unless respond_to?(verb) - raise "Command '#{verb}' not found for 'interface'" - end - end - - def interfaces - Puppet::Interface.interfaces - end - - def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort - end - - def actions(indirection) - return [] unless interface = Puppet::Interface[indirection, '0.0.1'] - interface.load_actions - return interface.actions.sort { |a,b| a.to_s <=> b.to_s } - end - - def load_applications - command_line.available_subcommands.each do |app| - command_line.require_application app - end - end -end - diff --git a/lib/puppet/application/interface_base.rb b/lib/puppet/application/interface_base.rb deleted file mode 100644 index 841f3ca12..000000000 --- a/lib/puppet/application/interface_base.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'puppet/application' -require 'puppet/interface' - -class Puppet::Application::InterfaceBase < Puppet::Application - should_parse_config - run_mode :agent - - def preinit - super - trap(:INT) do - $stderr.puts "Cancelling Interface" - exit(0) - end - end - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - option("--format FORMAT") do |arg| - @format = arg.to_sym - end - - option("--mode RUNMODE", "-r") do |arg| - raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) - self.class.run_mode(arg.to_sym) - set_run_mode self.class.run_mode - end - - - attr_accessor :interface, :type, :verb, :arguments, :format - attr_writer :exit_code - - # This allows you to set the exit code if you don't want to just exit - # immediately but you need to indicate a failure. - def exit_code - @exit_code || 0 - end - - def main - # Call the method associated with the provided action (e.g., 'find'). - if result = interface.send(verb, *arguments) - puts render(result) - end - exit(exit_code) - end - - # Override this if you need custom rendering. - def render(result) - render_method = Puppet::Network::FormatHandler.format(format).render_method - if render_method == "to_pson" - jj result - exit(0) - else - result.send(render_method) - end - end - - def setup - Puppet::Util::Log.newdestination :console - - @verb = command_line.args.shift - @arguments = command_line.args - @arguments ||= [] - - @arguments = Array(@arguments) - - @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - - # TODO: These should be configurable versions. - unless Puppet::Interface.interface?(@type, :latest) - raise "Could not find any version of interface '#{@type}'" - end - @interface = Puppet::Interface[@type, :latest] - @format ||= @interface.default_format - - # We copy all of the app options to the interface. - # This allows each action to read in the options. - @interface.options = options - - validate - end - - def validate - unless verb - raise "You must specify #{interface.actions.join(", ")} as a verb; 'save' probably does not work right now" - end - - unless interface.action?(verb) - raise "Command '#{verb}' not found for #{type}" - end - end -end diff --git a/lib/puppet/application/string.rb b/lib/puppet/application/string.rb new file mode 100644 index 000000000..aa369e669 --- /dev/null +++ b/lib/puppet/application/string.rb @@ -0,0 +1,95 @@ +require 'puppet/application' +require 'puppet/string' + +class Puppet::Application::String < Puppet::Application + + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + def list(*arguments) + if arguments.empty? + arguments = %w{terminuses actions} + end + strings.each do |name| + str = "#{name}:\n" + if arguments.include?("terminuses") + begin + terms = terminus_classes(name.to_sym) + str << "\tTerminuses: #{terms.join(", ")}\n" + rescue => detail + puts detail.backtrace if Puppet[:trace] + $stderr.puts "Could not load terminuses for #{name}: #{detail}" + end + end + + if arguments.include?("actions") + begin + actions = actions(name.to_sym) + str << "\tActions: #{actions.join(", ")}\n" + rescue => detail + puts detail.backtrace if Puppet[:trace] + $stderr.puts "Could not load actions for #{name}: #{detail}" + end + end + + print str + end + end + + attr_accessor :verb, :name, :arguments + + def main + # Call the method associated with the provided action (e.g., 'find'). + send(verb, *arguments) + end + + def setup + Puppet::Util::Log.newdestination :console + + load_applications # Call this to load all of the apps + + @verb, @arguments = command_line.args + @arguments ||= [] + + validate + end + + def validate + unless verb + raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" + end + + unless respond_to?(verb) + raise "Command '#{verb}' not found for 'string'" + end + end + + def strings + Puppet::String.strings + end + + def terminus_classes(indirection) + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + end + + 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 } + end + + def load_applications + command_line.available_subcommands.each do |app| + command_line.require_application app + end + end +end + diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb new file mode 100644 index 000000000..5b701597d --- /dev/null +++ b/lib/puppet/application/string_base.rb @@ -0,0 +1,97 @@ +require 'puppet/application' +require 'puppet/string' + +class Puppet::Application::StringBase < Puppet::Application + should_parse_config + run_mode :agent + + def preinit + super + trap(:INT) do + $stderr.puts "Cancelling String" + exit(0) + end + end + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + option("--format FORMAT") do |arg| + @format = arg.to_sym + end + + option("--mode RUNMODE", "-r") do |arg| + raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) + self.class.run_mode(arg.to_sym) + set_run_mode self.class.run_mode + end + + + attr_accessor :string, :type, :verb, :arguments, :format + attr_writer :exit_code + + # This allows you to set the exit code if you don't want to just exit + # immediately but you need to indicate a failure. + def exit_code + @exit_code || 0 + end + + def main + # Call the method associated with the provided action (e.g., 'find'). + if result = string.send(verb, *arguments) + puts render(result) + end + exit(exit_code) + end + + # Override this if you need custom rendering. + def render(result) + render_method = Puppet::Network::FormatHandler.format(format).render_method + if render_method == "to_pson" + jj result + exit(0) + else + result.send(render_method) + end + end + + def setup + Puppet::Util::Log.newdestination :console + + @verb = command_line.args.shift + @arguments = command_line.args + @arguments ||= [] + + @arguments = Array(@arguments) + + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + + # TODO: These should be configurable versions. + unless Puppet::String.string?(@type, :latest) + raise "Could not find any version of string '#{@type}'" + end + @string = Puppet::String[@type, :latest] + @format ||= @string.default_format + + # We copy all of the app options to the string. + # This allows each action to read in the options. + @string.options = options + + validate + end + + def validate + unless verb + raise "You must specify #{string.actions.join(", ")} as a verb; 'save' probably does not work right now" + end + + unless string.action?(verb) + raise "Command '#{verb}' not found for #{type}" + end + end +end -- cgit From 4609e203fd47f8159118bb74a8308f9c6aee179f Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Fri, 25 Mar 2011 14:52:48 -0700 Subject: (#6770) Change versioning; adopt :current over :latest. As per discussion with Luke, versions of an interface are first looked up by requiring 'puppet/interface/{name}', and secondarily looked up by requiring '{name}@{version}/puppet/interface/{name}' if the first failed. A version of `:current` can be used to represent the version living in 'puppet/interface/{name}'. Paired-With: Nick Lewis --- lib/puppet/application/string_base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 5b701597d..bc627adde 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -72,10 +72,10 @@ class Puppet::Application::StringBase < Puppet::Application @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym # TODO: These should be configurable versions. - unless Puppet::String.string?(@type, :latest) + unless Puppet::String.string?(@type, :current) raise "Could not find any version of string '#{@type}'" end - @string = Puppet::String[@type, :latest] + @string = Puppet::String[@type, :current] @format ||= @string.default_format # We copy all of the app options to the string. -- cgit From 05b434dca10bbc18d794358a9d08db89a46424f9 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 28 Mar 2011 21:37:05 -0700 Subject: (#6758) Pass options as an argument to string actions. Earlier in their implementation the String prototype would set global state on a String object to reflect options set on the command line. As we move strings away from a CLI-only prototype, this becomes troublesome because we can easily have, for example, HTTP access to a string, which means load balancers can really make this confusing. It also encourages global state pollution, where one invocation can adversely influence another. A better approach is that we pass options to the string action invocation directly; this makes the interaction stateless. Changes required to your code to adapt to the new world: - action(:foo) do |some, args| + action(:foo) do |some, args, options={}| if options[:whatever] then Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/string_base.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index bc627adde..762fbfda8 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -63,11 +63,12 @@ class Puppet::Application::StringBase < Puppet::Application def setup Puppet::Util::Log.newdestination :console + # We copy all of the app options to the end of the call; This allows each + # action to read in the options. This replaces the older model where we + # would invoke the action with options set as global state in the + # interface object. --daniel 2011-03-28 @verb = command_line.args.shift - @arguments = command_line.args - @arguments ||= [] - - @arguments = Array(@arguments) + @arguments = Array(command_line.args) << options @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym @@ -78,10 +79,6 @@ class Puppet::Application::StringBase < Puppet::Application @string = Puppet::String[@type, :current] @format ||= @string.default_format - # We copy all of the app options to the string. - # This allows each action to read in the options. - @string.options = options - validate end -- cgit From a113e8f03d257375bf4eb2416a6ad7e1958d7868 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 29 Mar 2011 15:34:23 -0700 Subject: (#6749) implementing option handling in CLI string wrapper The purpose of this is to adapt the generic option support in our strings to the command line; we adapt the generic option information to optparse, and establish our environment early in the process to ensure that we can play nice with Puppet::Application for the moment. In the process we ensure that we detect, and report, conflicts in option naming across the board. Additionally, when an option is declared with multiple aliases, we insist that either all, or none, of them take an argument. To support this we support introspecting options having an optional argument, as well as documentation and all. Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/indirection_base.rb | 5 +--- lib/puppet/application/string_base.rb | 43 +++++++++++++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index da61f408d..61cfb435e 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,15 +1,12 @@ require 'puppet/application/string_base' class Puppet::Application::IndirectionBase < Puppet::Application::StringBase - option("--terminus TERMINUS") do |arg| - @terminus = arg - end - attr_accessor :terminus, :indirection def setup super + # REVISIT: need to implement this in terms of the string options, eh. if string.respond_to?(:indirection) raise "Could not find data type #{type} for application #{self.class.name}" unless string.indirection diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 762fbfda8..ffd49e8c0 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -60,6 +60,39 @@ class Puppet::Application::StringBase < Puppet::Application end end + def preinit + # We need to parse enough of the command line out early, to identify what + # the action is, so that we can obtain the full set of options to parse. + # + # This requires a partial parse first, and removing the options that we + # understood, then identification of the next item, then another round of + # the same until we have the string and action all set. --daniel 2011-03-29 + # + # NOTE: We can't use the Puppet::Application implementation of option + # parsing because it is (*ahem*) going to puts on $stderr and exit when it + # hits a parse problem, not actually let us reuse stuff. --daniel 2011-03-29 + + # TODO: These should be configurable versions, through a global + # '--version' option, but we don't implement that yet... --daniel 2011-03-29 + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + @string = Puppet::String[@type, :current] + @format = @string.default_format + + # Now, collect the global and string options and parse the command line. + begin + @string.options.inject OptionParser.new do |options, option| + option = @string.get_option option # turn it into the object, bleh + options.on(*option.to_optparse) do |value| + puts "REVISIT: do something with #{value.inspect}" + end + end.parse! command_line.args.dup + rescue OptionParser::InvalidOption => e + puts e.inspect # ...and ignore?? + end + + fail "REVISIT: Finish this code, eh..." + end + def setup Puppet::Util::Log.newdestination :console @@ -69,16 +102,6 @@ class Puppet::Application::StringBase < Puppet::Application # interface object. --daniel 2011-03-28 @verb = command_line.args.shift @arguments = Array(command_line.args) << options - - @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - - # TODO: These should be configurable versions. - unless Puppet::String.string?(@type, :current) - raise "Could not find any version of string '#{@type}'" - end - @string = Puppet::String[@type, :current] - @format ||= @string.default_format - validate end -- cgit From 423fe1f6b7c5bc0ca9b53a87f636668514802ad7 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Wed, 30 Mar 2011 16:58:17 -0700 Subject: (#6749) string cli base: implement preinit CLI parsing In order to identify the full set of options we need to know the action that is being invoked; that actually requires a pre-processing step to identify that out of the global options. Notably, our spec is that options can be to the right of their declaration point, but not to the left: that means that we can now extract the full set of options, and interact with the standard Puppet option handling code, resulting in at least vaguely saner behaviour... Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/string_base.rb | 90 +++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 41 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index ffd49e8c0..1169a45a4 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -5,14 +5,6 @@ class Puppet::Application::StringBase < Puppet::Application should_parse_config run_mode :agent - def preinit - super - trap(:INT) do - $stderr.puts "Cancelling String" - exit(0) - end - end - option("--debug", "-d") do |arg| Puppet::Util::Log.level = :debug end @@ -32,7 +24,7 @@ class Puppet::Application::StringBase < Puppet::Application end - attr_accessor :string, :type, :verb, :arguments, :format + attr_accessor :string, :action, :type, :arguments, :format attr_writer :exit_code # This allows you to set the exit code if you don't want to just exit @@ -41,14 +33,6 @@ class Puppet::Application::StringBase < Puppet::Application @exit_code || 0 end - def main - # Call the method associated with the provided action (e.g., 'find'). - if result = string.send(verb, *arguments) - puts render(result) - end - exit(exit_code) - end - # Override this if you need custom rendering. def render(result) render_method = Puppet::Network::FormatHandler.format(format).render_method @@ -61,16 +45,14 @@ class Puppet::Application::StringBase < Puppet::Application end def preinit + super + trap(:INT) do + $stderr.puts "Cancelling String" + exit(0) + end + # We need to parse enough of the command line out early, to identify what # the action is, so that we can obtain the full set of options to parse. - # - # This requires a partial parse first, and removing the options that we - # understood, then identification of the next item, then another round of - # the same until we have the string and action all set. --daniel 2011-03-29 - # - # NOTE: We can't use the Puppet::Application implementation of option - # parsing because it is (*ahem*) going to puts on $stderr and exit when it - # hits a parse problem, not actually let us reuse stuff. --daniel 2011-03-29 # TODO: These should be configurable versions, through a global # '--version' option, but we don't implement that yet... --daniel 2011-03-29 @@ -78,19 +60,42 @@ class Puppet::Application::StringBase < Puppet::Application @string = Puppet::String[@type, :current] @format = @string.default_format - # Now, collect the global and string options and parse the command line. - begin - @string.options.inject OptionParser.new do |options, option| - option = @string.get_option option # turn it into the object, bleh - options.on(*option.to_optparse) do |value| - puts "REVISIT: do something with #{value.inspect}" + # Now, walk the command line and identify the action. We skip over + # arguments based on introspecting the action and all, and find the first + # non-option word to use as the action. + action = nil + cli = command_line.args.dup # we destroy this copy, but... + while @action.nil? and not cli.empty? do + item = cli.shift + if item =~ /^-/ then + option = @string.options.find { |a| item =~ /^-+#{a}\b/ } + if option then + if @string.get_option(option).takes_argument? then + # We don't validate if the argument is optional or mandatory, + # because it doesn't matter here. We just assume that errors will + # be caught later. --daniel 2011-03-30 + cli.shift unless cli.first =~ /^-/ + end + else + raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" end - end.parse! command_line.args.dup - rescue OptionParser::InvalidOption => e - puts e.inspect # ...and ignore?? + else + action = @string.get_action(item.to_sym) + if action.nil? then + raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" + end + @action = action + end end - fail "REVISIT: Finish this code, eh..." + @action or raise ArgumentError, "No action given on the command line!" + + # Finally, we can interact with the default option code to build behaviour + # around the full set of options we now know we support. + @action.options.each do |option| + option = @action.get_option(option) # make it the object. + self.class.option(*option.optparse) # ...and make the CLI parse it. + end end def setup @@ -100,18 +105,21 @@ class Puppet::Application::StringBase < Puppet::Application # action to read in the options. This replaces the older model where we # would invoke the action with options set as global state in the # interface object. --daniel 2011-03-28 - @verb = command_line.args.shift @arguments = Array(command_line.args) << options validate end + + def main + # Call the method associated with the provided action (e.g., 'find'). + if result = @string.send(@action.name, *arguments) + puts render(result) + end + exit(exit_code) + end def validate - unless verb + unless @action raise "You must specify #{string.actions.join(", ")} as a verb; 'save' probably does not work right now" end - - unless string.action?(verb) - raise "Command '#{verb}' not found for #{type}" - end end end -- cgit From 1635454755fa8fdc0dedf032c543d3f4006aa568 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 31 Mar 2011 10:45:33 -0700 Subject: (#6749) Remove "save does not work" language from strings. Now we are pushing into production we can eliminate this language, which was a legacy from the prototype that is no longer relevant globally. Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/string_base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 1169a45a4..09e42a5ef 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -119,7 +119,7 @@ class Puppet::Application::StringBase < Puppet::Application end def validate unless @action - raise "You must specify #{string.actions.join(", ")} as a verb; 'save' probably does not work right now" + raise "You must specify #{string.actions.join(", ")} as a verb" end end end -- cgit From 8723b1c2102a181d23c9fe4ede7d58294f7c18ba Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 31 Mar 2011 16:48:50 -0700 Subject: (#6749) code and test cleanup of Application/StringBase. This removes dead code now we have terminus in the base string, and disables some tests on StringBase app until they can be rewritten. Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/indirection_base.rb | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index 61cfb435e..cfa1ea529 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,16 +1,4 @@ require 'puppet/application/string_base' class Puppet::Application::IndirectionBase < Puppet::Application::StringBase - attr_accessor :terminus, :indirection - - def setup - super - - # REVISIT: need to implement this in terms of the string options, eh. - if string.respond_to?(:indirection) - raise "Could not find data type #{type} for application #{self.class.name}" unless string.indirection - - string.set_terminus(terminus) if terminus - end - end end -- cgit From eb4c4fbdc3951c220a76ec01abc33a7654d89e53 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Fri, 1 Apr 2011 10:44:35 -0700 Subject: (#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 --- lib/puppet/application/configurer.rb | 4 ++-- lib/puppet/application/string.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index b440098ee..be018338f 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 aa369e669..0a6a798ce 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 -- cgit From 8b37d7038c89bd830b076e838686419ff0068b56 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Fri, 1 Apr 2011 15:16:55 -0700 Subject: (#6749) Polish the CLI option pre-parse implementation This improves handling of the pre-parse of the command line to be non-destructive, which cuts down the volume of garbage generated in the process. It also improves testing to verify that we get the darn thing right... Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/string_base.rb | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 09e42a5ef..6032e32f8 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -64,9 +64,9 @@ class Puppet::Application::StringBase < Puppet::Application # arguments based on introspecting the action and all, and find the first # non-option word to use as the action. action = nil - cli = command_line.args.dup # we destroy this copy, but... - while @action.nil? and not cli.empty? do - item = cli.shift + index = -1 + while (index += 1) < command_line.args.length do + item = command_line.args[index] if item =~ /^-/ then option = @string.options.find { |a| item =~ /^-+#{a}\b/ } if option then @@ -74,7 +74,7 @@ class Puppet::Application::StringBase < Puppet::Application # We don't validate if the argument is optional or mandatory, # because it doesn't matter here. We just assume that errors will # be caught later. --daniel 2011-03-30 - cli.shift unless cli.first =~ /^-/ + index += 1 unless command_line.args[index + 1] =~ /^-/ end else raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" @@ -85,6 +85,7 @@ class Puppet::Application::StringBase < Puppet::Application raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" end @action = action + command_line.args.delete_at(index) end end @@ -105,8 +106,8 @@ class Puppet::Application::StringBase < Puppet::Application # action to read in the options. This replaces the older model where we # would invoke the action with options set as global state in the # interface object. --daniel 2011-03-28 - @arguments = Array(command_line.args) << options - validate + @arguments = command_line.args + @arguments << options end @@ -117,9 +118,4 @@ class Puppet::Application::StringBase < Puppet::Application end exit(exit_code) end - def validate - unless @action - raise "You must specify #{string.actions.join(", ")} as a verb" - end - end end -- cgit From 5a0b547f3289cb8e13b197d021322e03d05bee8e Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 4 Apr 2011 11:04:17 -0700 Subject: (#6749) Fix optional vs mandatory argument handling. optparse will treat '--foo --bar' as "foo with the argument --bar" when foo takes a mandatory argument. We need to emulate that behaviour in our pre-parse of the command line. Incidentally, fix up a bug in boolean options, and improve our testing. Reviewed-By: Nick Lewis --- lib/puppet/application/string_base.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 6032e32f8..a082ba0e2 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -65,16 +65,15 @@ class Puppet::Application::StringBase < Puppet::Application # non-option word to use as the action. action = nil index = -1 - while (index += 1) < command_line.args.length do + until @action or (index += 1) >= command_line.args.length do item = command_line.args[index] if item =~ /^-/ then option = @string.options.find { |a| item =~ /^-+#{a}\b/ } if option then - if @string.get_option(option).takes_argument? then - # We don't validate if the argument is optional or mandatory, - # because it doesn't matter here. We just assume that errors will - # be caught later. --daniel 2011-03-30 - index += 1 unless command_line.args[index + 1] =~ /^-/ + option = @string.get_option(option) + if option.takes_argument? then + index += 1 unless + (option.optional_argument? and command_line.args[index + 1] =~ /^-/) end else raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" -- cgit From cec3b6e2627ea2340e46c2e498f4d41522140094 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 4 Apr 2011 11:19:26 -0700 Subject: (#6749) Extract the action from the arguments cleanly. This adds a test to verify that we are correctly removing the action name from the set of arguments passed to the string action, then cleans up the previous code so we don't need to mutilate the command line arguments: we can just extract it from the resultant set of information. Reviewed-By: Nick Lewis --- lib/puppet/application/string_base.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index a082ba0e2..8284a3185 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -84,7 +84,6 @@ class Puppet::Application::StringBase < Puppet::Application raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" end @action = action - command_line.args.delete_at(index) end end @@ -105,7 +104,12 @@ class Puppet::Application::StringBase < Puppet::Application # action to read in the options. This replaces the older model where we # would invoke the action with options set as global state in the # interface object. --daniel 2011-03-28 - @arguments = command_line.args + # + # Note: because of our definition of where the action is set, we end up + # with it *always* being the first word of the remaining set of command + # line arguments. So, strip that off when we construct the arguments to + # pass down to the string action. --daniel 2011-04-04 + @arguments = command_line.args[1, -1] || [] @arguments << options end -- cgit From 0c74495529bd697cdc42986882fc3efb4cdc9903 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 4 Apr 2011 11:35:46 -0700 Subject: (#6749) Handle options with inline arguments. We didn't correctly handle '--foo=bar' as having supplied an argument during the pre-parse phase. Now we have a test for it, and a fix in the code. Reviewed-By: Nick Lewis --- lib/puppet/application/string_base.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 8284a3185..06e5789be 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -71,7 +71,11 @@ class Puppet::Application::StringBase < Puppet::Application option = @string.options.find { |a| item =~ /^-+#{a}\b/ } if option then option = @string.get_option(option) - if option.takes_argument? then + # If we have an inline argument, just carry on. We don't need to + # care about optional vs mandatory in that case because we do a real + # parse later, and that will totally take care of raising the error + # when we get there. --daniel 2011-04-04 + if option.takes_argument? and !item.index('=') then index += 1 unless (option.optional_argument? and command_line.args[index + 1] =~ /^-/) end -- cgit From 0950d09d12ec06e97915d264e8724e736c84e36a Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Mon, 4 Apr 2011 14:46:21 -0700 Subject: (#6949) Fix passing positional arguments to actions. We had a logic failure that didn't pass positional arguments at all, but which our testing didn't verify. This entirely broke things. Now fixed, and a test added to ensure we don't bug out further... Reviewed-By: Pieter van de Bruggen --- lib/puppet/application/string_base.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 06e5789be..76b0a46fd 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -104,16 +104,18 @@ class Puppet::Application::StringBase < Puppet::Application def setup Puppet::Util::Log.newdestination :console - # We copy all of the app options to the end of the call; This allows each - # action to read in the options. This replaces the older model where we - # would invoke the action with options set as global state in the - # interface object. --daniel 2011-03-28 - # + @arguments = command_line.args + # Note: because of our definition of where the action is set, we end up # with it *always* being the first word of the remaining set of command # line arguments. So, strip that off when we construct the arguments to # pass down to the string action. --daniel 2011-04-04 - @arguments = command_line.args[1, -1] || [] + @arguments.delete_at(0) + + # We copy all of the app options to the end of the call; This allows each + # action to read in the options. This replaces the older model where we + # would invoke the action with options set as global state in the + # interface object. --daniel 2011-03-28 @arguments << options end -- cgit From 7e7d246bf46349c904c76a31951d4a40c200790b Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 5 Apr 2011 11:37:51 -0700 Subject: (#6972) Recognize puppet global options in pre-parse. This extends the CLI pre-parse phase to identify both string *and* global options out of the Puppet settings/defaults system. This makes the regular CLI support for setting Puppet configuration globals work as expected. This moves us along the line of supporting these options more fully. Reviewed-By: Dan Bode --- lib/puppet/application/string_base.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb index 76b0a46fd..09d02c079 100644 --- a/lib/puppet/application/string_base.rb +++ b/lib/puppet/application/string_base.rb @@ -68,7 +68,9 @@ class Puppet::Application::StringBase < Puppet::Application until @action or (index += 1) >= command_line.args.length do item = command_line.args[index] if item =~ /^-/ then - option = @string.options.find { |a| item =~ /^-+#{a}\b/ } + option = @string.options.find do |name| + item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/ + end if option then option = @string.get_option(option) # If we have an inline argument, just carry on. We don't need to @@ -79,6 +81,12 @@ class Puppet::Application::StringBase < Puppet::Application index += 1 unless (option.optional_argument? and command_line.args[index + 1] =~ /^-/) end + elsif option = find_global_settings_argument(item) then + unless Puppet.settings.boolean? option.name then + # As far as I can tell, we treat non-bool options as always having + # a mandatory argument. --daniel 2011-04-05 + index += 1 # ...so skip the argument. + end else raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" end @@ -101,6 +109,18 @@ class Puppet::Application::StringBase < Puppet::Application end end + def find_global_settings_argument(item) + Puppet.settings.each do |name, object| + object.optparse_args.each do |arg| + next unless arg =~ /^-/ + # sadly, we have to emulate some of optparse here... + pattern = /^#{arg.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ + pattern.match item and return object + end + end + return nil # nothing found. + end + def setup Puppet::Util::Log.newdestination :console -- cgit From a03790d82a2c190d6f00ee7677617a7be04aa85d Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Tue, 5 Apr 2011 18:39:19 -0700 Subject: (#6972) Handle ca-location in the certificate string. This ports the existing certificate location configuration to be a string option, and then uses that to change the configuration. This will leak state between calls, which is somewhat unavoidable, but should at least get the basic stuff right for the CLI. We eventually need the CA string to be supported by a stateless internal CA implementation that allows us to do the right thing overall. Reviewed-By: Dan Bode --- lib/puppet/application/certificate.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/certificate.rb b/lib/puppet/application/certificate.rb index f4b13ffe0..eacb830b2 100644 --- a/lib/puppet/application/certificate.rb +++ b/lib/puppet/application/certificate.rb @@ -1,18 +1,10 @@ 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| - Puppet::SSL::Host.ca_location = arg.to_sym - end - def setup - - unless Puppet::SSL::Host.ca_location - raise ArgumentError, "You must have a CA location specified; use --ca-location to specify the location (remote, local, only)" + unless options[:ca_location] + raise ArgumentError, "You must have a CA location specified;\n" + + "use --ca-location to specify the location (remote, local, only)" end location = Puppet::SSL::Host.ca_location @@ -23,5 +15,4 @@ class Puppet::Application::Certificate < Puppet::Application::IndirectionBase super end - end -- cgit From 5592034fdb8bf3a72ab3133d69443490f9ad7b78 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 7 Apr 2011 13:18:26 -0700 Subject: (#7012) global rename of strings to faces. This just changes filenames and directories; files are exact copies rather than having additional modifications to make clearer each step of this process. This does leave a currently broken build. :/ --- lib/puppet/application/faces.rb | 95 +++++++++++++++++++++ lib/puppet/application/faces_base.rb | 150 ++++++++++++++++++++++++++++++++++ lib/puppet/application/string.rb | 95 --------------------- lib/puppet/application/string_base.rb | 150 ---------------------------------- 4 files changed, 245 insertions(+), 245 deletions(-) create mode 100644 lib/puppet/application/faces.rb create mode 100644 lib/puppet/application/faces_base.rb delete mode 100644 lib/puppet/application/string.rb delete mode 100644 lib/puppet/application/string_base.rb (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/faces.rb b/lib/puppet/application/faces.rb new file mode 100644 index 000000000..0a6a798ce --- /dev/null +++ b/lib/puppet/application/faces.rb @@ -0,0 +1,95 @@ +require 'puppet/application' +require 'puppet/string' + +class Puppet::Application::String < Puppet::Application + + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + def list(*arguments) + if arguments.empty? + arguments = %w{terminuses actions} + end + strings.each do |name| + str = "#{name}:\n" + if arguments.include?("terminuses") + begin + terms = terminus_classes(name.to_sym) + str << "\tTerminuses: #{terms.join(", ")}\n" + rescue => detail + puts detail.backtrace if Puppet[:trace] + $stderr.puts "Could not load terminuses for #{name}: #{detail}" + end + end + + if arguments.include?("actions") + begin + actions = actions(name.to_sym) + str << "\tActions: #{actions.join(", ")}\n" + rescue => detail + puts detail.backtrace if Puppet[:trace] + $stderr.puts "Could not load actions for #{name}: #{detail}" + end + end + + print str + end + end + + attr_accessor :verb, :name, :arguments + + def main + # Call the method associated with the provided action (e.g., 'find'). + send(verb, *arguments) + end + + def setup + Puppet::Util::Log.newdestination :console + + load_applications # Call this to load all of the apps + + @verb, @arguments = command_line.args + @arguments ||= [] + + validate + end + + def validate + unless verb + raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" + end + + unless respond_to?(verb) + raise "Command '#{verb}' not found for 'string'" + end + end + + def strings + Puppet::String.strings + end + + def terminus_classes(indirection) + Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort + end + + 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 } + end + + def load_applications + command_line.available_subcommands.each do |app| + command_line.require_application app + end + end +end + diff --git a/lib/puppet/application/faces_base.rb b/lib/puppet/application/faces_base.rb new file mode 100644 index 000000000..09d02c079 --- /dev/null +++ b/lib/puppet/application/faces_base.rb @@ -0,0 +1,150 @@ +require 'puppet/application' +require 'puppet/string' + +class Puppet::Application::StringBase < Puppet::Application + should_parse_config + run_mode :agent + + option("--debug", "-d") do |arg| + Puppet::Util::Log.level = :debug + end + + option("--verbose", "-v") do + Puppet::Util::Log.level = :info + end + + option("--format FORMAT") do |arg| + @format = arg.to_sym + end + + option("--mode RUNMODE", "-r") do |arg| + raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) + self.class.run_mode(arg.to_sym) + set_run_mode self.class.run_mode + end + + + attr_accessor :string, :action, :type, :arguments, :format + attr_writer :exit_code + + # This allows you to set the exit code if you don't want to just exit + # immediately but you need to indicate a failure. + def exit_code + @exit_code || 0 + end + + # Override this if you need custom rendering. + def render(result) + render_method = Puppet::Network::FormatHandler.format(format).render_method + if render_method == "to_pson" + jj result + exit(0) + else + result.send(render_method) + end + end + + def preinit + super + trap(:INT) do + $stderr.puts "Cancelling String" + exit(0) + end + + # We need to parse enough of the command line out early, to identify what + # the action is, so that we can obtain the full set of options to parse. + + # TODO: These should be configurable versions, through a global + # '--version' option, but we don't implement that yet... --daniel 2011-03-29 + @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym + @string = Puppet::String[@type, :current] + @format = @string.default_format + + # Now, walk the command line and identify the action. We skip over + # arguments based on introspecting the action and all, and find the first + # non-option word to use as the action. + action = nil + index = -1 + until @action or (index += 1) >= command_line.args.length do + item = command_line.args[index] + if item =~ /^-/ then + option = @string.options.find do |name| + item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/ + end + if option then + option = @string.get_option(option) + # If we have an inline argument, just carry on. We don't need to + # care about optional vs mandatory in that case because we do a real + # parse later, and that will totally take care of raising the error + # when we get there. --daniel 2011-04-04 + if option.takes_argument? and !item.index('=') then + index += 1 unless + (option.optional_argument? and command_line.args[index + 1] =~ /^-/) + end + elsif option = find_global_settings_argument(item) then + unless Puppet.settings.boolean? option.name then + # As far as I can tell, we treat non-bool options as always having + # a mandatory argument. --daniel 2011-04-05 + index += 1 # ...so skip the argument. + end + else + raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" + end + else + action = @string.get_action(item.to_sym) + if action.nil? then + raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" + end + @action = action + end + end + + @action or raise ArgumentError, "No action given on the command line!" + + # Finally, we can interact with the default option code to build behaviour + # around the full set of options we now know we support. + @action.options.each do |option| + option = @action.get_option(option) # make it the object. + self.class.option(*option.optparse) # ...and make the CLI parse it. + end + end + + def find_global_settings_argument(item) + Puppet.settings.each do |name, object| + object.optparse_args.each do |arg| + next unless arg =~ /^-/ + # sadly, we have to emulate some of optparse here... + pattern = /^#{arg.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ + pattern.match item and return object + end + end + return nil # nothing found. + end + + def setup + Puppet::Util::Log.newdestination :console + + @arguments = command_line.args + + # Note: because of our definition of where the action is set, we end up + # with it *always* being the first word of the remaining set of command + # line arguments. So, strip that off when we construct the arguments to + # pass down to the string action. --daniel 2011-04-04 + @arguments.delete_at(0) + + # We copy all of the app options to the end of the call; This allows each + # action to read in the options. This replaces the older model where we + # would invoke the action with options set as global state in the + # interface object. --daniel 2011-03-28 + @arguments << options + end + + + def main + # Call the method associated with the provided action (e.g., 'find'). + if result = @string.send(@action.name, *arguments) + puts render(result) + end + exit(exit_code) + end +end diff --git a/lib/puppet/application/string.rb b/lib/puppet/application/string.rb deleted file mode 100644 index 0a6a798ce..000000000 --- a/lib/puppet/application/string.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'puppet/application' -require 'puppet/string' - -class Puppet::Application::String < Puppet::Application - - should_parse_config - run_mode :agent - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - def list(*arguments) - if arguments.empty? - arguments = %w{terminuses actions} - end - strings.each do |name| - str = "#{name}:\n" - if arguments.include?("terminuses") - begin - terms = terminus_classes(name.to_sym) - str << "\tTerminuses: #{terms.join(", ")}\n" - rescue => detail - puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not load terminuses for #{name}: #{detail}" - end - end - - if arguments.include?("actions") - begin - actions = actions(name.to_sym) - str << "\tActions: #{actions.join(", ")}\n" - rescue => detail - puts detail.backtrace if Puppet[:trace] - $stderr.puts "Could not load actions for #{name}: #{detail}" - end - end - - print str - end - end - - attr_accessor :verb, :name, :arguments - - def main - # Call the method associated with the provided action (e.g., 'find'). - send(verb, *arguments) - end - - def setup - Puppet::Util::Log.newdestination :console - - load_applications # Call this to load all of the apps - - @verb, @arguments = command_line.args - @arguments ||= [] - - validate - end - - def validate - unless verb - raise "You must specify 'find', 'search', 'save', or 'destroy' as a verb; 'save' probably does not work right now" - end - - unless respond_to?(verb) - raise "Command '#{verb}' not found for 'string'" - end - end - - def strings - Puppet::String.strings - end - - def terminus_classes(indirection) - Puppet::Indirector::Terminus.terminus_classes(indirection).collect { |t| t.to_s }.sort - end - - 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 } - end - - def load_applications - command_line.available_subcommands.each do |app| - command_line.require_application app - end - end -end - diff --git a/lib/puppet/application/string_base.rb b/lib/puppet/application/string_base.rb deleted file mode 100644 index 09d02c079..000000000 --- a/lib/puppet/application/string_base.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'puppet/application' -require 'puppet/string' - -class Puppet::Application::StringBase < Puppet::Application - should_parse_config - run_mode :agent - - option("--debug", "-d") do |arg| - Puppet::Util::Log.level = :debug - end - - option("--verbose", "-v") do - Puppet::Util::Log.level = :info - end - - option("--format FORMAT") do |arg| - @format = arg.to_sym - end - - option("--mode RUNMODE", "-r") do |arg| - raise "Invalid run mode #{arg}; supported modes are user, agent, master" unless %w{user agent master}.include?(arg) - self.class.run_mode(arg.to_sym) - set_run_mode self.class.run_mode - end - - - attr_accessor :string, :action, :type, :arguments, :format - attr_writer :exit_code - - # This allows you to set the exit code if you don't want to just exit - # immediately but you need to indicate a failure. - def exit_code - @exit_code || 0 - end - - # Override this if you need custom rendering. - def render(result) - render_method = Puppet::Network::FormatHandler.format(format).render_method - if render_method == "to_pson" - jj result - exit(0) - else - result.send(render_method) - end - end - - def preinit - super - trap(:INT) do - $stderr.puts "Cancelling String" - exit(0) - end - - # We need to parse enough of the command line out early, to identify what - # the action is, so that we can obtain the full set of options to parse. - - # TODO: These should be configurable versions, through a global - # '--version' option, but we don't implement that yet... --daniel 2011-03-29 - @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - @string = Puppet::String[@type, :current] - @format = @string.default_format - - # Now, walk the command line and identify the action. We skip over - # arguments based on introspecting the action and all, and find the first - # non-option word to use as the action. - action = nil - index = -1 - until @action or (index += 1) >= command_line.args.length do - item = command_line.args[index] - if item =~ /^-/ then - option = @string.options.find do |name| - item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/ - end - if option then - option = @string.get_option(option) - # If we have an inline argument, just carry on. We don't need to - # care about optional vs mandatory in that case because we do a real - # parse later, and that will totally take care of raising the error - # when we get there. --daniel 2011-04-04 - if option.takes_argument? and !item.index('=') then - index += 1 unless - (option.optional_argument? and command_line.args[index + 1] =~ /^-/) - end - elsif option = find_global_settings_argument(item) then - unless Puppet.settings.boolean? option.name then - # As far as I can tell, we treat non-bool options as always having - # a mandatory argument. --daniel 2011-04-05 - index += 1 # ...so skip the argument. - end - else - raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" - end - else - action = @string.get_action(item.to_sym) - if action.nil? then - raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" - end - @action = action - end - end - - @action or raise ArgumentError, "No action given on the command line!" - - # Finally, we can interact with the default option code to build behaviour - # around the full set of options we now know we support. - @action.options.each do |option| - option = @action.get_option(option) # make it the object. - self.class.option(*option.optparse) # ...and make the CLI parse it. - end - end - - def find_global_settings_argument(item) - Puppet.settings.each do |name, object| - object.optparse_args.each do |arg| - next unless arg =~ /^-/ - # sadly, we have to emulate some of optparse here... - pattern = /^#{arg.sub('[no-]', '').sub(/[ =].*$/, '')}(?:[ =].*)?$/ - pattern.match item and return object - end - end - return nil # nothing found. - end - - def setup - Puppet::Util::Log.newdestination :console - - @arguments = command_line.args - - # Note: because of our definition of where the action is set, we end up - # with it *always* being the first word of the remaining set of command - # line arguments. So, strip that off when we construct the arguments to - # pass down to the string action. --daniel 2011-04-04 - @arguments.delete_at(0) - - # We copy all of the app options to the end of the call; This allows each - # action to read in the options. This replaces the older model where we - # would invoke the action with options set as global state in the - # interface object. --daniel 2011-03-28 - @arguments << options - end - - - def main - # Call the method associated with the provided action (e.g., 'find'). - if result = @string.send(@action.name, *arguments) - puts render(result) - end - exit(exit_code) - end -end -- cgit From 8d144d0bf5116c5f04522f2b4cd75699f6480f8e Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 7 Apr 2011 14:20:35 -0700 Subject: (#7012) Update references in code to use face(s) The codebase is now using the new name, faces, uniformly to reference the objects contained. All tests pass. --- lib/puppet/application/config.rb | 4 ++-- lib/puppet/application/configurer.rb | 6 +++--- lib/puppet/application/faces.rb | 18 +++++++++--------- lib/puppet/application/faces_base.rb | 24 ++++++++++++------------ lib/puppet/application/indirection_base.rb | 4 ++-- 5 files changed, 28 insertions(+), 28 deletions(-) (limited to 'lib/puppet/application') diff --git a/lib/puppet/application/config.rb b/lib/puppet/application/config.rb index f6559277b..41a46c339 100644 --- a/lib/puppet/application/config.rb +++ b/lib/puppet/application/config.rb @@ -1,4 +1,4 @@ -require 'puppet/application/string_base' +require 'puppet/application/faces_base' -class Puppet::Application::Config < Puppet::Application::StringBase +class Puppet::Application::Config < Puppet::Application::FacesBase end diff --git a/lib/puppet/application/configurer.rb b/lib/puppet/application/configurer.rb index be018338f..751e6b4d7 100644 --- a/lib/puppet/application/configurer.rb +++ b/lib/puppet/application/configurer.rb @@ -1,5 +1,5 @@ require 'puppet/application' -require 'puppet/string' +require 'puppet/faces' class Puppet::Application::Configurer < Puppet::Application should_parse_config @@ -17,7 +17,7 @@ class Puppet::Application::Configurer < Puppet::Application end def run_command - report = Puppet::String[:configurer, '0.0.1'].synchronize(Puppet[:certname]) - Puppet::String[:report, '0.0.1'].submit(report) + report = Puppet::Faces[:configurer, '0.0.1'].synchronize(Puppet[:certname]) + Puppet::Faces[:report, '0.0.1'].submit(report) end end diff --git a/lib/puppet/application/faces.rb b/lib/puppet/application/faces.rb index 0a6a798ce..904a0cccc 100644 --- a/lib/puppet/application/faces.rb +++ b/lib/puppet/application/faces.rb @@ -1,7 +1,7 @@ require 'puppet/application' -require 'puppet/string' +require 'puppet/faces' -class Puppet::Application::String < Puppet::Application +class Puppet::Application::Faces < Puppet::Application should_parse_config run_mode :agent @@ -18,7 +18,7 @@ class Puppet::Application::String < Puppet::Application if arguments.empty? arguments = %w{terminuses actions} end - strings.each do |name| + faces.each do |name| str = "#{name}:\n" if arguments.include?("terminuses") begin @@ -68,12 +68,12 @@ class Puppet::Application::String < Puppet::Application end unless respond_to?(verb) - raise "Command '#{verb}' not found for 'string'" + raise "Command '#{verb}' not found for 'faces'" end end - def strings - Puppet::String.strings + def faces + Puppet::Faces.faces end def terminus_classes(indirection) @@ -81,9 +81,9 @@ class Puppet::Application::String < Puppet::Application end 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 [] unless faces = Puppet::Faces[indirection, '0.0.1'] + faces.load_actions + return faces.actions.sort { |a, b| a.to_s <=> b.to_s } end def load_applications diff --git a/lib/puppet/application/faces_base.rb b/lib/puppet/application/faces_base.rb index 09d02c079..6d66ee8a1 100644 --- a/lib/puppet/application/faces_base.rb +++ b/lib/puppet/application/faces_base.rb @@ -1,7 +1,7 @@ require 'puppet/application' -require 'puppet/string' +require 'puppet/faces' -class Puppet::Application::StringBase < Puppet::Application +class Puppet::Application::FacesBase < Puppet::Application should_parse_config run_mode :agent @@ -24,7 +24,7 @@ class Puppet::Application::StringBase < Puppet::Application end - attr_accessor :string, :action, :type, :arguments, :format + attr_accessor :face, :action, :type, :arguments, :format attr_writer :exit_code # This allows you to set the exit code if you don't want to just exit @@ -47,7 +47,7 @@ class Puppet::Application::StringBase < Puppet::Application def preinit super trap(:INT) do - $stderr.puts "Cancelling String" + $stderr.puts "Cancelling Face" exit(0) end @@ -57,8 +57,8 @@ class Puppet::Application::StringBase < Puppet::Application # TODO: These should be configurable versions, through a global # '--version' option, but we don't implement that yet... --daniel 2011-03-29 @type = self.class.name.to_s.sub(/.+:/, '').downcase.to_sym - @string = Puppet::String[@type, :current] - @format = @string.default_format + @face = Puppet::Faces[@type, :current] + @format = @face.default_format # Now, walk the command line and identify the action. We skip over # arguments based on introspecting the action and all, and find the first @@ -68,11 +68,11 @@ class Puppet::Application::StringBase < Puppet::Application until @action or (index += 1) >= command_line.args.length do item = command_line.args[index] if item =~ /^-/ then - option = @string.options.find do |name| + option = @face.options.find do |name| item =~ /^-+#{name.to_s.gsub(/[-_]/, '[-_]')}(?:[ =].*)?$/ end if option then - option = @string.get_option(option) + option = @face.get_option(option) # If we have an inline argument, just carry on. We don't need to # care about optional vs mandatory in that case because we do a real # parse later, and that will totally take care of raising the error @@ -91,9 +91,9 @@ class Puppet::Application::StringBase < Puppet::Application raise ArgumentError, "Unknown option #{item.sub(/=.*$/, '').inspect}" end else - action = @string.get_action(item.to_sym) + action = @face.get_action(item.to_sym) if action.nil? then - raise ArgumentError, "#{@string} does not have an #{item.inspect} action!" + raise ArgumentError, "#{@face} does not have an #{item.inspect} action!" end @action = action end @@ -129,7 +129,7 @@ class Puppet::Application::StringBase < Puppet::Application # Note: because of our definition of where the action is set, we end up # with it *always* being the first word of the remaining set of command # line arguments. So, strip that off when we construct the arguments to - # pass down to the string action. --daniel 2011-04-04 + # pass down to the face action. --daniel 2011-04-04 @arguments.delete_at(0) # We copy all of the app options to the end of the call; This allows each @@ -142,7 +142,7 @@ class Puppet::Application::StringBase < Puppet::Application def main # Call the method associated with the provided action (e.g., 'find'). - if result = @string.send(@action.name, *arguments) + if result = @face.send(@action.name, *arguments) puts render(result) end exit(exit_code) diff --git a/lib/puppet/application/indirection_base.rb b/lib/puppet/application/indirection_base.rb index cfa1ea529..7455ebedf 100644 --- a/lib/puppet/application/indirection_base.rb +++ b/lib/puppet/application/indirection_base.rb @@ -1,4 +1,4 @@ -require 'puppet/application/string_base' +require 'puppet/application/faces_base' -class Puppet::Application::IndirectionBase < Puppet::Application::StringBase +class Puppet::Application::IndirectionBase < Puppet::Application::FacesBase end -- cgit