Class: SimpleDeploy::StackAttributeFormater

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_deploy/stack/stack_attribute_formater.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ StackAttributeFormater

Returns a new instance of StackAttributeFormater.



4
5
6
7
8
9
10
# File 'lib/simple_deploy/stack/stack_attribute_formater.rb', line 4

def initialize(args)
  @attributes = args[:attributes]
  @config = args[:config]
  @environment = args[:environment]
  @region = @config.region @environment
  @logger = @config.logger
end

Instance Method Details

#artifact_namesObject



24
25
26
# File 'lib/simple_deploy/stack/stack_attribute_formater.rb', line 24

def artifact_names
  @config.artifacts.map {|i| i['name']}
end

#cloud_formation_url(attribute) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/simple_deploy/stack/stack_attribute_formater.rb', line 28

def cloud_formation_url attribute
  name = attribute.keys.first
  id = attribute[name]
  a = @config.artifacts.select { |a| a['name'] == name }.first

  endpoint = a['endpoint'] ||= 's3'
  variable = a['variable']
  bucket_prefix = a['bucket_prefix']
  cloud_formation_url = a['cloud_formation_url']

  artifact = Artifact.new :name          => name,
                          :id            => id,
                          :region        => @region,
                          :config        => @config,
                          :bucket_prefix => bucket_prefix

  { cloud_formation_url => artifact.endpoints[endpoint] }
end

#updated_attributesObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/simple_deploy/stack/stack_attribute_formater.rb', line 12

def updated_attributes
  updates = []
  @attributes.each do |attribute|
    key = attribute.keys.first
    if artifact_names.include? key
      updates << cloud_formation_url(attribute)
      @logger.info "Adding artifact attribute: #{cloud_formation_url(attribute)}"
    end
  end
  @attributes + updates
end