Class: Chef::Resource::ChefDataBagItem
- Inherits:
-
LWRPBase
- Object
- LWRPBase
- Chef::Resource::ChefDataBagItem
- Defined in:
- lib/chef/resource/chef_data_bag_item.rb
Constant Summary collapse
- NOT_PASSED =
‘NOT_PASSED` is defined in chef-12.5.0, this guard will ensure we don’t redefine it if it’s already there
Object.new
Instance Attribute Summary collapse
-
#raw_data_modifiers ⇒ Object
readonly
value ‘ip_address’, ‘127.0.0.1’ value [ ‘pushy’, ‘port’ ], ‘9000’ value ‘ip_addresses’ do |existing_value| (existing_value || []) + [ ‘127.0.0.1’ ] end value ‘ip_address’, :delete.
Instance Method Summary collapse
- #data_bag(value = NOT_PASSED) ⇒ Object
- #id(value = NOT_PASSED) ⇒ Object
-
#initialize(*args) ⇒ ChefDataBagItem
constructor
A new instance of ChefDataBagItem.
- #name(*args) ⇒ Object
-
#secret(new_secret = nil) ⇒ Object
attribute :secret, :kind_of => String.
-
#secret_path(new_secret_path = nil) ⇒ Object
attribute :secret_path, :kind_of => String.
- #value(raw_data_path, value = NOT_PASSED, &block) ⇒ Object
Constructor Details
#initialize(*args) ⇒ ChefDataBagItem
Returns a new instance of ChefDataBagItem.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 13 def initialize(*args) super name @name if !data_bag data_bag run_context.cheffish.current_data_bag end if run_context.cheffish.current_data_bag_item_encryption @encrypt = true if run_context.cheffish.current_data_bag_item_encryption[:encrypt_all] @secret = run_context.cheffish.current_data_bag_item_encryption[:secret] @secret_path = run_context.cheffish.current_data_bag_item_encryption[:secret_path] || run_context.config[:encrypted_data_bag_secret] @encryption_cipher = run_context.cheffish.current_data_bag_item_encryption[:encryption_cipher] @encryption_version = run_context.cheffish.current_data_bag_item_encryption[:encryption_version] || run_context.config[:data_bag_encrypt_version] @old_secret = run_context.cheffish.current_data_bag_item_encryption[:old_secret] @old_secret_path = run_context.cheffish.current_data_bag_item_encryption[:old_secret_path] end chef_server run_context.cheffish.current_chef_server end |
Instance Attribute Details
#raw_data_modifiers ⇒ Object (readonly)
value ‘ip_address’, ‘127.0.0.1’ value [ ‘pushy’, ‘port’ ], ‘9000’ value ‘ip_addresses’ do |existing_value|
(existing_value || []) + [ '127.0.0.1' ]
end value ‘ip_address’, :delete
108 109 110 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 108 def raw_data_modifiers @raw_data_modifiers end |
Instance Method Details
#data_bag(value = NOT_PASSED) ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 59 def data_bag(value = NOT_PASSED) if value == NOT_PASSED @data_bag else @data_bag = value name data_bag ? "#{data_bag}/#{id}" : id end end |
#id(value = NOT_PASSED) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 51 def id(value = NOT_PASSED) if value == NOT_PASSED @id else @id = value name data_bag ? "#{data_bag}/#{id}" : id end end |
#name(*args) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 31 def name(*args) result = super(*args) if args.size == 1 parts = name.split('/') if parts.size == 1 @id = parts[0] elsif parts.size == 2 @data_bag = parts[0] @id = parts[1] else raise "Name #{args[0].inspect} must be a string with 1 or 2 parts, either 'id' or 'data_bag/id" end end result end |
#secret(new_secret = nil) ⇒ Object
attribute :secret, :kind_of => String
72 73 74 75 76 77 78 79 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 72 def secret(new_secret = nil) if !new_secret @secret else @secret = new_secret @encrypt = true if @encrypt.nil? end end |
#secret_path(new_secret_path = nil) ⇒ Object
attribute :secret_path, :kind_of => String
81 82 83 84 85 86 87 88 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 81 def secret_path(new_secret_path = nil) if !new_secret_path @secret_path else @secret_path = new_secret_path @encrypt = true if @encrypt.nil? end end |
#value(raw_data_path, value = NOT_PASSED, &block) ⇒ Object
109 110 111 112 113 114 115 116 117 118 |
# File 'lib/chef/resource/chef_data_bag_item.rb', line 109 def value(raw_data_path, value=NOT_PASSED, &block) @raw_data_modifiers ||= [] if value != NOT_PASSED @raw_data_modifiers << [ raw_data_path, value ] elsif block @raw_data_modifiers << [ raw_data_path, block ] else raise "value requires either a value or a block" end end |