Class: Chef::Knife::EncryptedAttributeEdit

Inherits:
Core::EncryptedAttributeBase show all
Includes:
Core::EncryptedAttributeDepends, Core::EncryptedAttributeEditorOptions
Defined in:
lib/chef/knife/encrypted_attribute_edit.rb

Overview

knife encrypted attribute edit command.

$ knife encrypted attribute edit NODE ATTRIBUTE (options)

Instance Method Summary collapse

Methods included from Core::EncryptedAttributeEditorOptions

#edit_data, #edit_data_obj_to_string, #edit_data_run_editor, #edit_data_run_editor_command, #edit_data_string_to_obj, included

Methods included from Core::EncryptedAttributeDepends

included

Methods inherited from Core::EncryptedAttributeBase

#assert_attribute_does_not_exist, #assert_attribute_exists, #assert_attribute_readable, #attribute_path_to_ary, #attribute_path_to_ary_read_escape, #die, #option_assert, #parse_args

Instance Method Details

#assert_valid_argsObject

Raises:

  • (ArgumentError)

    if the attribute path format is wrong.


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

def assert_valid_args
  assert_attribute_exists(@node_name, @attr_ary)
end

#runObject

Runs knife command.

Returns:

  • void

Raises:

  • (RuntimeError)

    if the editing command fails.

  • (ArgumentError)

    if the attribute path format or the user list is wrong.

  • (UnacceptableEncryptedAttributeFormat)

    if encrypted attribute format is wrong or does not exist.

  • (UnsupportedEncryptedAttributeFormat)

    if encrypted attribute format is not supported or unknown.

  • (EncryptionFailure)

    if there are encryption errors.

  • (MessageAuthenticationFailure)

    if HMAC calculation error.

  • (InvalidPublicKey)

    if it is not a valid RSA public key.

  • (InvalidKey)

    if the RSA key format is wrong.

  • (InsufficientPrivileges)

    if you lack enough privileges to read the keys from the Chef Server.

  • (ClientNotFound)

    if client does not exist.

  • (Net::HTTPServerException)

    for Chef Server HTTP errors.

  • (RequirementsFailure)

    if the specified encrypted attribute version cannot be used.

  • (SearchFailure)

    if there is a Chef search error.

  • (SearchFatalError)

    if the Chef search response is wrong.

  • (InvalidSearchKeys)

    if search keys structure is wrong.


73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/chef/knife/encrypted_attribute_edit.rb', line 73

def run
  parse_args

  # edit encrypted attribute
  enc_attr =
    Chef::EncryptedAttribute.new(
      Chef::Config[:knife][:encrypted_attributes]
    )
  input = enc_attr.load_from_node(@node_name, @attr_ary)
  output = edit_data(input, config[:input_format])
  enc_attr.create_on_node(@node_name, @attr_ary, output)
end