Class: KnifeTopo::TopoCookbookCreate

Inherits:
Chef::Knife
  • Object
show all
Includes:
Loader
Defined in:
lib/chef/knife/topo_cookbook_create.rb

Overview

knife topo cookbook create

Instance Attribute Summary

Attributes included from Loader

#loader, #ui

Instance Method Summary collapse

Methods included from Loader

#auto_detect_format, #check_file, #create_topo_bag, #get_local_topo_path, #list_topo_bag, #load_local_topo_or_exit, #load_node_data, #load_topo_from_file_or_exit, #load_topo_from_server, #load_topo_from_server_or_exit, #priority_attrs, #topo_bag_name, #topologies_path

Constructor Details

#initialize(args) ⇒ TopoCookbookCreate

Returns a new instance of TopoCookbookCreate.



44
45
46
47
# File 'lib/chef/knife/topo_cookbook_create.rb', line 44

def initialize(args)
  super
  @args = args
end

Instance Method Details

#do_create_artifactsObject



66
67
68
69
70
71
# File 'lib/chef/knife/topo_cookbook_create.rb', line 66

def do_create_artifacts
  @processor.generate_artifacts(
    'cmd_args' => @args,
    'cmd' => self
  )
end

#runObject



49
50
51
52
53
54
55
# File 'lib/chef/knife/topo_cookbook_create.rb', line 49

def run
  validate_args

  @topo = load_topo_from_file_or_exit(@topo_file)
  @processor = KnifeTopo::Processor.for_topo(@topo)
  do_create_artifacts
end

#validate_argsObject



57
58
59
60
61
62
63
64
# File 'lib/chef/knife/topo_cookbook_create.rb', line 57

def validate_args
  unless @name_args[0]
    show_usage
    ui.fatal('You must specify a topology JSON file')
    exit 1
  end
  @topo_file = @name_args[0]
end