build-labels 0.0.20 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/build-labels/builder.rb +2 -8
- data/lib/build-labels/command_cache.rb +10 -21
- data/lib/build-labels/command_line.rb +2 -0
- data/lib/build-labels/command_set_version.rb +8 -7
- data/lib/build-labels/command_to_compose.rb +3 -3
- data/lib/build-labels/command_to_dockerfiles.rb +2 -5
- data/lib/version.rb +1 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50511bc850b411617f1d5c516593dbfe886de1d4230e76b3036c70ac9e7fa91e
|
4
|
+
data.tar.gz: 6f1d316b6941a45bd0451e17b322854172d9e1a5eb55eca39bb7039e2bcf1120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3e4df0698922db01f4526405a9ce7c694a6fea149e86d4fbd90142ca6e1781cf8d2a22cb534049da6853b8fb3662cb65695c470fe099000fa4d06f15d3f30b2
|
7
|
+
data.tar.gz: 4afcd88dcf92dcf78f9c938a0902e486db8f10981f42b4a659877c4b5b2ae52f2c76ef5e3167713b48e424727424eb667ff16a640c586311f826df8438205d89
|
data/lib/build-labels/builder.rb
CHANGED
@@ -54,14 +54,7 @@ module BuildLabels
|
|
54
54
|
yield ns, values
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
58
|
-
def extend_compose(compose_text)
|
59
|
-
|
60
|
-
result = YamlMerge::parse_and_process_yaml compose_text
|
61
|
-
compose = YamlMerge::deep_copy_without_aliases result
|
62
|
-
|
63
|
-
# compose = YAML.load compose_text
|
64
|
-
|
57
|
+
def extend_compose(compose)
|
65
58
|
compose['services'].each do |name, service|
|
66
59
|
service.delete_if {|k, v| !%w[image build].include? k }
|
67
60
|
next unless service['build']
|
@@ -79,6 +72,7 @@ module BuildLabels
|
|
79
72
|
end
|
80
73
|
end
|
81
74
|
compose['services'].delete_if do |name, svc| ! svc.key?('build') end
|
75
|
+
|
82
76
|
puts compose.to_yaml
|
83
77
|
end
|
84
78
|
end
|
@@ -5,32 +5,21 @@ BuildLabels::CommandLine::COMMANDS[:cache] = Class.new do
|
|
5
5
|
parser.on('', '--cache-from CACHE FROM', 'type=[local,registry] ... ')
|
6
6
|
parser.on('', '--cache-to CACHE TO', 'type=[local,registry] ...')
|
7
7
|
end
|
8
|
-
def run(builder, params,
|
9
|
-
compose = YAML.load compose_text
|
8
|
+
def run(builder, params, compose)
|
10
9
|
compose['services'].each do |service_name, service|
|
11
10
|
next unless service['build']
|
12
11
|
|
13
|
-
if service['build'].
|
14
|
-
service['build'] = { 'context' => service['build'] }
|
15
|
-
end
|
16
|
-
# p params
|
17
|
-
# registry = params[:registry]
|
18
|
-
image = service['image'].gsub( /:.*/, '')
|
19
|
-
if params[:'cache-from']
|
20
|
-
service['build']['cache_from'] = [ params[:'cache-from'] % {image: image, service_name: service_name} ]
|
21
|
-
else
|
22
|
-
service['build']['cache_from'] = [ "type=registry,ref=#{image}:cache" ]
|
23
|
-
end
|
12
|
+
service['build'] = { 'context' => service['build'] } if service['build'].is_a?(String)
|
24
13
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
# # - type=local,dest=./.cache,mode=max
|
14
|
+
image = service['image'].split(':').first
|
15
|
+
cache_from = params[:'cache-from'] || "type=registry,ref=#{image}:cache"
|
16
|
+
cache_to = params[:'cache-to'] || "type=registry,ref=#{image}:cache,mode=max"
|
17
|
+
|
18
|
+
service['build']['cache_from'] = [format(cache_from, image: image, service_name: service_name)]
|
19
|
+
service['build']['cache_to'] = [format(cache_to, image: image, service_name: service_name)]
|
32
20
|
end
|
33
|
-
|
21
|
+
# - type=local,src=./.cache
|
22
|
+
# - type=local,dest=./.cache,mode=max
|
34
23
|
end
|
35
24
|
|
36
25
|
def help = 'Add cache section'
|
@@ -55,6 +55,8 @@ module BuildLabels
|
|
55
55
|
compose_text = File.read(params[:compose]) if params[:compose]
|
56
56
|
compose_text ||= STDIN.read unless $stdin.tty?
|
57
57
|
|
58
|
+
result = YamlMerge.parse_and_process_yaml compose_text
|
59
|
+
compose_text = YamlMerge.deep_copy_without_aliases result
|
58
60
|
builder = Builder.new
|
59
61
|
|
60
62
|
# eval $(grep -v -e '^#' .build_info | xargs -I {} echo export \'{}\') && echo $CI_COMMIT_AUTHOR
|
@@ -5,12 +5,8 @@ BuildLabels::CommandLine::COMMANDS[:set_version] = Class.new do
|
|
5
5
|
# parser.on('', '--set-version', '')
|
6
6
|
# end
|
7
7
|
|
8
|
-
def run(builder, params,
|
9
|
-
raise 'Compose file not defined' unless
|
10
|
-
|
11
|
-
result = YamlMerge::parse_and_process_yaml compose_text
|
12
|
-
compose = YamlMerge::deep_copy_without_aliases result
|
13
|
-
# compose = YAML.load compose_text
|
8
|
+
def run(builder, params, compose)
|
9
|
+
raise 'Compose file not defined' unless compose
|
14
10
|
|
15
11
|
compose_dir = params[:compose] ? File.dirname(params[:compose]) : '.'
|
16
12
|
|
@@ -24,9 +20,14 @@ BuildLabels::CommandLine::COMMANDS[:set_version] = Class.new do
|
|
24
20
|
image = svc['image'].gsub( /:.*/, '')
|
25
21
|
tag = svc['image'][/:(.*)/, 1]
|
26
22
|
svc['image'] = "#{image}:#{current_version}#{tag ? "-" + tag : ""}"
|
23
|
+
next unless svc['build']['tags']
|
24
|
+
svc['build']['tags'] = svc['build']['tags'].map do |t|
|
25
|
+
image = t.gsub( /:.*/, '')
|
26
|
+
tag = t[/:(.*)/, 1]
|
27
|
+
"#{image}:#{current_version}#{tag ? "-" + tag : ""}"
|
28
|
+
end
|
27
29
|
end
|
28
30
|
|
29
|
-
compose_text.replace compose.to_yaml
|
30
31
|
end
|
31
32
|
|
32
33
|
def help = 'Add version tag from [docker_context]/.version file to image'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require_relative 'command_line'
|
2
2
|
|
3
3
|
BuildLabels::CommandLine::COMMANDS[:to_compose] = Class.new do
|
4
|
-
def run(builder, params,
|
5
|
-
raise 'Compose file not defined' unless
|
4
|
+
def run(builder, params, compose)
|
5
|
+
raise 'Compose file not defined' unless compose
|
6
6
|
|
7
|
-
builder.extend_compose
|
7
|
+
builder.extend_compose compose
|
8
8
|
end
|
9
9
|
|
10
10
|
def help = 'Add labels to all build sections of docker-compose file'
|
@@ -1,13 +1,10 @@
|
|
1
1
|
require_relative 'command_line'
|
2
2
|
|
3
3
|
BuildLabels::CommandLine::COMMANDS[:to_dockerfiles] = Class.new do
|
4
|
-
def run(builder, params,
|
5
|
-
raise 'Compose file not defined' unless
|
4
|
+
def run(builder, params, compose)
|
5
|
+
raise 'Compose file not defined' unless compose
|
6
6
|
compose_dir = params[:compose] ? File.dirname(params[:compose]) : '.'
|
7
7
|
|
8
|
-
result = YamlMerge::parse_and_process_yaml compose_text
|
9
|
-
compose = YamlMerge::deep_copy_without_aliases result
|
10
|
-
# compose = YAML.load compose_text
|
11
8
|
|
12
9
|
compose['services'].each do |name, svc|
|
13
10
|
next unless svc['build']
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: build-labels
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom B
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -121,7 +121,7 @@ licenses:
|
|
121
121
|
- Nonstandard
|
122
122
|
metadata:
|
123
123
|
source_code_uri: https://github.com/artyomb/build-labels
|
124
|
-
post_install_message:
|
124
|
+
post_install_message:
|
125
125
|
rdoc_options: []
|
126
126
|
require_paths:
|
127
127
|
- lib
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
139
|
rubygems_version: 3.3.7
|
140
|
-
signing_key:
|
140
|
+
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Generate docker build image labels from CI variables
|
143
143
|
test_files: []
|