Class: Chef::Knife::ClientKeyCreate

Inherits:
Knife
  • Object
show all
Includes:
KeyCreateBase
Defined in:
lib/chef/knife/client_key_create.rb

Overview

Implements knife user key create using Chef::Knife::KeyCreate as a service class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from KeyCreateBase

included

Constructor Details

#initialize(argv = []) ⇒ ClientKeyCreate

Returns a new instance of ClientKeyCreate.



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

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

Instance Attribute Details

#actor ⇒ String (readonly)

the name of the client that this key is for

Returns:

  • (String) —

    the current value of actor



30
31
32
# File 'lib/chef/knife/client_key_create.rb', line 30

def actor
  @actor
end

Instance Method Details

#actor_field_name ⇒ Object



51
52
53
# File 'lib/chef/knife/client_key_create.rb', line 51

def actor_field_name
  "client"
end

#actor_missing_error ⇒ Object



59
60
61
# File 'lib/chef/knife/client_key_create.rb', line 59

def actor_missing_error
  "You must specify a client name"
end

#apply_params!(params) ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/chef/knife/client_key_create.rb', line 63

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

#run ⇒ Object



46
47
48
49
# File 'lib/chef/knife/client_key_create.rb', line 46

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

#service_object ⇒ Object



55
56
57
# File 'lib/chef/knife/client_key_create.rb', line 55

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