Class: Chef::Knife::KeyShow

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

Overview

Service class for UserKeyShow and ClientKeyShow, used to show keys. Implements common functionality of knife [user | org client] key show.

Author:

  • Tyler Cloke

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, actor, load_method, ui) ⇒ KeyShow

Returns a new instance of KeyShow.



35
36
37
38
39
40
# File 'lib/chef/knife/key_show.rb', line 35

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

Instance Attribute Details

#configObject

Returns the value of attribute config.



33
34
35
# File 'lib/chef/knife/key_show.rb', line 33

def config
  @config
end

Instance Method Details

#display_output(key) ⇒ Object



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

def display_output(key)
  @ui.output(@ui.format_for_display(key))
end

#runObject



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

def run
  key = Chef::Key.send(@load_method, @actor, @name)
  key.public_key(key.public_key.strip)
  display_output(key)
end