Sha256: 3a1541769675570069d11a7cb26341db3620500ef7fab9c43e87368868f940db

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

module SimpleDeploy
  class StackAttributeFormater

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

    def updated_attributes(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

    private

    def artifact_names
      @config.artifacts
    end
    
    def cloud_formation_url(attribute)
      name = attribute.keys.first
      id = attribute[name]

      bucket_prefix = @main_attributes["#{name}_bucket_prefix"]
      domain = @main_attributes["#{name}_domain"]
      artifact = Artifact.new :name          => name,
                              :id            => id,
                              :region        => @region,
                              :config        => @config,
                              :domain        => domain,
                              :bucket_prefix => bucket_prefix

      url_parameter = @config.artifact_cloud_formation_url name
      { url_parameter => artifact.endpoints['s3'] }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simple_deploy-0.5.1 lib/simple_deploy/stack/stack_attribute_formater.rb