Sha256: 187a14e85f64f06fcb3ddf14151dbcdc95b7b8f650902e090ef8291a2807fc67

Contents?: true

Size: 878 Bytes

Versions: 4

Compression:

Stored size: 878 Bytes

Contents

class ECR < Mapper
  #
  # Returns an array of resources.
  #
  def collect
    resources = []

    #
    # describe_repositories
    #
    @client.describe_repositories.each_with_index do |response, page|
      log(response.context.operation_name, page)

      response.repositories.each do |repo|
        struct = OpenStruct.new(repo.to_h)
        struct.type = 'repository'
        struct.arn = repo.repository_arn
        struct.policy = @client
                        .get_repository_policy({ repository_name: repo.repository_name }).policy_text.parse_policy

      rescue Aws::ECR::Errors::ServiceError => e
        raise e unless suppressed_errors.include?(e.code)
      ensure
        resources.push(struct.to_h)
      end
    end

    resources
  end

  private

  # not an error
  def suppressed_errors
    %w[
      RepositoryPolicyNotFoundException
    ]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aws_recon-0.2.24 lib/aws_recon/collectors/ecr.rb
aws_recon-0.2.23 lib/aws_recon/collectors/ecr.rb
aws_recon-0.2.22 lib/aws_recon/collectors/ecr.rb
aws_recon-0.2.21 lib/aws_recon/collectors/ecr.rb