tagfish 1.0.3 → 1.1.0
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 +2 -31
- data/bin/tagfish +1 -6
- data/lib/tagfish/api_call.rb +20 -10
- data/lib/tagfish/docker_registry_v1_client.rb +1 -13
- data/lib/tagfish/docker_registry_v2_client.rb +2 -18
- data/lib/tagfish/docker_registry_vboth_client.rb +5 -3
- data/lib/tagfish/version.rb +1 -1
- metadata +1 -2
- data/lib/tagfish/search_command.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83601af2f323594eb16a06d92ce666ce94e82580
|
4
|
+
data.tar.gz: 5f79d1303e6bd48a517d0a23b9665d4d7e0b1bae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f29ea037986d26b33f347c20a1e2780ad95be58bbf180dbf6a19c986f72f5b7362f921fb374fca5eec0e1354b2358f11014342068caca2be0bf0c640b3559ee
|
7
|
+
data.tar.gz: 8e76d79699a7df157669a789c52146197b1e54d7032fd5c2dbdd3ea0137d07ce7c974d5ba985e59f56d4cf939159237afb27dbd223c7d66421ae8f6fc5fde6ed
|
data/README.md
CHANGED
@@ -9,7 +9,6 @@ Features include:
|
|
9
9
|
- List all the tags of a given Docker repository
|
10
10
|
- Return the most recent explicit tag of a repository
|
11
11
|
- Update a file with the newest tags
|
12
|
-
- Search for a repository
|
13
12
|
- Authenticate by reading native Docker config file
|
14
13
|
- Works against hub.docker.com and private registries
|
15
14
|
- Supports Docker Registry/Distribution API v1 and v2
|
@@ -23,8 +22,6 @@ To use Tagfish against a registry requiring authentication, you first need to au
|
|
23
22
|
- [Usage](#usage)
|
24
23
|
- [`tagfish tags`](#tagfish-tags)
|
25
24
|
- [Example](#example)
|
26
|
-
- [`tagfish search`](#tagfish-search)
|
27
|
-
- [Example](#example-1)
|
28
25
|
- [`tagfish update`](#tagfish-update)
|
29
26
|
- [Example](#example-2)
|
30
27
|
- [Official repositories](#official-repositories)
|
@@ -70,33 +67,6 @@ alpine:edge
|
|
70
67
|
alpine:latest
|
71
68
|
```
|
72
69
|
|
73
|
-
### `tagfish search`
|
74
|
-
The `search` command is used to search for a repository in a given registry.
|
75
|
-
|
76
|
-
Usage:
|
77
|
-
tagfish search [OPTIONS] [KEYWORD]
|
78
|
-
|
79
|
-
Parameters:
|
80
|
-
[KEYWORD] object to search
|
81
|
-
|
82
|
-
Options:
|
83
|
-
-r, --registry REGISTRY Docker registry (default: "index.docker.io")
|
84
|
-
-h, --help print help
|
85
|
-
|
86
|
-
Note: `search` will not work if the search API is disabled on the registry side.
|
87
|
-
|
88
|
-
#### Example
|
89
|
-
```
|
90
|
-
$ tagfish search alpine
|
91
|
-
alpine
|
92
|
-
1science/alpine
|
93
|
-
webhippie/alpine
|
94
|
-
anapsix/alpine-java
|
95
|
-
colstrom/alpine
|
96
|
-
appelgriebsch/alpine
|
97
|
-
[...]
|
98
|
-
```
|
99
|
-
|
100
70
|
### `tagfish update`
|
101
71
|
The `update` subcommand is used to update a file with the latest tags available:
|
102
72
|
|
@@ -148,7 +118,8 @@ Tagfish is released as a Docker image as well, and can be run with:
|
|
148
118
|
docker run --rm \
|
149
119
|
-v ~/.docker:/root/.docker:ro \
|
150
120
|
-v ${PWD}:/cwd \
|
151
|
-
cowbell/tagfish
|
121
|
+
cowbell/tagfish \
|
122
|
+
<COMMAND>
|
152
123
|
```
|
153
124
|
|
154
125
|
## Contributing
|
data/bin/tagfish
CHANGED
@@ -5,8 +5,7 @@ $LOAD_PATH << File.expand_path("../../lib", __FILE__)
|
|
5
5
|
require 'clamp'
|
6
6
|
require 'tagfish/tags_command'
|
7
7
|
require 'tagfish/update/update_command'
|
8
|
-
require 'tagfish/
|
9
|
-
require "tagfish/version"
|
8
|
+
require 'tagfish/version'
|
10
9
|
|
11
10
|
module Tagfish
|
12
11
|
class MainCommand < Clamp::Command
|
@@ -24,9 +23,5 @@ module Tagfish
|
|
24
23
|
subcommand "update", "inspect files for outdated dependencies", Update::UpdateCommand
|
25
24
|
end
|
26
25
|
|
27
|
-
class MainCommand < Clamp::Command
|
28
|
-
subcommand "search", "search a registry for repositories", SearchCommand
|
29
|
-
end
|
30
|
-
|
31
26
|
MainCommand.run
|
32
27
|
end
|
data/lib/tagfish/api_call.rb
CHANGED
@@ -1,19 +1,33 @@
|
|
1
|
+
require 'tagfish/docker_http_auth'
|
2
|
+
|
1
3
|
module Tagfish
|
2
4
|
class APICall
|
3
5
|
attr_accessor :uri
|
4
6
|
attr_accessor :http
|
5
7
|
attr_accessor :request
|
6
|
-
|
7
|
-
|
8
|
+
attr_accessor :http_auth
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@auth = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(uri_string)
|
8
15
|
@uri = URI.parse(uri_string)
|
9
16
|
@http = Net::HTTP.new(uri.host, uri.port)
|
10
17
|
@http.use_ssl = true if uri.port == 443
|
11
18
|
@request = Net::HTTP::Get.new(uri.request_uri)
|
19
|
+
if http_auth
|
20
|
+
@request.basic_auth(http_auth.username, http_auth.password)
|
21
|
+
end
|
22
|
+
self
|
12
23
|
end
|
13
|
-
|
14
|
-
def
|
24
|
+
|
25
|
+
def auth(registry)
|
26
|
+
@http_auth = DockerHttpAuth.new(registry)
|
27
|
+
end
|
28
|
+
|
29
|
+
def json
|
15
30
|
begin
|
16
|
-
auth(http_auth) if http_auth
|
17
31
|
response = http.request(request)
|
18
32
|
if response.code == "200"
|
19
33
|
return JSON.parse(response.body)
|
@@ -25,8 +39,7 @@ module Tagfish
|
|
25
39
|
end
|
26
40
|
end
|
27
41
|
|
28
|
-
def response_code
|
29
|
-
auth(http_auth) if http_auth
|
42
|
+
def response_code
|
30
43
|
begin
|
31
44
|
http.request(request).code.to_i
|
32
45
|
rescue SocketError
|
@@ -34,8 +47,5 @@ module Tagfish
|
|
34
47
|
end
|
35
48
|
end
|
36
49
|
|
37
|
-
def auth(http_auth)
|
38
|
-
@request.basic_auth(http_auth.username, http_auth.password)
|
39
|
-
end
|
40
50
|
end
|
41
51
|
end
|
@@ -7,14 +7,6 @@ module Tagfish
|
|
7
7
|
'v1'
|
8
8
|
end
|
9
9
|
|
10
|
-
def search(keyword)
|
11
|
-
if not keyword
|
12
|
-
abort("You need to specify a keyword to search a Registry V1")
|
13
|
-
end
|
14
|
-
repos_raw = APICall.new(search_uri(keyword)).get_json(http_auth)
|
15
|
-
repos = repos_raw["results"].map {|result| result["name"]}
|
16
|
-
end
|
17
|
-
|
18
10
|
def tag_names
|
19
11
|
tag_map.tag_names
|
20
12
|
end
|
@@ -27,7 +19,7 @@ module Tagfish
|
|
27
19
|
private
|
28
20
|
|
29
21
|
def tags
|
30
|
-
|
22
|
+
api_call.get(tags_uri).json
|
31
23
|
end
|
32
24
|
|
33
25
|
def tags_api(api_response_data)
|
@@ -47,10 +39,6 @@ module Tagfish
|
|
47
39
|
"#{base_uri}/v1/_ping"
|
48
40
|
end
|
49
41
|
|
50
|
-
def search_uri(keyword)
|
51
|
-
"#{base_uri}/v1/search?q=#{keyword}"
|
52
|
-
end
|
53
|
-
|
54
42
|
def tags_uri
|
55
43
|
"#{base_uri}/v1/repositories/#{docker_uri.repository}/tags"
|
56
44
|
end
|
@@ -7,14 +7,6 @@ module Tagfish
|
|
7
7
|
'v2'
|
8
8
|
end
|
9
9
|
|
10
|
-
def search(keyword)
|
11
|
-
repo_list = catalog
|
12
|
-
if keyword
|
13
|
-
repo_list.select! {|repo| repo.include? keyword}
|
14
|
-
end
|
15
|
-
repo_list.map {|repo| "#{docker_uri.registry}/#{repo}"}
|
16
|
-
end
|
17
|
-
|
18
10
|
def tag_names
|
19
11
|
tags["tags"]
|
20
12
|
end
|
@@ -25,16 +17,12 @@ module Tagfish
|
|
25
17
|
|
26
18
|
private
|
27
19
|
|
28
|
-
def catalog
|
29
|
-
APICall.new(catalog_uri).get_json(http_auth)["repositories"]
|
30
|
-
end
|
31
|
-
|
32
20
|
def tags
|
33
|
-
|
21
|
+
api_call.get(tags_uri).json
|
34
22
|
end
|
35
23
|
|
36
24
|
def hash(tag)
|
37
|
-
|
25
|
+
api_call.get(hash_uri(tag)).json
|
38
26
|
end
|
39
27
|
|
40
28
|
def tags_logic
|
@@ -52,10 +40,6 @@ module Tagfish
|
|
52
40
|
"#{base_uri}/v2/"
|
53
41
|
end
|
54
42
|
|
55
|
-
def catalog_uri
|
56
|
-
"#{base_uri}/v2/_catalog"
|
57
|
-
end
|
58
|
-
|
59
43
|
def tags_uri
|
60
44
|
"#{base_uri}/v2/#{docker_uri.repository}/tags/list"
|
61
45
|
end
|
@@ -9,13 +9,15 @@ module Tagfish
|
|
9
9
|
|
10
10
|
attr_accessor :docker_uri
|
11
11
|
attr_accessor :http_auth
|
12
|
+
attr_accessor :api_call
|
12
13
|
|
13
14
|
def initialize(docker_uri)
|
15
|
+
@api_call = APICall.new
|
14
16
|
@docker_uri = docker_uri
|
15
|
-
code =
|
17
|
+
code = api_call.get(ping_uri).response_code
|
16
18
|
if code == 401
|
17
|
-
|
18
|
-
code =
|
19
|
+
api_call.auth(docker_uri.registry)
|
20
|
+
code = api_call.get(ping_uri).response_code
|
19
21
|
end
|
20
22
|
if code == 401
|
21
23
|
raise DockerRegistryClient::AuthenticationError, "Please `docker login <REGISTRY>` and try again"
|
data/lib/tagfish/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tagfish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Clement Labbe
|
@@ -116,7 +116,6 @@ files:
|
|
116
116
|
- lib/tagfish/docker_registry_v2_client.rb
|
117
117
|
- lib/tagfish/docker_registry_vboth_client.rb
|
118
118
|
- lib/tagfish/docker_uri.rb
|
119
|
-
- lib/tagfish/search_command.rb
|
120
119
|
- lib/tagfish/tags.rb
|
121
120
|
- lib/tagfish/tags_command.rb
|
122
121
|
- lib/tagfish/tokeniser.rb
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'tagfish/docker_uri'
|
2
|
-
|
3
|
-
module Tagfish
|
4
|
-
class SearchCommand < Clamp::Command
|
5
|
-
parameter "[KEYWORD]", "object to search"
|
6
|
-
option ["-r", "--registry"], "REGISTRY", "Docker registry", :default => "index.docker.io"
|
7
|
-
|
8
|
-
def execute
|
9
|
-
if not registry and not keyword
|
10
|
-
abort("You need to specify a REGISTRY and/or a KEYWORD")
|
11
|
-
end
|
12
|
-
|
13
|
-
docker_uri = DockerURI.parse(registry + "/" + "dummy")
|
14
|
-
docker_api = DockerRegistryClient.for(docker_uri)
|
15
|
-
puts docker_api.search(keyword)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|