tagfish 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/tagfish/api_call.rb +9 -1
- data/lib/tagfish/docker_http_auth.rb +1 -1
- data/lib/tagfish/docker_registry_v1_client.rb +6 -6
- data/lib/tagfish/docker_registry_v2_client.rb +8 -8
- data/lib/tagfish/tags_command.rb +13 -4
- data/lib/tagfish/update/updater.rb +1 -1
- data/lib/tagfish/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd9bcb5d1929a71e1a54b46c9d03ac992113de4a
|
4
|
+
data.tar.gz: 81fce340dddd5f00b36ec61f05039c770533d154
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c4d6f8180f2779473365b04488406775fb8d8fadd92a12db0b570b55a3fea41d7d04162fc355f1738b4c6e91a063510730572e693df2c6b1a04beac4aef409a
|
7
|
+
data.tar.gz: d532b8f0ab2367fbd673c494aea6c6159250566a1777f37aa3eb8a4cfc89b52fb7ef8ea31d5207ff32a106f57787eb83f07ae75dafa12f43d04a186baf452b75
|
data/README.md
CHANGED
@@ -50,12 +50,20 @@ The `tags` subcommands is used to retrieve tags from a given repository:
|
|
50
50
|
Options:
|
51
51
|
-l, --latest only return latest explicitly tagged image
|
52
52
|
-s, --short only return tag, not full image path
|
53
|
+
-d, --digest returns the tag's digest (v2 API only)
|
53
54
|
-h, --help print help
|
54
55
|
|
55
56
|
Where `repository` is a docker repository path, including the docker registry. The tags are returned in alphabetical order.
|
56
57
|
|
57
58
|
The `--latest` option gets the image ID of the docker image tagged `latest` in the repository, finds a matching image with a tag set manually (e.g: date, version number), and returns that tag. This option will not work if there is no image tagged `latest` in your repository.
|
58
59
|
|
60
|
+
EXPERIMENTAL: The `--digest` option returns the tag with its hash. It only works in conjunction
|
61
|
+
with the `--latest` option and against a registry running the v2 API. As of today it doesn't work against Docker Hub, because we're accessing it over API v1 to avoid the authentication mecanism. It returns a string such as:
|
62
|
+
```
|
63
|
+
my-registry/cowbell/tagfish:1.1.3@sha256:491c87df7d5f...
|
64
|
+
```
|
65
|
+
This is used to lock down not only to a specific tag version, but to a specific image hash. So even if the tag is reassigned later, this will still point to the same image.
|
66
|
+
|
59
67
|
#### Example
|
60
68
|
```
|
61
69
|
$ tagfish tags alpine
|
data/lib/tagfish/api_call.rb
CHANGED
@@ -46,6 +46,14 @@ module Tagfish
|
|
46
46
|
abort("Call to the registry API failed, the following resource might not exist:\n#{uri.to_s}")
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
|
+
def digest
|
51
|
+
begin
|
52
|
+
response = http.request(request)
|
53
|
+
return response.fetch("Docker-Content-Digest")
|
54
|
+
rescue SocketError
|
55
|
+
puts "ERROR: SocketError"
|
56
|
+
end
|
57
|
+
end
|
50
58
|
end
|
51
59
|
end
|
@@ -13,7 +13,7 @@ module Tagfish
|
|
13
13
|
begin
|
14
14
|
config = File.open(File.expand_path(file_path), 'r')
|
15
15
|
rescue Exception => e
|
16
|
-
abort("Tried to get
|
16
|
+
abort("Tried to get username/password but the file #{file_path} does not exist")
|
17
17
|
end
|
18
18
|
|
19
19
|
json_config = JSON.parse(config.read())
|
@@ -8,28 +8,28 @@ module Tagfish
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def tag_names
|
11
|
-
|
11
|
+
tags.tag_names
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
tags_list = tags_api(
|
14
|
+
def tags
|
15
|
+
tags_list = tags_api(tags_json)
|
16
16
|
Tagfish::Tags.new(tags_list)
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def
|
21
|
+
def tags_json
|
22
22
|
api_call.get(tags_uri).json
|
23
23
|
end
|
24
24
|
|
25
25
|
def tags_api(api_response_data)
|
26
26
|
case api_response_data
|
27
|
-
|
27
|
+
when Hash
|
28
28
|
api_response_data
|
29
29
|
when Array
|
30
30
|
api_response_data.reduce({}) do |images, tag|
|
31
31
|
images.merge({tag["name"] => tag["layer"]})
|
32
|
-
|
32
|
+
end
|
33
33
|
else
|
34
34
|
raise "unexpected type #{api_response_data.class}"
|
35
35
|
end
|
@@ -8,30 +8,30 @@ module Tagfish
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def tag_names
|
11
|
-
|
11
|
+
tags_json["tags"]
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
15
|
-
Tagfish::Tags.new(
|
14
|
+
def tags
|
15
|
+
Tagfish::Tags.new(tags_list)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
|
-
def
|
20
|
+
def tags_json
|
21
21
|
api_call.get(tags_uri).json
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
api_call.get(hash_uri(tag)).
|
24
|
+
def digest(tag)
|
25
|
+
api_call.get(hash_uri(tag)).digest
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
28
|
+
def tags_list
|
29
29
|
if tag_names.nil?
|
30
30
|
abort("No Tags found for this repository")
|
31
31
|
end
|
32
32
|
|
33
33
|
tags_with_hashes = tag_names.inject({}) do |dict, tag|
|
34
|
-
dict[tag] =
|
34
|
+
dict[tag] = digest(tag)
|
35
35
|
dict
|
36
36
|
end
|
37
37
|
end
|
data/lib/tagfish/tags_command.rb
CHANGED
@@ -6,6 +6,7 @@ module Tagfish
|
|
6
6
|
parameter "REPOSITORY", "docker repository"
|
7
7
|
option ["-l", "--latest"], :flag, "only return latest explicitly tagged image"
|
8
8
|
option ["-s", "--short"], :flag, "only return tag, not full image path"
|
9
|
+
option ["-d", "--digest"], :flag, "returns the tag's digest (v2 API only)"
|
9
10
|
|
10
11
|
def execute
|
11
12
|
|
@@ -13,22 +14,30 @@ module Tagfish
|
|
13
14
|
docker_api = DockerRegistryClient.for(docker_uri)
|
14
15
|
|
15
16
|
if latest?
|
16
|
-
tags = docker_api.
|
17
|
+
tags = docker_api.tags
|
17
18
|
latest_tags = tags.latest_tags
|
18
19
|
if latest_tags.empty?
|
19
20
|
signal_error "No image explicitly tagged in this Repository, " +
|
20
21
|
"only `latest` tag available."
|
21
22
|
end
|
22
23
|
tags_found = latest_tags
|
24
|
+
|
25
|
+
if digest?
|
26
|
+
tags_found = tags_found.map do |tag_name|
|
27
|
+
digest = tags.tag_map[tag_name]
|
28
|
+
digest.include?("sha256:") ? tag_name + '@' + digest : tag_name
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
23
32
|
else
|
24
33
|
tags_found = docker_api.tag_names
|
25
34
|
end
|
26
35
|
|
27
|
-
|
36
|
+
tags_fqdn = tags_found.map do |tag_name|
|
28
37
|
short? ? tag_name : docker_uri.with_tag(tag_name).to_s
|
29
38
|
end
|
30
|
-
|
31
|
-
puts
|
39
|
+
|
40
|
+
puts tags_fqdn
|
32
41
|
end
|
33
42
|
end
|
34
43
|
end
|
data/lib/tagfish/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clement Labbe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|