Sha256: fe807e67a65c5267476882331a93000a757e0f3fde36b065dca7a816cedf6245

Contents?: true

Size: 961 Bytes

Versions: 1

Compression:

Stored size: 961 Bytes

Contents

# frozen_string_literal: true

module Gl
  class Registry < Thor
    desc 'status', 'display statistics about the registry'
    def status
      project = Gl.current_project

      registries = Gitlab.registry_repositories(project).auto_paginate

      table = TTY::Table.new(header: %w[Registry Tags Size]) do |table|
        registries.each do |registry|
          tags = Gitlab.registry_repository_tags(project, registry.id).auto_paginate

          next if tags.empty?

          tags = tags.map do |tag|
            Gitlab.registry_repository_tag(project, registry.id, tag.name)
          rescue Gitlab::Error::NotFound
            next
          end

          tags_size = tags.flatten.compact.map(&:total_size).inject(0) { |sum, x| sum + x }
          table << [registry.path, tags.count, "#{(tags_size / 1024.0 / 1024.0).round(2)} MB"]
        end
      end
      puts table.render(:ascii, alignments: %i[left right], padding: [0, 1])
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gl-0.3.0 lib/gl/cli/registry.rb