Module: Chef::Knife::SecureDataBag::SecretsMixin

Defined in:
lib/chef/knife/secure_data_bag/secrets_mixin.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Steps to execute when the mixin is include. In this case specifically, add additional command line options related to exporting.

Since:

  • 3.0.0



9
10
11
12
13
14
15
16
17
18
# File 'lib/chef/knife/secure_data_bag/secrets_mixin.rb', line 9

def self.included(base)
  base.option :secret,
    description: 'The secret key used to (de)encrypt data bag item values',
    short: '-s SECRET',
    long: '--secret '

  base.option :secret_file,
    description: 'The secret key file used to (de)encrypt data bag item values',
    long: '--secret-file SECRET_FILE'
end

Instance Method Details

#secretString

The shared secret used to encrypt / decrypt data bag items

Returns:

  • (String)

    the shared secret

Since:

  • 3.0.0



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chef/knife/secure_data_bag/secrets_mixin.rb', line 23

def secret
  @secret ||= begin
    secret = load_secret
    unless secret
      ui.fatal('A secret or secret_file must be specified')
      show_usage
      exit 1
    end
    secret
  end
end