Class: Tagfish::TagsCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/tagfish/tags_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/tagfish/tags_command.rb', line 10

def execute
  
  docker_uri = DockerURI.parse(repository)
  docker_api = DockerRegistryClient.for(docker_uri)
  
  if latest?
    tags = docker_api.tag_map
    latest_tag = tags.latest_tag
    if latest_tag.nil?
      signal_error "No image explicitly tagged in this Repository, " +
              "only `latest` tag available."
    end
    tags_found = [latest_tag]
  else
    tags_found = docker_api.tag_names
  end

  pretty_tags = tags_found.map do |tag_name|
    short? ? tag_name : docker_uri.with_tag(tag_name).to_s
  end

  puts pretty_tags
end