Class: Chef::Knife::ClientKeyDelete

Inherits:
Chef::Knife show all
Defined in:
lib/chef/knife/client_key_delete.rb

Overview

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

Author:

  • Tyler Cloke

Constant Summary

Constants inherited from Chef::Knife

CHEF_ORGANIZATION_MANAGEMENT, OFFICIAL_PLUGINS, OPSCODE_HOSTED_CHEF_ACCESS_CONTROL

Instance Attribute Summary collapse

Attributes inherited from Chef::Knife

#name_args, #ui

Instance Method Summary collapse

Methods inherited from Chef::Knife

#api_key, #apply_computed_config, category, chef_config_dir, #cli_keys, common_name, #config_file_settings, config_loader, #config_source, #configure_chef, #create_object, #delete_object, dependency_loaders, deps, #format_rest_error, guess_category, #humanize_exception, #humanize_http_exception, inherited, list_commands, load_commands, load_config, load_deps, #maybe_setup_fips, #merge_configs, msg, #noauth_rest, #parse_options, reset_config_loader!, reset_subcommands!, #rest, run, #run_with_pretty_exceptions, #server_url, #show_usage, snake_case_name, subcommand_category, subcommand_class_from, subcommand_files, subcommand_loader, subcommands, subcommands_by_category, #test_mandatory_field, ui, unnamed?, use_separate_defaults?, #username

Methods included from Mixin::ConvertToClassName

#constantize, #convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #normalize_snake_case_name, #snake_case_basename

Constructor Details

#initialize(argv = []) ⇒ ClientKeyDelete

Returns a new instance of ClientKeyDelete.



35
36
37
38
# File 'lib/chef/knife/client_key_delete.rb', line 35

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



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

def actor
  @actor
end

Instance Method Details

#actor_field_nameObject



45
46
47
# File 'lib/chef/knife/client_key_delete.rb', line 45

def actor_field_name
  "client"
end

#actor_missing_errorObject



49
50
51
# File 'lib/chef/knife/client_key_delete.rb', line 49

def actor_missing_error
  "You must specify a client name"
end

#apply_params!(params) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/chef/knife/client_key_delete.rb', line 61

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



53
54
55
# File 'lib/chef/knife/client_key_delete.rb', line 53

def keyname_missing_error
  "You must specify a key name"
end

#runObject



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

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

#service_objectObject



57
58
59
# File 'lib/chef/knife/client_key_delete.rb', line 57

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