class Chef::Provisioning::ManagedEntryStore
Public Class Methods
# File lib/chef/provisioning/managed_entry_store.rb, line 9 def initialize(chef_run_data) @chef_run_data = chef_run_data end
Public Instance Methods
Delete the given spec.
@param resource_type [Symbol] The type of spec to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the spec to delete
@return [Boolean] Whether anything was deleted or not.
# File lib/chef/provisioning/managed_entry_store.rb, line 115 def delete(resource_type, name, action_handler) delete_data(resource_type, name, action_handler) end
Delete the given data
@param resource_type [Symbol] The type of thing to delete (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the thing to delete
@return [Boolean] Whether anything was deleted or not.
# File lib/chef/provisioning/managed_entry_store.rb, line 44 def delete_data(resource_type, name, action_handler) raise NotImplementedError, :delete_data end
Get a spec.
@param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the spec to retrieve
@return [ManagedEntry] The entry, or `nil` if the data does not exist.
# File lib/chef/provisioning/managed_entry_store.rb, line 71 def get(resource_type, name) data = get_data(resource_type, name) if data new_entry(resource_type, name, data) end end
Get a spec, erroring out if the data does not exist.
@param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the spec to retrieve
@return [ManagedEntry] The entry.
# File lib/chef/provisioning/managed_entry_store.rb, line 99 def get!(resource_type, name) result = get(resource_type, name) if !result raise "#{identifier(resource_type, name)} not found!" end result end
Get the given data
@param resource_type [Symbol] The type of thing to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the thing to retrieve
@return [Hash,Array] The data. Will be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
# File lib/chef/provisioning/managed_entry_store.rb, line 21 def get_data(resource_type, name) raise NotImplementedError, :get_data end
Get a spec, or create a new one, depending on whether an entry exists.
@param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the spec to retrieve
@return [ManagedEntry] The entry.
# File lib/chef/provisioning/managed_entry_store.rb, line 86 def get_or_new(resource_type, name) data = get_data(resource_type, name) new_entry(resource_type, name, data) end
Get a globally unique identifier for this resource.
@param resource_type [Symbol] The type of spec to retrieve (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet, …) @param name [String] The unique identifier of the spec to retrieve
@return [String] The identifier.
@example ChefManagedEntry does this:
chef_managed_entry_store.identifier(:machine, 'mario') # => https://my.chef.server/organizations/org/nodes/mario
# File lib/chef/provisioning/managed_entry_store.rb, line 59 def identifier(resource_type, name) raise NotImplementedError, :identifier end
Create a new managed entry of the given type.
# File lib/chef/provisioning/managed_entry_store.rb, line 122 def new_entry(resource_type, name, data=nil) case resource_type when :machine MachineSpec.new(self, resource_type, name, data) when :machine_image MachineImageSpec.new(self, resource_type, name, data) when :load_balancer LoadBalancerSpec.new(self, resource_type, name, data) else ManagedEntry.new(self, resource_type, name, data) end end
Save the given data
@param resource_type [Symbol] The type of thing to save (:machine, :machine_image, :load_balancer, :aws_vpc, :aws_subnet …) @param name [String] The unique identifier of the thing to save @param data [Hash,Array] The data to save. Must be JSON- and YAML-compatible (Hash, Array, String, Integer, Boolean, Nil)
# File lib/chef/provisioning/managed_entry_store.rb, line 32 def save_data(resource_type, name, data, action_handler) raise NotImplementedError, :save_data end