Class: Puppet::Provider::BambooProvider
- Inherits:
-
Puppet::Provider
- Object
- Puppet::Provider
- Puppet::Provider::BambooProvider
- Defined in:
- lib/puppet/provider/bamboo_provider.rb
Direct Known Subclasses
Class Method Summary collapse
-
.bamboo_resource ⇒ Object
Bamboo REST resource, needs to be overwritten by child class.
- .content_type ⇒ Object
-
.instances ⇒ Object
Find resource information of this type via invoking bamboo REST api.
-
.map_config_to_resource_hash(bamboo_settings) ⇒ Object
map REST response to resource hash.
-
.prefetch(resources) ⇒ Object
Fetch information of the resource type, invoked during ‘puppet apply` and `puppet agent`.
Instance Method Summary collapse
-
#flush ⇒ Object
Instead of applying each attribute one by one, flush after all attributes have been updated.
-
#map_resource_hash_to_config ⇒ Object
map resource hash to format accepted by REST resource.
Class Method Details
.bamboo_resource ⇒ Object
Bamboo REST resource, needs to be overwritten by child class
7 8 9 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 7 def self.bamboo_resource '/rest/api/latest/info' end |
.content_type ⇒ Object
11 12 13 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 11 def self.content_type 'json' end |
.instances ⇒ Object
Find resource information of this type via invoking bamboo REST api. Map response from json fromat to resource properties Invoked during ‘puppet resource`
18 19 20 21 22 23 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 18 def self.instances bamboo_settings = Bamboo::Rest.get_bamboo_settings(self.bamboo_resource, self.content_type) hash = map_config_to_resource_hash(bamboo_settings) hash[:name] = 'current' [new(hash)] end |
.map_config_to_resource_hash(bamboo_settings) ⇒ Object
map REST response to resource hash
36 37 38 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 36 def self.map_config_to_resource_hash(bamboo_settings) notice('Need to be implemented') end |
.prefetch(resources) ⇒ Object
Fetch information of the resource type, invoked during ‘puppet apply` and `puppet agent`
26 27 28 29 30 31 32 33 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 26 def self.prefetch(resources) settings = instances resources.keys.each do |name| if provider = settings.find { |setting| setting.name == name } resources[name].provider = provider end end end |
Instance Method Details
#flush ⇒ Object
Instead of applying each attribute one by one, flush after all attributes have been updated
46 47 48 49 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 46 def flush config = map_resource_hash_to_config Bamboo::Rest.update_bamboo_settings(self.class.bamboo_resource, config, 'put', self.class.content_type) end |
#map_resource_hash_to_config ⇒ Object
map resource hash to format accepted by REST resource
41 42 43 |
# File 'lib/puppet/provider/bamboo_provider.rb', line 41 def map_resource_hash_to_config notice('Need to be implemented') end |