summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util
diff options
context:
space:
mode:
authorMax Martin <max@puppetlabs.com>2011-06-02 15:56:22 -0700
committerMax Martin <max@puppetlabs.com>2011-06-02 15:56:22 -0700
commit4801e10c81264b20c2d35b0d44c10cfb0668d1b9 (patch)
tree3e3024bbd4a46a3ab2af5bf29ec2f3b30db270d7 /lib/puppet/util
parent520cbc0292ec0cf75b6871bb0a4bc12bce506bb0 (diff)
parent4ad88017d3b8b8000325f5165520a6c21b48c469 (diff)
downloadpuppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.tar.gz
puppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.tar.xz
puppet-4801e10c81264b20c2d35b0d44c10cfb0668d1b9.zip
Merge branch '2.7.x'
* 2.7.x: (40 commits) (#7746) Fix bootstrap issues from #7717 fix. (#7683) Use ronn, when available, to render the output. (#7683) Add a 'man' face and subcommand to Puppet. maint: remove obsolete work-around code from help face. (#7699) Don't duplicate inherited action names on faces. (#7177) Deprecate implicit 'puppet apply' for 2.7.0 (#7717) Layout cleanup for subcommand extraction. #7211: Test unknown options don't shadow unknown actions. #7211: nasty logic error with global Face options taking arguments. #7211: more helpful error messages in various cases. maint: Fix order dependent test failure (#5966) Add support for hostname regular expressions in auth.conf (#7708) Delete extended documentation from configuration reference (#7707) Document signals in puppet agent and puppet master help add puppet master polling step for ticket 7117 (#5318) Always notice changes to manifests when compiling. (#5318) Always notice changes to manifests when compiling. (#7557) Remove Faces Application maint: Fix order dependent spec failure for face indirection (#7690) Don't blow up when listing terminuses available for faces ... Conflicts (resolved manually): acceptance/tests/ticket_7117_broke_env_criteria_authconf.rb
Diffstat (limited to 'lib/puppet/util')
-rw-r--r--lib/puppet/util/autoload.rb30
-rw-r--r--lib/puppet/util/command_line.rb91
2 files changed, 102 insertions, 19 deletions
diff --git a/lib/puppet/util/autoload.rb b/lib/puppet/util/autoload.rb
index f0dd0a5c5..6537a4a4e 100644
--- a/lib/puppet/util/autoload.rb
+++ b/lib/puppet/util/autoload.rb
@@ -105,26 +105,28 @@ class Puppet::Util::Autoload
# so that already-loaded files don't get reloaded unnecessarily.
def loadall
# Load every instance of everything we can find.
- searchpath.each do |dir|
- Dir.glob("#{dir}/*.rb").each do |file|
- name = File.basename(file).sub(".rb", '').intern
- next if loaded?(name)
- begin
- Kernel.require file
- loaded(name, file)
- rescue SystemExit,NoMemoryError
- raise
- rescue Exception => detail
- puts detail.backtrace if Puppet[:trace]
- raise Puppet::Error, "Could not autoload #{file}: #{detail}"
- end
+ files_to_load.each do |file|
+ name = File.basename(file).chomp(".rb").intern
+ next if loaded?(name)
+ begin
+ Kernel.require file
+ loaded(name, file)
+ rescue SystemExit,NoMemoryError
+ raise
+ rescue Exception => detail
+ puts detail.backtrace if Puppet[:trace]
+ raise Puppet::Error, "Could not autoload #{file}: #{detail}"
end
end
end
+ def files_to_load
+ searchpath.map { |dir| Dir.glob("#{dir}/*.rb") }.flatten
+ end
+
# The list of directories to search through for loadable plugins.
def searchpath(env=nil)
- search_directories(env).collect { |d| File.join(d, @path) }.find_all { |d| FileTest.directory?(d) }
+ search_directories(env).uniq.collect { |d| File.join(d, @path) }.find_all { |d| FileTest.directory?(d) }
end
def module_directories(env=nil)
diff --git a/lib/puppet/util/command_line.rb b/lib/puppet/util/command_line.rb
index 8190f8ac1..244e2c2c9 100644
--- a/lib/puppet/util/command_line.rb
+++ b/lib/puppet/util/command_line.rb
@@ -59,6 +59,13 @@ module Puppet
require_application subcommand_name
app = Puppet::Application.find(subcommand_name).new(self)
Puppet::Plugins.on_application_initialization(:appliation_object => self)
+
+ # See the note in 'warn_later' down below. --daniel 2011-06-01
+ if $delayed_deprecation_warning_for_p_u_cl.is_a? String then
+ Puppet.deprecation_warning($delayed_deprecation_warning_for_p_u_cl)
+ $delayed_deprecation_warning_for_p_u_cl = true
+ end
+
app.run
elsif execute_external_subcommand then
# Logically, we shouldn't get here, but we do, so whatever. We just
@@ -93,16 +100,90 @@ module Puppet
if zero == 'puppet'
case argv.first
- when nil; [ stdin.tty? ? nil : "apply", argv] # ttys get usage info
- when "--help", "-h"; [nil, argv] # help should give you usage, not the help for `puppet apply`
- when /^-|\.pp$|\.rb$/; ["apply", argv]
- else [ argv.first, argv[1..-1] ]
+ when nil then
+ if stdin.tty? then
+ [nil, argv] # ttys get usage info
+ else
+ # Killed for 2.7.0 --daniel 2011-06-01
+ warn_later <<EOM
+Implicit invocation of 'puppet apply' by redirection into 'puppet' is deprecated,
+and will be removed in the 2.8 series. Please invoke 'puppet apply' directly
+in the future.
+EOM
+ ["apply", argv]
+ end
+ when "--help", "-h" then
+ # help should give you usage, not the help for `puppet apply`
+ [nil, argv]
+ when /^-|\.pp$|\.rb$/ then
+ # Killed for 2.7.0 --daniel 2011-06-01
+ warn_later <<EOM
+Implicit invocation of 'puppet apply' by passing files (or flags) directly
+to 'puppet' is deprecated, and will be removed in the 2.8 series. Please
+invoke 'puppet apply' directly in the future.
+EOM
+ ["apply", argv]
+ else
+ [argv.first, argv[1..-1]]
end
else
- [ zero, argv ]
+ [zero, argv]
end
end
+ # So, this is more than a little bit of a horror. You see, the process
+ # of bootstrapping Puppet is ... complex. This file, like many of our
+ # early initialization files, has an incestuous relationship between the
+ # order of files loaded, code executed at load time, and code executed
+ # in other files at runtime.
+ #
+ # When we construct this object we have not yet actually loaded the
+ # global puppet object, so we can't use any methods in it. That
+ # includes all the logging stuff, which is used by the deprecation
+ # warning subsystem.
+ #
+ # On the other hand, we can't just load the logging system, because that
+ # depends on the top level Puppet module being bootstrapped. It doesn't
+ # actually load the stuff it uses, though, for hysterical raisins.
+ #
+ # Finally, we can't actually just load the top level Puppet module.
+ # This one is precious: it turns out that some of the code loaded in the
+ # top level Puppet module has a dependency on the run mode values.
+ #
+ # Run mode is set correctly *only* when the application is loaded, and
+ # if it is wrong when the top level code is brought in we end up with
+ # the wrong settings scattered through some of the defaults.
+ #
+ # Which means that we have a dependency cycle that runs:
+ # 1. The binary creates an instance of P::U::CL.
+ # 2. That identifies the application to load.
+ # 3. It does, then instantiates the application.
+ # 4. That sets the run-mode.
+ # 5. That then loads the top level Puppet module.
+ # 6. Finally, we get to where we can use the top level stuff
+ #
+ # So, essentially, we see a dependency between runtime code in this
+ # file, run-time code in the application, and load-time code in the top
+ # level module.
+ #
+ # Which leads me to our current horrible hack: we stash away the message
+ # we wanted to log about deprecation, then send it to our logging system
+ # once we have done enough bootstrapping that it will, y'know, actually
+ # work.
+ #
+ # I would have liked to fix this, but that is going to be a whole pile
+ # of work digging through and decrufting all the global state from the
+ # local state, and working out what depends on what else in the product.
+ #
+ # Oh, and we use a global because we have *two* instances of a P::U::CL
+ # object during the startup sequence. I don't know why.
+ #
+ # Maybe, one day, when I am not behind a deadline to ship code.
+ # --daniel 2011-06-01
+ def warn_later(text)
+ return if $delayed_deprecation_warning_for_p_u_cl
+ $delayed_deprecation_warning_for_p_u_cl = text
+ end
end
end
end