tagfish 1.1.5 → 1.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5ff081cce0c22b7b5f8a8139045485d3fa2184d
4
- data.tar.gz: 9d316b76e1972b0544bcce06eda7cbe4112f3020
3
+ metadata.gz: 05b88f51ae087cebd100f07fb24e5b2a6a11556f
4
+ data.tar.gz: e224ae8aab3b783527d409351f6d20d41b62c9f2
5
5
  SHA512:
6
- metadata.gz: b7770cdc629f1c9adcd61b2f7b5ce20a3669396b8972841af905ee9ae28dbcd430bc1931b3642fe5cd70b306ea37720032ed3e5a08bbd2b5b49f3058003ab9e5
7
- data.tar.gz: 2348139104553d2376420aeebd7b8a9d5eab001a0e3d623ea89cfa1862791d3e80b50304ea45cc31c9f77cabc8f4b25b7322e917320870e97a27711c23885c48
6
+ metadata.gz: 2ec7003db64bba1a474aa200c7b1a40f888e134eaf14c7fd10e8dbb25ee30d786f7793ffb11616faf0c58dd44f43901ed23a8d9a2c372a0ce58b9bf4d1acb9dc
7
+ data.tar.gz: fd83a60351e1f12224990304dbe8995d538a4018dfc51d231be449fad58b8e19efe7c8963c37c108aca3d79dff9d7944aa6169d2767189fb6eb954647549bfe0
@@ -0,0 +1,14 @@
1
+ *.swp
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /spec/examples.txt
11
+ /tmp/
12
+ /*.gem
13
+ /compiled-gem
14
+ /tests
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1 @@
1
+ 2.3
@@ -0,0 +1,4 @@
1
+ sudo: required
2
+
3
+ script:
4
+ - bundle exec rake spec
@@ -0,0 +1,22 @@
1
+ FROM alpine:3.4
2
+ MAINTAINER Clement Labbe <clement.labbe@rea-group.com>
3
+
4
+ RUN apk add --update \
5
+ ruby=2.3.1-r0 \
6
+ ruby-dev=2.3.1-r0 \
7
+ ruby-io-console=2.3.1-r0 \
8
+ diffutils \
9
+ linux-headers \
10
+ build-base \
11
+ ca-certificates && \
12
+ rm /var/cache/apk/* && \
13
+ rm -rf /usr/share/ri
14
+
15
+ RUN echo -e 'gem: --no-rdoc --no-ri' > /etc/gemrc
16
+
17
+ COPY pkg/tagfish-latest.gem /cwd/
18
+ WORKDIR /cwd
19
+ RUN gem install tagfish-latest.gem
20
+ RUN mkdir -p /root/.docker
21
+
22
+ ENTRYPOINT ["tagfish"]
@@ -0,0 +1,20 @@
1
+ FROM alpine:3.4
2
+ MAINTAINER Clement Labbe <clement.labbe@rea-group.com>
3
+
4
+ RUN apk add --update \
5
+ ruby=2.3.1-r0 \
6
+ ruby-dev=2.3.1-r0 \
7
+ ruby-io-console=2.3.1-r0 \
8
+ git \
9
+ diffutils \
10
+ linux-headers \
11
+ build-base \
12
+ ca-certificates && \
13
+ rm /var/cache/apk/* && \
14
+ rm -rf /usr/share/ri
15
+
16
+ RUN echo -e 'gem: --no-rdoc --no-ri' > /etc/gemrc && \
17
+ gem update --system && \
18
+ gem install bundler && \
19
+ rm -rf /usr/share/ri
20
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tagfish.gemspec
4
+ gemspec
@@ -0,0 +1,172 @@
1
+ # Tagfish [![Build Status](https://travis-ci.org/realestate-com-au/tagfish.svg?branch=master)](https://travis-ci.org/realestate-com-au/tagfish)
2
+
3
+
4
+ ![Tagfish logo](logo.png)
5
+
6
+ Tagfish is a CLI tool to interact with Docker registries.
7
+
8
+ Features include:
9
+
10
+ - List all the tags of a given Docker repository
11
+ - Return the most recent explicit tag of a repository
12
+ - Update a file with the newest tags
13
+ - Authenticate by reading native Docker config file
14
+ - Works against hub.docker.com and private registries
15
+ - Supports Docker Registry/Distribution API v1 and v2
16
+
17
+ To use Tagfish against a registry requiring authentication, you first need to authenticate to the given registry using `docker login <REGISTRY>`.
18
+
19
+ ## Table of contents
20
+
21
+ <!-- MarkdownTOC autolink=true bracket=round depth=4 -->
22
+
23
+ - [Usage](#usage)
24
+ - [`tagfish tags`](#tagfish-tags)
25
+ - [Example](#example)
26
+ - [`tagfish update`](#tagfish-update)
27
+ - [Example](#example-2)
28
+ - [Official repositories](#official-repositories)
29
+ - [Installation](#installation)
30
+ - [Gem](#gem)
31
+ - [Limitations](#limitations)
32
+ - [Docker image](#docker-image)
33
+ - [Development](#development)
34
+ - [Contributing](#contributing)
35
+ - [Licence](#licence)
36
+
37
+
38
+ <!-- /MarkdownTOC -->
39
+
40
+ ## Usage
41
+ The Tagfish CLI tool has different subcommands for interacting with Docker registries.
42
+
43
+ ### `tagfish tags`
44
+ The `tags` subcommands is used to retrieve tags from a given repository:
45
+
46
+ Usage:
47
+ tagfish tags [OPTIONS] REPOSITORY
48
+
49
+ Parameters:
50
+ REPOSITORY docker repository
51
+
52
+ Options:
53
+ -l, --latest only return latest explicitly tagged image
54
+ -s, --short only return tag, not full image path
55
+ -h, --help print help
56
+
57
+ Where `repository` is a docker repository path, including the docker registry. The tags are returned in alphabetical order.
58
+
59
+ 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.
60
+
61
+ #### Example
62
+ ```
63
+ $ tagfish tags alpine
64
+ alpine:2.6
65
+ alpine:2.7
66
+ alpine:3.1
67
+ alpine:3.2
68
+ alpine:edge
69
+ alpine:latest
70
+ ```
71
+
72
+ ### `tagfish update`
73
+ The `update` subcommand is used to update a file with the latest tags available:
74
+
75
+ Usage:
76
+ tagfish update [OPTIONS] FILE
77
+
78
+ Parameters:
79
+ FILE file to update
80
+
81
+ Options:
82
+ -d, --dry-run enable dry run
83
+ --only PATTERN Only update repositories matching pattern. Wildcards `*` may be used.
84
+ -h, --help print help
85
+
86
+ #### Example
87
+ ```
88
+ $ tagfish update --dry-run Dockerfile
89
+ -FROM docker-registry.delivery.realestate.com.au/gpde/ubuntu-ruby2.2:201508191500
90
+ +FROM docker-registry.delivery.realestate.com.au/gpde/ubuntu-ruby2.2:201511261833
91
+ ```
92
+
93
+ #### Official repositories
94
+ `tagfish update` will update repositories such as:
95
+ ```
96
+ private.registry/namespace/repository:tag
97
+ namespace/repository:tag
98
+ ```
99
+ However, it will not update the tag of official repositories, such as:
100
+ ```
101
+ ubuntu:tag
102
+ ```
103
+ This is because updating to a new OS automatically might be something you want to avoid, and because it is hard to match a repository without a namespace.
104
+
105
+ ## Installation
106
+ ### Gem
107
+ Tagfish is packaged as a Ruby gem. Install it from the command line:
108
+
109
+ ```
110
+ $ gem install tagfish
111
+ ```
112
+
113
+ #### Limitations
114
+ Tagfish requires Ruby 2.2 or newer if the registry you are accessing restricts TLS to v1.2.
115
+
116
+ ### Docker image
117
+ Tagfish is released as a Docker image as well, and can be run with:
118
+
119
+ ```
120
+ docker run --rm \
121
+ -v ~/.docker:/root/.docker:ro \
122
+ -v ${PWD}:/cwd \
123
+ cowbell/tagfish \
124
+ <COMMAND>
125
+ ```
126
+ ## Development
127
+ - Use dev tagfish
128
+ ```bash
129
+ $ auto/tagfish
130
+ ```
131
+
132
+ - Run the tests
133
+ ```bash
134
+ $ auto/test
135
+ ```
136
+
137
+ - Package gem and Docker image
138
+ ```bash
139
+ $ auto/package
140
+ ```
141
+
142
+ - Release gem and Docker image
143
+ ```bash
144
+ $ auto/release
145
+ ```
146
+ This requires write access to the Git repo, the Gem repo, and the Docker repo.
147
+
148
+ ## Contributing
149
+
150
+ Bug reports and pull requests are welcome on GitHub at https://github.com/realestate-com-au/tagfish .
151
+
152
+ ## Licence
153
+
154
+ Copyright (c) 2015 REA Group Ltd.
155
+
156
+ Permission is hereby granted, free of charge, to any person obtaining a copy
157
+ of this software and associated documentation files (the "Software"), to deal
158
+ in the Software without restriction, including without limitation the rights
159
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
160
+ copies of the Software, and to permit persons to whom the Software is
161
+ furnished to do so, subject to the following conditions:
162
+
163
+ The above copyright notice and this permission notice shall be included in
164
+ all copies or substantial portions of the Software.
165
+
166
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
167
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
168
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
169
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
170
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
171
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
172
+ THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+ require "fileutils"
3
+
4
+ spec = Gem::Specification::load(Dir.glob("*.gemspec").first)
5
+ gem_file = "pkg/#{spec.name}-#{spec.version}.gem"
6
+
7
+ task build_latest: [:build] do
8
+ FileUtils.copy(gem_file, "pkg/tagfish-latest.gem")
9
+ end
10
+
11
+ require "rspec/core/rake_task"
12
+
13
+ desc "Run the specs"
14
+ RSpec::Core::RakeTask.new do |t|
15
+ t.pattern = "spec/**/*_spec.rb"
16
+ end
@@ -0,0 +1,11 @@
1
+ #! /bin/bash -e
2
+ #
3
+ # Run rake
4
+
5
+ cd $(dirname $0)/..
6
+
7
+ trap "docker-compose down --volumes" 0
8
+
9
+ docker volume create --name ruby2.3-bundle-cache > /dev/null
10
+ docker-compose run --rm dev sh -c 'bundle check > /dev/null || bundle install'
11
+ docker-compose run --rm dev bundle exec "${@-sh}"
@@ -0,0 +1,9 @@
1
+ #! /bin/bash -e
2
+
3
+ cd $(dirname $0)/..
4
+
5
+ # Build the gem
6
+ auto/dev-environment rake build_latest
7
+
8
+ # Build the Docker image
9
+ docker build -t cowbell/tagfish:latest .
@@ -0,0 +1,12 @@
1
+ #! /bin/bash -e
2
+
3
+ cd $(dirname $0)/..
4
+
5
+ REPOSITORY=cowbell/tagfish
6
+ VERSION=$(cat lib/tagfish/version.rb | grep VERSION | cut -d'"' -f2)
7
+
8
+ # Ensure we have no local changes
9
+ git diff HEAD --exit-code
10
+
11
+ auto/release-gem
12
+ auto/release-docker-image
@@ -0,0 +1,14 @@
1
+ #! /bin/bash -e
2
+
3
+ cd $(dirname $0)/..
4
+
5
+ REPOSITORY=cowbell/tagfish
6
+ VERSION=$(cat lib/tagfish/version.rb | grep VERSION | cut -d'"' -f2)
7
+
8
+ # Build the image
9
+ docker build -t ${REPOSITORY}:latest .
10
+
11
+ # Release the image
12
+ docker push ${REPOSITORY}:latest
13
+ docker tag ${REPOSITORY}:latest ${REPOSITORY}:${VERSION}
14
+ docker push ${REPOSITORY}:latest
@@ -0,0 +1,7 @@
1
+ #! /bin/bash -e
2
+
3
+ cd $(dirname $0)/..
4
+
5
+ # Release the gem
6
+ auto/dev-environment rake build_latest
7
+ auto/dev-environment rake release
@@ -0,0 +1,3 @@
1
+ #! /bin/bash -e
2
+
3
+ $(dirname $0)/dev-environment bin/tagfish "$@"
@@ -0,0 +1,3 @@
1
+ #! /bin/bash -e
2
+
3
+ $(dirname $0)/dev-environment rake spec
@@ -0,0 +1,18 @@
1
+ version: "2"
2
+
3
+ services:
4
+ dev:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile.dev
8
+ environment:
9
+ - GEM_HOME=/usr/local/bundle
10
+ - GEM_PATH=/usr/lib/ruby/gems/2.3.0:/usr/local/bundle/gems
11
+ volumes:
12
+ - .:/work
13
+ - ruby2.3-bundle-cache:/usr/local/bundle
14
+ working_dir: /work
15
+
16
+ volumes:
17
+ ruby2.3-bundle-cache:
18
+ external: true
@@ -21,7 +21,7 @@ module Tagfish
21
21
  URIFilters.must_not_be_tagged_latest,
22
22
  URIFilters.must_match_repository(only)
23
23
  ]
24
- updater = Updater.new(filters)
24
+ updater = Updater.new(filters, debug?)
25
25
  original = File.read(file)
26
26
  updated = Tokeniser.dump(updater.update(Tokeniser.tokenise(original)))
27
27
 
@@ -0,0 +1,24 @@
1
+ require 'tagfish/registry_credentials'
2
+
3
+ module Tagfish
4
+
5
+ class CredentialStore
6
+
7
+ def initialize(docker_config_data)
8
+ @credentials_by_registry = {}
9
+ auths = docker_config_data.fetch("auths", {})
10
+ auths.each do |registry, data|
11
+ encoded_credentials = data.fetch("auth")
12
+ username, password = Base64.decode64(encoded_credentials).split(":")
13
+ creds = RegistryCredentials.new(username, password)
14
+ @credentials_by_registry[registry] = creds
15
+ end
16
+ end
17
+
18
+ def credentials_for(registry)
19
+ @credentials_by_registry[registry]
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,5 @@
1
+ module Tagfish
2
+
3
+ RegistryCredentials = Struct.new(:username, :password)
4
+
5
+ end
@@ -5,8 +5,11 @@ require 'tagfish/docker_registry_client'
5
5
  module Tagfish
6
6
  module Update
7
7
  class Updater
8
- def initialize(filters)
8
+ attr_reader :debug
9
+
10
+ def initialize(filters, debug = false)
9
11
  @filters = filters
12
+ @debug = debug
10
13
  end
11
14
 
12
15
  def update(tokens)
@@ -38,7 +41,7 @@ module Tagfish
38
41
  end
39
42
 
40
43
  def update_uri(docker_uri)
41
- docker_api = DockerRegistryClient.for(docker_uri)
44
+ docker_api = DockerRegistryClient.for(docker_uri, debug)
42
45
  tags = docker_api.tags
43
46
  newest_tag_name = tags.latest_tags.first
44
47
  if newest_tag_name.nil?
@@ -1,3 +1,3 @@
1
1
  module Tagfish
2
- VERSION = "1.1.5"
2
+ VERSION = "1.1.6"
3
3
  end
Binary file
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tagfish/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tagfish"
8
+ spec.version = Tagfish::VERSION
9
+ spec.authors = ["Clement Labbe"]
10
+ spec.email = ["clement.labbe@rea-group.com"]
11
+ spec.summary = %q{Command line utility for docker registries}
12
+ spec.description = "Retrieve repository tags, update dockerfiles, and more!"
13
+ spec.homepage = "https://github.com/realestate-com-au/tagfish"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = ["tagfish"]
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.3.0"
24
+ spec.add_dependency "clamp", "~> 1.0.0"
25
+ spec.add_dependency "diffy", "~> 3.0.0"
26
+ spec.add_dependency "json", "~> 1.8.0"
27
+ end
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.5
4
+ version: 1.1.6
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-09-18 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,24 @@ executables:
102
102
  extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
+ - ".gitignore"
106
+ - ".rspec"
107
+ - ".ruby-version"
108
+ - ".travis.yml"
109
+ - Dockerfile
110
+ - Dockerfile.dev
111
+ - Gemfile
112
+ - README.md
113
+ - Rakefile
114
+ - auto/dev-environment
115
+ - auto/package
116
+ - auto/release
117
+ - auto/release-docker-image
118
+ - auto/release-gem
119
+ - auto/tagfish
120
+ - auto/test
105
121
  - bin/tagfish
122
+ - docker-compose.yml
106
123
  - lib/tagfish.rb
107
124
  - lib/tagfish/api_call.rb
108
125
  - lib/tagfish/api_error.rb
@@ -111,18 +128,22 @@ files:
111
128
  - lib/tagfish/cli/main_command.rb
112
129
  - lib/tagfish/cli/tags_command.rb
113
130
  - lib/tagfish/cli/update_command.rb
131
+ - lib/tagfish/credential_store.rb
114
132
  - lib/tagfish/docker_http_auth.rb
115
133
  - lib/tagfish/docker_registry_client.rb
116
134
  - lib/tagfish/docker_registry_v1_client.rb
117
135
  - lib/tagfish/docker_registry_v2_client.rb
118
136
  - lib/tagfish/docker_registry_vboth_client.rb
119
137
  - lib/tagfish/docker_uri.rb
138
+ - lib/tagfish/registry_credentials.rb
120
139
  - lib/tagfish/tags.rb
121
140
  - lib/tagfish/tokeniser.rb
122
141
  - lib/tagfish/update/differ.rb
123
142
  - lib/tagfish/update/updater.rb
124
143
  - lib/tagfish/update/uri_filters.rb
125
144
  - lib/tagfish/version.rb
145
+ - logo.png
146
+ - tagfish.gemspec
126
147
  homepage: https://github.com/realestate-com-au/tagfish
127
148
  licenses:
128
149
  - MIT