class Chef::Knife::ZeroApply

Public Class Methods

new(argv = []) click to toggle source
Calls superclass method
# File lib/chef/knife/zero_apply.rb, line 55
def initialize(argv = [])
  super
  self.configure_chef

  @name_args = [@name_args[0], start_chef_apply]
end

Public Instance Methods

start_chef_apply() click to toggle source
# File lib/chef/knife/zero_apply.rb, line 62
def start_chef_apply # rubocop:disable Metrics/PerceivedComplexity, Metrics/AbcSize, Metrics/CyclomaticComplexity
  log_level = if @config[:verbosity] && @config[:verbosity] >= 2
                'debug'
              else
                'info'
              end

  client_path = @config[:use_sudo] || Chef::Config[:knife][:use_sudo] ? 'sudo ' : ''
  client_path = @config[:chef_client_path] ? "#{client_path}#{@config[:chef_client_path]}" : "#{client_path}chef-apply"
  s = String.new("echo #{@config[:recipe]} | #{client_path}")
  s << " -l #{log_level}"
  s << ' -s'
  s << ' --minimal-ohai' if @config[:minimal_ohai]
  s << " -j #{@config[:json_attribs]}" if @config[:json_attribs]
  s << ' --no-color' unless @config[:color]
  s << ' -W' if @config[:why_run]
  Chef::Log.info 'Remote command: ' + s
  s
end