class Chef::Knife

noinspection RubyTooManyInstanceVariablesInspection noinspection RubyTooManyMethodsInspection

Attributes

ALLACTIONS[RW]
ALLPARTS[RW]
LOGLEVELS[RW]
location[R]
logger[RW]
prec_max[RW]
rsrctype[R]
verbosity[RW]

Public Class Methods

allactions() click to toggle source
# File lib/chef/knife/chop_base.rb, line 57
def self.allactions
  @ALLACTIONS
end
allactions=(acts) click to toggle source
# File lib/chef/knife/chop_base.rb, line 45
def self.allactions=(acts)
  @ALLACTIONS = acts || [:upload, :translate]
end
allparts() click to toggle source
# File lib/chef/knife/chop_base.rb, line 53
def self.allparts
  @ALLPARTS
end
allparts=(parts) click to toggle source
# File lib/chef/knife/chop_base.rb, line 41
def self.allparts=(parts)
  @ALLPARTS   = parts || [:environments, :roles, :databags, :cookbooks]
end
loglevels() click to toggle source
# File lib/chef/knife/chop_base.rb, line 49
def self.loglevels
  @LOGLEVELS
end
loglevels=(levels) click to toggle source
# File lib/chef/knife/chop_base.rb, line 37
def self.loglevels=(levels)
  @LOGLEVELS  = levels || [:trace, :debug, :step, :info, :warn, :error, :fatal, :todo]
end

Public Instance Methods

translate() click to toggle source

# File lib/chef/knife/chop/chef_knife.rb, line 42
def translate()
  if config[:all]
    translate_all()
  else
    if @name_args[0].nil?
      show_usage
      ui.fatal("You must specify a file to translate")
      exit 1
    end

    @name_args.each do |arg|
      translate_one(arg)
    end
  end
end

Private Instance Methods

translate_all() click to toggle source

# File lib/chef/knife/chop/chef_knife.rb, line 63
def translate_all()
  set = self.send("find_all_#{@location}")
  if set.empty?
    ui.fatal("Unable to find any #{@rsrctype} files in '#{subc.send("#{@rsrctype}_path")}'")
    exit(1)
  end
  set.each do |ent|
    translate_one(ent)
  end
end
translate_one(ent) click to toggle source

# File lib/chef/knife/chop/chef_knife.rb, line 75
def translate_one(ent)
  location = loader.find_file(@location, ent)
  resource = loader.load_from(@location, ent)
  part = ::Chef::Part.new(resource,location)
  part.translate(@config)
  resource = part.resource
  output(format_for_display(resource)) if config[:print_after]
  ui.info("Translated #{@rsrctype.capitalize} #{resource.name}")
end