Class: Chef::Knife::KeyDelete

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/knife/key_delete.rb

Overview

Service class for UserKeyDelete and ClientKeyDelete, used to delete keys. Implements common functionality of knife [user | org client] key delete.

Author:

  • Tyler Cloke

Instance Method Summary collapse

Constructor Details

#initialize(name, actor, actor_field_name, ui) ⇒ KeyDelete

Returns a new instance of KeyDelete.



30
31
32
33
34
35
# File 'lib/chef/knife/key_delete.rb', line 30

def initialize(name, actor, actor_field_name, ui)
  @name = name
  @actor = actor
  @actor_field_name = actor_field_name
  @ui = ui
end

Instance Method Details

#confirm!Object



37
38
39
# File 'lib/chef/knife/key_delete.rb', line 37

def confirm!
  @ui.confirm("Do you really want to delete the key named #{@name} for the #{@actor_field_name} named #{@actor}")
end


41
42
43
# File 'lib/chef/knife/key_delete.rb', line 41

def print_destroyed
  @ui.info("Deleted key named #{@name} for the #{@actor_field_name} named #{@actor}")
end

#runObject



45
46
47
48
49
50
51
# File 'lib/chef/knife/key_delete.rb', line 45

def run
  key = Chef::Key.new(@actor, @actor_field_name)
  key.name(@name)
  confirm!
  key.destroy
  print_destroyed
end