Please review pull request #231: Ticket/2.7.x/10940 deprecate apply for catalog opened by (kelseyhightower)

Description:

Without this patch, the puppet apply command uses the --apply option
to reference a Puppet catalog. This can cause a bit of confusion as both
the subcommand and option have the same name.

This patch improves the usability of the puppet apply command by
adding a new --catalog option. This patch also adds a deprecation
warning whenever the --apply option is used, which advises end-users
to use the --catalog option instead.

This patch updates the in-line help documentation by adding help output
for the new --catalog option, and adding a deprecation warning for the
--apply option.

The plan is to deprecate the --apply option in the next 2.7.x release,
and removal in the future. External documentation should be updated to
reflect the new preference towards using the --catalog option in-place
of --apply.

Preferred method of applying a Puppet catalog using puppet apply:

$ puppet apply --catalog <catalog>

This patch also includes the spec tests covering the changes in
behavior.


    
  • Opened: Tue Nov 22 22:34:23 UTC 2011
  • Based on: puppetlabs:2.7.x (440ffac9a905672766c46c48c29704b8f85bfdd1)
  • Requested merge: kelseyhightower:ticket/2.7.x/10940_deprecate_apply_for_catalog (05b3cacd2ebc8f7c19a86d543262a5bee3fb0604)

Diff follows:

diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb
index 200309b..a5ad718 100644
--- a/lib/puppet/application/apply.rb
+++ b/lib/puppet/application/apply.rb
@@ -14,6 +14,14 @@ class Puppet::Application::Apply < Puppet::Application
   option("--detailed-exitcodes")
 
   option("--apply catalog",  "-a catalog") do |arg|
+    Puppet.warning <<EOM
+--apply is deprecated and will be removed in the future. Please
+use 'puppet apply --catalog <catalog>'.
+EOM
+    options[:catalog] = arg
+  end
+
+  option("--catalog catalog",  "-c catalog") do |arg|
     options[:catalog] = arg
   end
 
@@ -46,7 +54,7 @@ USAGE
 -----
 puppet apply [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
   [-e|--execute] [--detailed-exitcodes] [-l|--logdest <file>]
-  [--apply <catalog>] <file>
+  [--apply <catalog>] [--catalog <catalog>] <file>
 
 
 DESCRIPTION
@@ -107,6 +115,11 @@ configuration options can also be generated by running puppet with
 
 * --apply:
   Apply a JSON catalog (such as one generated with 'puppet master --compile'). You can
+  either specify a JSON file or pipe in JSON from standard input. Deprecated, please
+  use --catalog instead.
+
+* --catalog:
+  Apply a JSON catalog (such as one generated with 'puppet master --compile'). You can
   either specify a JSON file or pipe in JSON from standard input.
 
 
@@ -114,6 +127,7 @@ EXAMPLE
 -------
     $ puppet apply -l /tmp/manifest.log manifest.pp
     $ puppet apply --modulepath=/root/dev/modules -e "include ntpd::server"
+    $ puppet apply --catalog catalog.json
 
 
 AUTHOR
diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb
index c1f85d5..4c0498c 100755
--- a/spec/unit/application/apply_spec.rb
+++ b/spec/unit/application/apply_spec.rb
@@ -20,7 +20,7 @@ describe Puppet::Application::Apply do
     Puppet::Node.indirection.cache_class = nil
   end
 
-  [:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes].each do |option|
+  [:debug,:loadclasses,:verbose,:use_nodes,:detailed_exitcodes,:catalog].each do |option|
     it "should declare handle_#{option} method" do
       @apply.should respond_to("handle_#{option}".to_sym)
     end
@@ -53,6 +53,17 @@ describe Puppet::Application::Apply do
 
       @apply.handle_logdest("console")
     end
+
+    it "should deprecate --apply" do
+      Puppet.expects(:warning).with do |arg|
+        arg.match(/--apply is deprecated/)
+      end
+
+      command_line = Puppet::Util::CommandLine.new('puppet', ['apply', '--apply', 'catalog.json'])
+      apply = Puppet::Application::Apply.new(command_line)
+      apply.stubs(:run_command)
+      apply.run
+    end
   end
 
   describe "during setup" do

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to