Sha256: 56cd736462cf150c27cabbfa949df5c9a8eda5a99a9b0f91a7dd4eb90e93005a

Contents?: true

Size: 958 Bytes

Versions: 3

Compression:

Stored size: 958 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
        log_error(e.code)

        unless suppressed_errors.include?(e.code) && !@options.quit_on_exception
          raise e
        end
      ensure
        resources.push(struct.to_h)
      end
    end

    resources
  end

  private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
aws_recon-0.2.27 lib/aws_recon/collectors/ecr.rb
aws_recon-0.2.26 lib/aws_recon/collectors/ecr.rb
aws_recon-0.2.25 lib/aws_recon/collectors/ecr.rb