retag 0.1.10.265664 → 0.2.1.289789
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/Gemfile.lock +69 -55
- data/bin/retag +20 -4
- data/lib/retag/image.rb +20 -4
- data/lib/retag/service.rb +4 -3
- data/lib/retag/version.rb +1 -1
- data/lib/retag.rb +1 -0
- data/retag.gemspec +3 -1
- metadata +32 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b02aec116b0797e9023ac8503214e93f4ebd9036b507223133445336d824935f
|
4
|
+
data.tar.gz: 8c432f0c18632a19c671c764149c0a80d4be7a406fb0f165fdf1cf59b812eb46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb8d95b95b55b01f2aa4dbd2a4fa819a7390135488b560f6ef091eab245dbc07e99eb5f64ef69caf8f3c83fddd70c53b4555d7633b4d8a51294b2ca85571418d
|
7
|
+
data.tar.gz: 93ae41bea06c2bdf9958b7bcfa6900fc92a38b882ecab7e19d6bc837bff1f744fa1b1fd90bc1c3ab0bb0cef202d13e668ebf72784fec2a3a0c039643d6ac67fc
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
retag (0.1
|
4
|
+
retag (0.2.1)
|
5
5
|
activesupport (~> 6.0)
|
6
6
|
colorize (~> 0.8.1)
|
7
7
|
gitlab (< 5.0)
|
8
8
|
json
|
9
|
+
logger
|
10
|
+
multi_xml (~> 0.6.0)
|
9
11
|
thor
|
10
12
|
uri
|
11
13
|
yaml
|
@@ -14,99 +16,111 @@ PATH
|
|
14
16
|
GEM
|
15
17
|
remote: https://rubygems.org/
|
16
18
|
specs:
|
17
|
-
activesupport (6.1.7.
|
19
|
+
activesupport (6.1.7.10)
|
18
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
19
21
|
i18n (>= 1.6, < 2)
|
20
22
|
minitest (>= 5.1)
|
21
23
|
tzinfo (~> 2.0)
|
22
24
|
zeitwerk (~> 2.3)
|
23
|
-
addressable (2.8.
|
24
|
-
public_suffix (>= 2.0.2, <
|
25
|
+
addressable (2.8.7)
|
26
|
+
public_suffix (>= 2.0.2, < 7.0)
|
25
27
|
ansi (1.5.0)
|
26
28
|
ast (2.4.2)
|
29
|
+
bigdecimal (3.1.9)
|
27
30
|
colorize (0.8.1)
|
28
|
-
concurrent-ruby (1.3.
|
29
|
-
crack (0.
|
31
|
+
concurrent-ruby (1.3.5)
|
32
|
+
crack (1.0.0)
|
33
|
+
bigdecimal
|
30
34
|
rexml
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
csv (3.3.2)
|
36
|
+
diff-lcs (1.5.1)
|
37
|
+
docile (1.4.1)
|
38
|
+
gitlab (4.20.1)
|
39
|
+
httparty (~> 0.20)
|
35
40
|
terminal-table (>= 1.5.1)
|
36
|
-
hashdiff (1.
|
37
|
-
httparty (0.
|
41
|
+
hashdiff (1.1.2)
|
42
|
+
httparty (0.22.0)
|
43
|
+
csv
|
38
44
|
mini_mime (>= 1.0.0)
|
39
45
|
multi_xml (>= 0.5.2)
|
40
|
-
i18n (1.14.
|
46
|
+
i18n (1.14.7)
|
41
47
|
concurrent-ruby (~> 1.0)
|
42
|
-
json (2.
|
43
|
-
|
44
|
-
|
48
|
+
json (2.9.1)
|
49
|
+
language_server-protocol (3.17.0.4)
|
50
|
+
logger (1.6.6)
|
51
|
+
mini_mime (1.1.5)
|
52
|
+
minitest (5.25.4)
|
45
53
|
multi_xml (0.6.0)
|
46
|
-
parallel (1.
|
47
|
-
parser (3.
|
54
|
+
parallel (1.26.3)
|
55
|
+
parser (3.3.7.0)
|
48
56
|
ast (~> 2.4.1)
|
49
|
-
|
57
|
+
racc
|
58
|
+
public_suffix (5.1.1)
|
59
|
+
racc (1.8.1)
|
50
60
|
rainbow (3.1.1)
|
51
|
-
rake (13.
|
52
|
-
regexp_parser (2.
|
53
|
-
rexml (3.
|
54
|
-
rspec (3.
|
55
|
-
rspec-core (~> 3.
|
56
|
-
rspec-expectations (~> 3.
|
57
|
-
rspec-mocks (~> 3.
|
58
|
-
rspec-core (3.
|
59
|
-
rspec-support (~> 3.
|
60
|
-
rspec-expectations (3.
|
61
|
+
rake (13.2.1)
|
62
|
+
regexp_parser (2.10.0)
|
63
|
+
rexml (3.4.0)
|
64
|
+
rspec (3.13.0)
|
65
|
+
rspec-core (~> 3.13.0)
|
66
|
+
rspec-expectations (~> 3.13.0)
|
67
|
+
rspec-mocks (~> 3.13.0)
|
68
|
+
rspec-core (3.13.2)
|
69
|
+
rspec-support (~> 3.13.0)
|
70
|
+
rspec-expectations (3.13.3)
|
61
71
|
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
-
rspec-support (~> 3.
|
63
|
-
rspec-mocks (3.
|
72
|
+
rspec-support (~> 3.13.0)
|
73
|
+
rspec-mocks (3.13.2)
|
64
74
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
|
-
rspec-support (~> 3.
|
66
|
-
rspec-support (3.
|
67
|
-
rspec_junit_formatter (0.
|
75
|
+
rspec-support (~> 3.13.0)
|
76
|
+
rspec-support (3.13.2)
|
77
|
+
rspec_junit_formatter (0.6.0)
|
68
78
|
rspec-core (>= 2, < 4, != 2.12.0)
|
69
|
-
rubocop (1.
|
79
|
+
rubocop (1.71.0)
|
80
|
+
json (~> 2.3)
|
81
|
+
language_server-protocol (>= 3.17.0)
|
70
82
|
parallel (~> 1.10)
|
71
|
-
parser (>= 3.
|
83
|
+
parser (>= 3.3.0.2)
|
72
84
|
rainbow (>= 2.2.2, < 4.0)
|
73
|
-
regexp_parser (>=
|
74
|
-
|
75
|
-
rubocop-ast (>= 1.15.1, < 2.0)
|
85
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
86
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
76
87
|
ruby-progressbar (~> 1.7)
|
77
|
-
unicode-display_width (>=
|
78
|
-
rubocop-ast (1.
|
79
|
-
parser (>= 3.
|
80
|
-
ruby-progressbar (1.
|
81
|
-
simplecov (0.
|
88
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
89
|
+
rubocop-ast (1.38.0)
|
90
|
+
parser (>= 3.3.1.0)
|
91
|
+
ruby-progressbar (1.13.0)
|
92
|
+
simplecov (0.22.0)
|
82
93
|
docile (~> 1.1)
|
83
94
|
simplecov-html (~> 0.11)
|
84
95
|
simplecov_json_formatter (~> 0.1)
|
85
|
-
simplecov-console (0.9.
|
96
|
+
simplecov-console (0.9.2)
|
86
97
|
ansi
|
87
98
|
simplecov
|
88
99
|
terminal-table
|
89
|
-
simplecov-html (0.
|
90
|
-
simplecov_json_formatter (0.1.
|
91
|
-
terminal-table (
|
92
|
-
unicode-display_width (>= 1.1.1, <
|
93
|
-
thor (1.
|
100
|
+
simplecov-html (0.13.1)
|
101
|
+
simplecov_json_formatter (0.1.4)
|
102
|
+
terminal-table (4.0.0)
|
103
|
+
unicode-display_width (>= 1.1.1, < 4)
|
104
|
+
thor (1.3.2)
|
94
105
|
tzinfo (2.0.6)
|
95
106
|
concurrent-ruby (~> 1.0)
|
96
|
-
unicode-display_width (
|
97
|
-
|
98
|
-
|
107
|
+
unicode-display_width (3.1.4)
|
108
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
109
|
+
unicode-emoji (4.0.4)
|
110
|
+
uri (1.0.2)
|
111
|
+
webmock (3.24.0)
|
99
112
|
addressable (>= 2.8.0)
|
100
113
|
crack (>= 0.3.2)
|
101
114
|
hashdiff (>= 0.4.0, < 2.0.0)
|
102
|
-
yaml (0.
|
115
|
+
yaml (0.4.0)
|
103
116
|
zeitwerk (2.5.4)
|
104
117
|
|
105
118
|
PLATFORMS
|
119
|
+
ruby
|
106
120
|
x86_64-linux
|
107
121
|
|
108
122
|
DEPENDENCIES
|
109
|
-
bundler (
|
123
|
+
bundler (>= 2.1.0)
|
110
124
|
rake
|
111
125
|
retag!
|
112
126
|
rspec
|
data/bin/retag
CHANGED
@@ -80,6 +80,14 @@ class DockerCommand < Thor
|
|
80
80
|
required: true,
|
81
81
|
desc: "Env: #{ENV_PREFIX}_TAG_TAG. New tag"
|
82
82
|
|
83
|
+
option :project, default: ENV.fetch("#{ENV_PREFIX}_TAG_PROJECT", nil),
|
84
|
+
required: false,
|
85
|
+
desc: "Env: #{ENV_PREFIX}_TAG_PROJECT. Change repository project"
|
86
|
+
|
87
|
+
option :api, default: ENV.fetch("#{ENV_PREFIX}_TAG_API", 'harbor'),
|
88
|
+
required: false,
|
89
|
+
desc: "Env: #{ENV_PREFIX}_TAG_API. Which API user for: [harbor]"
|
90
|
+
|
83
91
|
option :suffix, default: ENV.fetch("#{ENV_PREFIX}_TAG_SUFFIX", nil),
|
84
92
|
required: false,
|
85
93
|
desc: "Env: #{ENV_PREFIX}_TAG_SUFFIX. Optional suffix added to image tag: <image>:<tag>[-<suffix>].
|
@@ -96,11 +104,11 @@ class DockerCommand < Thor
|
|
96
104
|
tag ||= 'latest'
|
97
105
|
tag = opts['suffix'].present? ? "#{tag}-#{opts['suffix']}" : tag
|
98
106
|
|
99
|
-
image = ::Retag::Image.new(img, tag)
|
107
|
+
image = ::Retag::Image.new(img, tag, api: opts['api'])
|
100
108
|
|
101
109
|
$logger.info ">>> Image #{image.image}"
|
102
110
|
$logger.info " From ".ljust(5) + "[#{image.tag.colorize(:yellow)}]: ".ljust(35) + image.full
|
103
|
-
newimg = image.retag!(opts['tag'])
|
111
|
+
newimg = image.retag!(opts['tag'], newproject: opts['project'])
|
104
112
|
$logger.info " To ".ljust(5) + "[#{newimg.tag.colorize(:yellow)}]: ".ljust(35) + newimg.full
|
105
113
|
end
|
106
114
|
|
@@ -116,6 +124,14 @@ class ReleaseCommand < Thor
|
|
116
124
|
required: true,
|
117
125
|
desc: "Env: #{ENV_PREFIX}_RELEASE_CONFIG. Path to release manifest"
|
118
126
|
|
127
|
+
option :project, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_PROJECT", nil),
|
128
|
+
required: false,
|
129
|
+
desc: "Env: #{ENV_PREFIX}_TAG_PROJECT. Change Docker repository project"
|
130
|
+
|
131
|
+
option :api, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_API", 'harbor'),
|
132
|
+
required: false,
|
133
|
+
desc: "Env: #{ENV_PREFIX}_TAG_API. Which API user for: [harbor]"
|
134
|
+
|
119
135
|
option :name, default: ENV.fetch("#{ENV_PREFIX}_RELEASE_NAME", nil),
|
120
136
|
required: false,
|
121
137
|
desc: "Env: #{ENV_PREFIX}_RELEASE_NAME. Name of the current release"
|
@@ -137,7 +153,7 @@ class ReleaseCommand < Thor
|
|
137
153
|
branch = config['default-branch']
|
138
154
|
|
139
155
|
services = config['services'].map do|(name, cfg)|
|
140
|
-
Retag::Service.new(name, cfg, release, suffix: cfg.fetch('suffix', suffix), branch: cfg.fetch('branch', branch)) unless name.start_with?('.')
|
156
|
+
Retag::Service.new(name, cfg, release, suffix: cfg.fetch('suffix', suffix), branch: cfg.fetch('branch', branch), api: opts['api']) unless name.start_with?('.')
|
141
157
|
end.compact
|
142
158
|
|
143
159
|
tag_message = "Release #{release} at #{DateTime.now.iso8601}"
|
@@ -155,7 +171,7 @@ class ReleaseCommand < Thor
|
|
155
171
|
|
156
172
|
$logger.shift do
|
157
173
|
$logger.info "From ".ljust(5) + "[#{img.tag.colorize(:yellow)}]: ".ljust(35) + img.full
|
158
|
-
newimg = img.retag!(release)
|
174
|
+
newimg = img.retag!(release, newproject: opts['project'])
|
159
175
|
$logger.info "To ".ljust(5) + "[#{newimg.tag.colorize(:yellow)}]: ".ljust(35) + newimg.full
|
160
176
|
|
161
177
|
markdown += "* **Name**: `#{srv.name}`<br>**Version**: #{img.tag}<br>**Image**: #{newimg.full}\n"
|
data/lib/retag/image.rb
CHANGED
@@ -5,20 +5,24 @@ module Retag
|
|
5
5
|
class Image
|
6
6
|
|
7
7
|
include Utils
|
8
|
-
attr_reader :full, :image, :tag
|
8
|
+
attr_reader :full, :image, :tag, :api
|
9
9
|
|
10
|
-
def initialize(image, tag, suffix: nil)
|
10
|
+
def initialize(image, tag, suffix: nil, api: nil)
|
11
11
|
@image = image
|
12
12
|
@tag = tag
|
13
13
|
@tag = "#{@tag}-#{suffix}" if suffix.present?
|
14
14
|
@full = "#{@image}:#{@tag}"
|
15
|
+
@api = api
|
15
16
|
end
|
16
17
|
|
17
|
-
def retag!(newtag = tag)
|
18
|
+
def retag!(newtag = tag, newproject: nil)
|
18
19
|
uri = ::URI.parse("https://#{image}")
|
19
20
|
repo = uri.path
|
20
21
|
repo[0..0] = ''
|
22
|
+
project, registry = repo.split('/')
|
21
23
|
uri.path = ''
|
24
|
+
newrepo = repo
|
25
|
+
newrepo = repo.sub("#{project}/", "#{newproject}/") if newproject
|
22
26
|
|
23
27
|
content_type = 'application/vnd.docker.distribution.manifest.v2+json'
|
24
28
|
|
@@ -28,11 +32,23 @@ module Retag
|
|
28
32
|
|
29
33
|
file.write(manifest.to_json)
|
30
34
|
file.flush
|
35
|
+
|
31
36
|
result = cmd!("curl -s -u '#{dockerauth(uri.host)}' -H 'Content-Type: #{content_type}' -H 'Accept: #{content_type}' -X PUT --data-binary @#{file.path} '#{uri}/v2/#{repo}/manifests/#{newtag}' -o -", capture: true).strip
|
37
|
+
|
38
|
+
if newrepo != repo
|
39
|
+
if api == 'harbor'
|
40
|
+
result = cmd!("curl -s -u '#{dockerauth(uri.host)}' -X POST '#{uri}/api/v2.0/projects/#{newproject}/repositories/#{registry}/artifacts?from=#{repo}:#{newtag}' -o -", capture: true).strip
|
41
|
+
else
|
42
|
+
raise "Unable to promote image #{repo} -> #{newrepo} with #{api.inspect} api: Unimplemented"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
32
46
|
raise result unless result.empty?
|
33
47
|
end
|
34
48
|
|
35
|
-
|
49
|
+
newuri = uri.dup
|
50
|
+
newuri.path = "/#{newrepo}"
|
51
|
+
Image.new(newuri.hostname + newuri.path, newtag)
|
36
52
|
end
|
37
53
|
|
38
54
|
end
|
data/lib/retag/service.rb
CHANGED
@@ -5,20 +5,21 @@ module Retag
|
|
5
5
|
|
6
6
|
include Retag::Utils
|
7
7
|
|
8
|
-
attr_reader :name, :config, :repo, :release, :suffix
|
8
|
+
attr_reader :name, :config, :repo, :release, :suffix, :api
|
9
9
|
|
10
10
|
delegate :revision, :branch, to: :repo
|
11
11
|
|
12
|
-
def initialize(name, config, release, branch:, suffix:)
|
12
|
+
def initialize(name, config, release, branch:, suffix:, api:)
|
13
13
|
@name = name
|
14
14
|
@config = config
|
15
15
|
@repo = Retag::Repo.new(config['repo'], branch)
|
16
16
|
@release = release
|
17
17
|
@suffix = suffix
|
18
|
+
@api = api
|
18
19
|
end
|
19
20
|
|
20
21
|
def images
|
21
|
-
@images ||= config['images'].map{|img| Retag::Image.new(img, revision, suffix: @suffix) }
|
22
|
+
@images ||= config['images'].map{|img| Retag::Image.new(img, revision, suffix: @suffix, api: api) }
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
data/lib/retag/version.rb
CHANGED
data/lib/retag.rb
CHANGED
data/retag.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new 'retag' do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^bin/retag}) {|f| File.basename(f) }
|
22
22
|
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler', '
|
24
|
+
spec.add_development_dependency 'bundler', '>= 2.1.0'
|
25
25
|
spec.add_development_dependency 'rake'
|
26
26
|
spec.add_development_dependency 'rspec'
|
27
27
|
spec.add_development_dependency 'rspec_junit_formatter'
|
@@ -37,6 +37,8 @@ Gem::Specification.new 'retag' do |spec|
|
|
37
37
|
spec.add_runtime_dependency 'thor'
|
38
38
|
spec.add_runtime_dependency 'uri'
|
39
39
|
spec.add_runtime_dependency 'yaml'
|
40
|
+
spec.add_runtime_dependency 'logger'
|
40
41
|
spec.add_runtime_dependency 'zeitwerk', '~> 2.5.3'
|
42
|
+
spec.add_runtime_dependency 'multi_xml', '~> 0.6.0'
|
41
43
|
end
|
42
44
|
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.2.1.289789
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samoilenko Yuri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.2'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.
|
19
|
+
version: 2.1.0
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.2'
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: 2.
|
26
|
+
version: 2.1.0
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rake
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,6 +220,20 @@ dependencies:
|
|
226
220
|
- - ">="
|
227
221
|
- !ruby/object:Gem::Version
|
228
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: logger
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
229
237
|
- !ruby/object:Gem::Dependency
|
230
238
|
name: zeitwerk
|
231
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -240,6 +248,20 @@ dependencies:
|
|
240
248
|
- - "~>"
|
241
249
|
- !ruby/object:Gem::Version
|
242
250
|
version: 2.5.3
|
251
|
+
- !ruby/object:Gem::Dependency
|
252
|
+
name: multi_xml
|
253
|
+
requirement: !ruby/object:Gem::Requirement
|
254
|
+
requirements:
|
255
|
+
- - "~>"
|
256
|
+
- !ruby/object:Gem::Version
|
257
|
+
version: 0.6.0
|
258
|
+
type: :runtime
|
259
|
+
prerelease: false
|
260
|
+
version_requirements: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - "~>"
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: 0.6.0
|
243
265
|
description: Retag is cli to manipulate docker images in handy way
|
244
266
|
email:
|
245
267
|
- kinnalru@gmail.com
|