Class: KnifeWip::NodeWip

Inherits:
Chef::Knife
  • Object
show all
Includes:
Helpers
Defined in:
lib/chef/knife/knife-wip.rb

Instance Method Summary collapse

Methods included from Helpers

#app_config, #cookbook_path, #ensure_cookbook_path!, #load_plugins

Instance Method Details

#runObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/chef/knife/knife-wip.rb', line 107

def run
  name = @name_args[0]
  description = @name_args[1..-1]

  if name.nil? || description.nil? || description.empty?
    show_usage
    ui.fatal("You must specify a node name and a description of what you are working on.")
    exit 1
  end

  self.config = Chef::Config.merge!(config)

  load_plugins

  wip_tag = "wip:#{ENV["USER"]}:#{description.join(" ")}"

  node = Chef::Node.load name
    (node.tags << wip_tag).uniq!
  node.save
  ui.info("Created WIP \"#{wip_tag}\" for node #{name}.")
  @plugins.each do |plugin|
    plugin.wip_start(ENV["USER"], description.join(" "), name)
  end
end