retag 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -0
- data/Gemfile.lock +110 -0
- data/bin/console +16 -0
- data/bin/retag +167 -0
- data/bin/setup +8 -0
- data/lib/retag/version.rb +1 -1
- data/retag.gemspec +39 -0
- data/sig/retag.rbs +4 -0
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cbe24b954c5ae0cc55386882c55d0d056239c20df8780ed732346e6fc577656
|
4
|
+
data.tar.gz: e71492bf16f2deb5ca71ca252a8324511c9469c20a5502cd00a703968c0782ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb8cc1fa4fed581f33e96c53a0258ed9b9532d163a532a554d492e988202411eb70f23a8542f5b68acd7b79f1440d2f9429b0b454ed2f1d1a6873a2427caf1c
|
7
|
+
data.tar.gz: 7e764cecb0bfd5015a7c7b0f91b2cefbc72008421ede60e40c21d72ca8bb3806812120f7e35faa57c3c41c7da673ed2d7b9a483737e7bb46288dcdbbc1255bcc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
retag (0.1.2)
|
5
|
+
activesupport (~> 6.0)
|
6
|
+
colorize
|
7
|
+
json
|
8
|
+
thor
|
9
|
+
uri
|
10
|
+
yaml
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (6.1.4.4)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
addressable (2.8.0)
|
22
|
+
public_suffix (>= 2.0.2, < 5.0)
|
23
|
+
ansi (1.5.0)
|
24
|
+
ast (2.4.2)
|
25
|
+
colorize (0.8.1)
|
26
|
+
concurrent-ruby (1.1.9)
|
27
|
+
crack (0.4.5)
|
28
|
+
rexml
|
29
|
+
diff-lcs (1.5.0)
|
30
|
+
docile (1.4.0)
|
31
|
+
hashdiff (1.0.1)
|
32
|
+
i18n (1.8.11)
|
33
|
+
concurrent-ruby (~> 1.0)
|
34
|
+
json (2.6.1)
|
35
|
+
minitest (5.15.0)
|
36
|
+
parallel (1.21.0)
|
37
|
+
parser (3.1.0.0)
|
38
|
+
ast (~> 2.4.1)
|
39
|
+
public_suffix (4.0.6)
|
40
|
+
rainbow (3.1.1)
|
41
|
+
rake (13.0.6)
|
42
|
+
regexp_parser (2.2.0)
|
43
|
+
rexml (3.2.5)
|
44
|
+
rspec (3.10.0)
|
45
|
+
rspec-core (~> 3.10.0)
|
46
|
+
rspec-expectations (~> 3.10.0)
|
47
|
+
rspec-mocks (~> 3.10.0)
|
48
|
+
rspec-core (3.10.1)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-expectations (3.10.2)
|
51
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
52
|
+
rspec-support (~> 3.10.0)
|
53
|
+
rspec-mocks (3.10.2)
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
55
|
+
rspec-support (~> 3.10.0)
|
56
|
+
rspec-support (3.10.3)
|
57
|
+
rspec_junit_formatter (0.5.1)
|
58
|
+
rspec-core (>= 2, < 4, != 2.12.0)
|
59
|
+
rubocop (1.25.0)
|
60
|
+
parallel (~> 1.10)
|
61
|
+
parser (>= 3.1.0.0)
|
62
|
+
rainbow (>= 2.2.2, < 4.0)
|
63
|
+
regexp_parser (>= 1.8, < 3.0)
|
64
|
+
rexml
|
65
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
66
|
+
ruby-progressbar (~> 1.7)
|
67
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
68
|
+
rubocop-ast (1.15.1)
|
69
|
+
parser (>= 3.0.1.1)
|
70
|
+
ruby-progressbar (1.11.0)
|
71
|
+
simplecov (0.21.2)
|
72
|
+
docile (~> 1.1)
|
73
|
+
simplecov-html (~> 0.11)
|
74
|
+
simplecov_json_formatter (~> 0.1)
|
75
|
+
simplecov-console (0.9.1)
|
76
|
+
ansi
|
77
|
+
simplecov
|
78
|
+
terminal-table
|
79
|
+
simplecov-html (0.12.3)
|
80
|
+
simplecov_json_formatter (0.1.3)
|
81
|
+
terminal-table (3.0.2)
|
82
|
+
unicode-display_width (>= 1.1.1, < 3)
|
83
|
+
thor (1.2.1)
|
84
|
+
tzinfo (2.0.4)
|
85
|
+
concurrent-ruby (~> 1.0)
|
86
|
+
unicode-display_width (2.1.0)
|
87
|
+
uri (0.11.0)
|
88
|
+
webmock (3.14.0)
|
89
|
+
addressable (>= 2.8.0)
|
90
|
+
crack (>= 0.3.2)
|
91
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
92
|
+
yaml (0.2.0)
|
93
|
+
zeitwerk (2.5.3)
|
94
|
+
|
95
|
+
PLATFORMS
|
96
|
+
x86_64-linux
|
97
|
+
|
98
|
+
DEPENDENCIES
|
99
|
+
bundler (~> 2.2, >= 2.2.1)
|
100
|
+
rake
|
101
|
+
retag!
|
102
|
+
rspec
|
103
|
+
rspec_junit_formatter
|
104
|
+
rubocop
|
105
|
+
simplecov
|
106
|
+
simplecov-console
|
107
|
+
webmock
|
108
|
+
|
109
|
+
BUNDLED WITH
|
110
|
+
2.2.33
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'retag'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
16
|
+
|
data/bin/retag
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'thor'
|
5
|
+
require 'colorize'
|
6
|
+
require 'retag'
|
7
|
+
|
8
|
+
UTIL = File.basename(__FILE__)
|
9
|
+
ENV_PREFIX = 'RETAG'
|
10
|
+
|
11
|
+
$logger = ActiveSupport::TaggedLogging.new(Retag::Logger.new(STDOUT))
|
12
|
+
$logger.level = :debug
|
13
|
+
|
14
|
+
# config = YAML.load_file('release.yml')
|
15
|
+
# release = config['release']
|
16
|
+
# services = config['services'].map{|(name, cfg)| Service.new(name, cfg, release)}
|
17
|
+
|
18
|
+
# services.each do |srv|
|
19
|
+
# $logger.tagged(srv.name, srv.revision) do
|
20
|
+
# $logger.info "==> Releasing service #{srv.name} from #{srv.repo} at #{srv.branch}:"
|
21
|
+
# $logger.shift do
|
22
|
+
# #$logger.info "* Pulling service..."
|
23
|
+
# #srv.pull
|
24
|
+
# $logger.info "* Tagging service..."
|
25
|
+
# srv.release!
|
26
|
+
# #$logger.info "* Pushing service..."
|
27
|
+
# #srv.push
|
28
|
+
# #$logger.info "* Cleaning service..."
|
29
|
+
# #srv.rm
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
# $logger.info "==> #{services.count} relesed as #{release}"
|
35
|
+
|
36
|
+
class Cli < Thor
|
37
|
+
|
38
|
+
def self.exit_on_failure?
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# class_option :plugin_gemname, default: ENV.fetch('PLUGIN_GEMNAME', 'unknown'),
|
43
|
+
# desc: 'Name of the current gem'
|
44
|
+
# class_option :service_image, default: ENV.fetch('SERVICE_IMAGE', 'tmpimage'),
|
45
|
+
# desc: 'Docker image name to build. Taken from SERVICE_IMAGE enviroment variable'
|
46
|
+
# class_option :service_tag, default: ENV.fetch('SERVICE_TAG', 'latest'),
|
47
|
+
# desc: 'Docker image tag to build. Taken from SERVICE_TAG enviroment variable'
|
48
|
+
|
49
|
+
desc 'version', 'Display version'
|
50
|
+
map %w[-v --version] => :version
|
51
|
+
|
52
|
+
def version
|
53
|
+
say Retag::VERSION
|
54
|
+
end
|
55
|
+
|
56
|
+
desc 'tag', 'Tag Docker image without downloading'
|
57
|
+
map %w[--tag] => :tag
|
58
|
+
|
59
|
+
option :image, default: ENV.fetch("#{ENV_PREFIX}_TAG_IMAGE", nil),
|
60
|
+
required: true,
|
61
|
+
desc: "Env: #{ENV_PREFIX}_TAG_IMAGE. Full image to be tagged. Ex: docker.rnds.pro/aggredator/service-uprid3:latest"
|
62
|
+
|
63
|
+
option :tag, default: ENV.fetch("#{ENV_PREFIX}_TAG_TAG", nil),
|
64
|
+
required: true,
|
65
|
+
desc: "Env: #{ENV_PREFIX}_TAG_TAG. New tag."
|
66
|
+
|
67
|
+
option :suffix, default: ENV.fetch("#{ENV_PREFIX}_TAG_SUFFIX", nil),
|
68
|
+
required: false,
|
69
|
+
desc: "Env: #{ENV_PREFIX}_TAG_SUFFIX. Optional suffix added to image tag: <image>:<tag>[-<suffix>].
|
70
|
+
Example:
|
71
|
+
# retag tag --image=registry/image:0a4bfc5 --tag v1.2.3 --suffix stable is equivalent to
|
72
|
+
docker tag registry/image:0a4bfc5-stable registry/image:v1.2.3
|
73
|
+
"
|
74
|
+
|
75
|
+
def tag(*_args)
|
76
|
+
opts = options.to_h.dup
|
77
|
+
img, tag = opts['image'].split(':')
|
78
|
+
tag ||= 'latest'
|
79
|
+
tag = opts['suffix'].present? ? "#{tag}-#{opts['suffix']}" : tag
|
80
|
+
|
81
|
+
image = ::Retag::Image.new(img, tag)
|
82
|
+
image.retag!(opts['tag'])
|
83
|
+
end
|
84
|
+
|
85
|
+
desc 'release', 'Release projects bundler from release.yml manifest'
|
86
|
+
map %w[--release] => :release
|
87
|
+
|
88
|
+
option :config, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_CONFIG", './release.yml'),
|
89
|
+
required: true,
|
90
|
+
desc: "Env: #{ENV_PREFIX}_RELEASE_CONFIG. Path to release manifest"
|
91
|
+
|
92
|
+
option :name, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_NAME", nil),
|
93
|
+
required: false,
|
94
|
+
desc: "Env: #{ENV_PREFIX}_RELEASE_NAME. Name of the current release"
|
95
|
+
|
96
|
+
def release(*_args)
|
97
|
+
opts = options.to_h.dup
|
98
|
+
config = YAML.load_file(File.expand_path(opts['config']))
|
99
|
+
config['release'] = opts['name'] || config['release']
|
100
|
+
|
101
|
+
release = config['release']
|
102
|
+
suffix = config['suffix']
|
103
|
+
|
104
|
+
services = config['services'].map do|(name, cfg)|
|
105
|
+
Retag::Service.new(name, cfg, release, suffix: cfg.fetch('suffix', suffix)) unless name.start_with?('.')
|
106
|
+
end.compact
|
107
|
+
|
108
|
+
services.each do |srv|
|
109
|
+
$logger.tagged(srv.name.colorize(:yellow), "#{srv.revision.colorize(mode: :bold)}@#{srv.branch}") do
|
110
|
+
$logger.info "#{'==>'.colorize(mode: :bold, color: :white)} Releasing service #{srv.name.colorize(:yellow)} from #{srv.repo} at #{srv.branch}:"
|
111
|
+
$logger.shift do
|
112
|
+
srv.images.each do |img|
|
113
|
+
$logger.info "Source image: #{img.full}"
|
114
|
+
newimg = img.retag!(release)
|
115
|
+
$logger.info "Release image: #{newimg.full}"
|
116
|
+
end
|
117
|
+
|
118
|
+
#$logger.info "* Pulling service..."
|
119
|
+
#srv.pull
|
120
|
+
#$logger.info "* Tagging service..."
|
121
|
+
#srv.release!
|
122
|
+
#$logger.info "* Pushing service..."
|
123
|
+
#srv.push
|
124
|
+
#$logger.info "* Cleaning service..."
|
125
|
+
#srv.rm
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
private
|
133
|
+
|
134
|
+
def cache_image(opts)
|
135
|
+
"#{opts['service_image']}_cache:latest"
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
139
|
+
|
140
|
+
::Cli.start
|
141
|
+
|
142
|
+
# puts ARGV.inspect
|
143
|
+
|
144
|
+
# parser.parse!
|
145
|
+
|
146
|
+
# puts ARGV.inspect
|
147
|
+
|
148
|
+
# warn parser.help
|
149
|
+
# exit 1
|
150
|
+
|
151
|
+
# config = {
|
152
|
+
# services: [
|
153
|
+
# {core: {images: []}}
|
154
|
+
# ]
|
155
|
+
# }
|
156
|
+
|
157
|
+
# release=$(cat .release | head -n 1)
|
158
|
+
|
159
|
+
# for line in "${services[@]}"; do
|
160
|
+
# module=$(echo $line | cut -f1 -d '|')
|
161
|
+
# repo=$(echo $line | cut -f2 -d '|')
|
162
|
+
# branch=$(echo $line | cut -f3 -d '|')
|
163
|
+
|
164
|
+
# echo "Tagging ${module} from ${branch} of ${repo}"
|
165
|
+
# git subtree push --prefix="src/${module}" "${repo}" "feature/otr"
|
166
|
+
# done
|
167
|
+
|
data/bin/setup
ADDED
data/lib/retag/version.rb
CHANGED
data/retag.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/retag/version'
|
4
|
+
|
5
|
+
Gem::Specification.new 'retag' do |spec|
|
6
|
+
spec.version = ENV['BUILDVERSION'].to_i > 0 ? "#{Retag::VERSION}.#{ENV['BUILDVERSION'].to_i}" : Retag::VERSION
|
7
|
+
spec.authors = ['Samoilenko Yuri']
|
8
|
+
spec.email = ['kinnalru@gmail.com']
|
9
|
+
spec.description = spec.summary = 'Retag is cli to manipulate docker images in handy way'
|
10
|
+
spec.homepage = 'https://github.com/RnD-Soft/retag'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.required_ruby_version = '>= 2.5.0'
|
14
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
15
|
+
spec.metadata['source_code_uri'] = 'https://github.com/RnD-Soft/retag'
|
16
|
+
|
17
|
+
spec.files = Dir['bin/**/*', 'lib/**/*', 'sig/**/*', 'Gemfile*', 'LICENSE', 'README.md', '*.gemspec']
|
18
|
+
|
19
|
+
spec.bindir = 'bin'
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/retag}) {|f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.1'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
spec.add_development_dependency 'rspec_junit_formatter'
|
27
|
+
spec.add_development_dependency 'rubocop'
|
28
|
+
spec.add_development_dependency 'simplecov'
|
29
|
+
spec.add_development_dependency 'simplecov-console'
|
30
|
+
spec.add_development_dependency 'webmock'
|
31
|
+
|
32
|
+
spec.add_runtime_dependency 'activesupport', '~> 6.0'
|
33
|
+
spec.add_runtime_dependency 'colorize'
|
34
|
+
spec.add_runtime_dependency 'json'
|
35
|
+
spec.add_runtime_dependency 'thor'
|
36
|
+
spec.add_runtime_dependency 'uri'
|
37
|
+
spec.add_runtime_dependency 'yaml'
|
38
|
+
end
|
39
|
+
|
data/sig/retag.rbs
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoilenko Yuri
|
@@ -215,18 +215,26 @@ dependencies:
|
|
215
215
|
description: Retag is cli to manipulate docker images in handy way
|
216
216
|
email:
|
217
217
|
- kinnalru@gmail.com
|
218
|
-
executables:
|
218
|
+
executables:
|
219
|
+
- retag
|
219
220
|
extensions: []
|
220
221
|
extra_rdoc_files: []
|
221
222
|
files:
|
223
|
+
- Gemfile
|
224
|
+
- Gemfile.lock
|
222
225
|
- LICENSE
|
223
226
|
- README.md
|
227
|
+
- bin/console
|
228
|
+
- bin/retag
|
229
|
+
- bin/setup
|
224
230
|
- lib/retag.rb
|
225
231
|
- lib/retag/image.rb
|
226
232
|
- lib/retag/logger.rb
|
227
233
|
- lib/retag/service.rb
|
228
234
|
- lib/retag/utils.rb
|
229
235
|
- lib/retag/version.rb
|
236
|
+
- retag.gemspec
|
237
|
+
- sig/retag.rbs
|
230
238
|
homepage: https://github.com/RnD-Soft/retag
|
231
239
|
licenses:
|
232
240
|
- MIT
|