Class: Puppet::Util::CommandLine::ApplicationSubcommand Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/command_line.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Method Summary collapse

Constructor Details

#initialize(subcommand_name, command_line) ⇒ ApplicationSubcommand

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of ApplicationSubcommand.



116
117
118
119
# File 'lib/puppet/util/command_line.rb', line 116

def initialize(subcommand_name, command_line)
  @subcommand_name = subcommand_name
  @command_line = command_line
end

Instance Method Details

#runObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/puppet/util/command_line.rb', line 121

def run
  # For most applications, we want to be able to load code from the modulepath,
  # such as apply, describe, resource, and faces.
  # For agent, we only want to load pluginsync'ed code from libdir.
  # For master, we shouldn't ever be loading per-enviroment code into the master's
  # ruby process, but that requires fixing (#17210, #12173, #8750). So for now
  # we try to restrict to only code that can be autoloaded from the node's
  # environment.

  # PUP-2114 - at this point in the bootstrapping process we do not
  # have an appropriate application-wide current_environment set.
  # If we cannot find the configured environment, which may not exist,
  # we do not attempt to add plugin directories to the load path.
  #
  if @subcommand_name != 'master' and @subcommand_name != 'agent'
    if configured_environment = Puppet.lookup(:environments).get(Puppet[:environment])
      configured_environment.each_plugin_directory do |dir|
        $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
      end
    end
  end

  app = Puppet::Application.find(@subcommand_name).new(@command_line)
  Puppet::Plugins.on_application_initialization(:application_object => @command_line)

  app.run
end