Module: Chef::Knife::SecureDataBag::BaseMixin
- Defined in:
- lib/chef/knife/secure_data_bag/base_mixin.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Steps to execute when the mixin is include.
Instance Method Summary collapse
-
#config_metadata ⇒ Object
Metadata to use when interacting with SecureDataBag containing overrides specified on the command-line.
-
#create_item(data_bag, item_name, data = {}, metadata = {}) ⇒ SecureDataBag::Item
Create a new data_bag_item.
-
#load_item(data_bag, item_name, metadata = {}) ⇒ SecureDataBag::Item
Load a data_bag_item from Chef Server.
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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chef/knife/secure_data_bag/base_mixin.rb', line 11 def self.included(base) base.deps do require 'secure_data_bag' end base.option :encryption_format, description: 'The format with which to encrypt data. If unset, it will be autodetected.', long: '--enc-format [plain|encrypted|nested]' base.option :decryption_format, description: 'The format with which to decrypt data. If unset, it will be autodetected.', long: '--dec-format [plain|encrypted|nested]' base.option :encrypted_keys, description: 'Comma delimited list of keys which should be encrypted, in addition to what was previously there', long: '--enc-keys FIELD1,FIELD2,FIELD3', proc: proc { |s| s.split(',') } end |
Instance Method Details
#config_metadata ⇒ Object
Metadata to use when interacting with SecureDataBag containing overrides specified on the command-line.
33 34 35 36 37 38 39 40 41 |
# File 'lib/chef/knife/secure_data_bag/base_mixin.rb', line 33 def Mash.new( encryption_format: config[:encryption_format], decryption_format: config[:decryption_format], encrypted_keys: encrypted_keys, encrypt: true, secret: secret ) end |
#create_item(data_bag, item_name, data = {}, metadata = {}) ⇒ SecureDataBag::Item
Create a new data_bag_item
61 62 63 64 65 66 |
# File 'lib/chef/knife/secure_data_bag/base_mixin.rb', line 61 def create_item(data_bag, item_name, data = {}, = {}) item = ::SecureDataBag::Item.new() item.raw_data = { 'id' => item_name }.merge(data) item.data_bag data_bag item end |
#load_item(data_bag, item_name, metadata = {}) ⇒ SecureDataBag::Item
Load a data_bag_item from Chef Server
49 50 51 52 |
# File 'lib/chef/knife/secure_data_bag/base_mixin.rb', line 49 def load_item(data_bag, item_name, = {}) item = ::SecureDataBag::Item.load(data_bag, item_name, ) item end |