Sha256: e8ab3c79b0ffbd087ea8c031f68155bdc9db6527e69b31abb5bfb214ce614287

Contents?: true

Size: 817 Bytes

Versions: 4

Compression:

Stored size: 817 Bytes

Contents

require 'chef/knife'
require 'knife-spork/runner'

module KnifeSpork
  class SporkNodeDelete < Chef::Knife
    include KnifeSpork::Runner

    banner 'knife spork node delete NODE (options)'


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

      if @name_args.empty?
        show_usage
        ui.error("You must specify a node name")
        exit 1
      end

      @object_name = @name_args.first

      run_plugins(:before_nodedelete)
      pre_node = load_node(@object_name)
      node_delete
      post_node = {}
      @object_difference = json_diff(pre_node,post_node).to_s
      run_plugins(:after_nodedelete)
    end

    private
    def node_delete
      ne = Chef::Knife::NodeDelete.new
      ne.name_args = @name_args
      ne.config[:editor] = config[:editor]
      ne.run
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
knife-spork-berks-1.3.2 lib/chef/knife/spork-node-delete.rb
knife-spork-1.3.2 lib/chef/knife/spork-node-delete.rb
knife-spork-1.3.1 lib/chef/knife/spork-node-delete.rb
knife-spork-1.3.0 lib/chef/knife/spork-node-delete.rb