Sha256: 50bf79109d991ed402613c913ebdbc6df6803d38b7d15e3399f34d4c3e888a83

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Heirloom

  class ArtifactAuthorizer

    def initialize(args)
      @config = args[:config]
      @logger = args[:logger]
    end

    def authorize(args)
      id = args[:id]
      name = args[:name]
      public_readable = args[:public_readable]

      unless public_readable
        @logger.info "Authorizing access to artifact."

        @config.regions.each do |region|
          bucket = artifact_reader.get_bucket :region => region,
                                              :name   => name,
                                              :id     => id
          s3_acl = ACL::S3.new :config => @config,
                               :logger => @logger,
                               :region => region

          s3_acl.allow_read_acccess_from_accounts :key_name => id,
                                                  :key_folder => name,
                                                  :bucket => bucket
        end
      end
    end

    private

    def artifact_reader
      @artifact_reader ||= ArtifactReader.new :config => @config
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.1.3 lib/heirloom/artifact/artifact_authorizer.rb