Class: Chef::Knife::UserKeyDelete

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

Overview

Implements knife user key delete using Chef::Knife::KeyDelete as a service class.

Author:

  • Tyler Cloke

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ UserKeyDelete

Returns a new instance of UserKeyDelete.



38
39
40
41
# File 'lib/chef/knife/user_key_delete.rb', line 38

def initialize(argv = [])
  super(argv)
  @service_object = nil
end

Instance Attribute Details

#actorString (readonly)

the name of the client that this key is for

Returns:

  • (String)

    the current value of actor



29
30
31
# File 'lib/chef/knife/user_key_delete.rb', line 29

def actor
  @actor
end

Instance Method Details

#actor_field_nameObject



48
49
50
# File 'lib/chef/knife/user_key_delete.rb', line 48

def actor_field_name
  "user"
end

#actor_missing_errorObject



52
53
54
# File 'lib/chef/knife/user_key_delete.rb', line 52

def actor_missing_error
  "You must specify a user name"
end

#apply_params!(params) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/chef/knife/user_key_delete.rb', line 64

def apply_params!(params)
  @actor = params[0]
  if @actor.nil?
    show_usage
    ui.fatal(actor_missing_error)
    exit 1
  end
  @name = params[1]
  if @name.nil?
    show_usage
    ui.fatal(keyname_missing_error)
    exit 1
  end
end

#keyname_missing_errorObject



56
57
58
# File 'lib/chef/knife/user_key_delete.rb', line 56

def keyname_missing_error
  "You must specify a key name"
end

#runObject



43
44
45
46
# File 'lib/chef/knife/user_key_delete.rb', line 43

def run
  apply_params!(@name_args)
  service_object.run
end

#service_objectObject



60
61
62
# File 'lib/chef/knife/user_key_delete.rb', line 60

def service_object
  @service_object ||= Chef::Knife::KeyDelete.new(@name, @actor, actor_field_name, ui)
end