Class: Chef::Knife::ClientKeyShow

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

Overview

Implements knife client key show using Chef::Knife::KeyShow as a service class.

Author:

  • Tyler Cloke

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv = []) ⇒ ClientKeyShow

Returns a new instance of ClientKeyShow.



38
39
40
41
# File 'lib/chef/knife/client_key_show.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/client_key_show.rb', line 29

def actor
  @actor
end

Instance Method Details

#actor_missing_errorObject



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

def actor_missing_error
  "You must specify a client name"
end

#apply_params!(params) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/chef/knife/client_key_show.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/client_key_show.rb', line 56

def keyname_missing_error
  "You must specify a key name"
end

#load_methodObject



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

def load_method
  :load_by_client
end

#runObject



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

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

#service_objectObject



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

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