Class: KnifeWip::NodeUnwip

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



143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/chef/knife/knife-wip.rb', line 143

def run
  name = @name_args[0]
  description = @name_args[1..-1].join(" ")

  if name.nil? || description.nil? || description.empty?
    show_usage
    ui.fatal("You must specify a node name and a WIP description.")
    exit 1
  end

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

  load_plugins

  node = Chef::Node.load name
  tag = "wip:#{ENV["USER"]}:#{description}"
  success = node.tags.delete(tag).nil? ? false : true

  node.save
  if success == false
    message = "Nothing has changed. The WIP description requested to be deleted does not exist."
  else
    message = "Deleted WIP description \"#{tag}\" for node #{name}."
    @plugins.each do |plugin|
      plugin.wip_stop(ENV["USER"], description, name)
    end
  end
  ui.info(message)
end