build-labels 0.0.12 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 720b52bf85f4f82c4c89fed5561ba93ef58c52fec91674848c751fe4af523ab2
4
- data.tar.gz: 04a2c81b8b8662ea174d878a0f093e24e6abbeaf864348331eb14a7c87c2007c
3
+ metadata.gz: 45ec711f57e62a9f9ace663420b2d5052904e1a0a997de2e68bbc7e72612f7b4
4
+ data.tar.gz: e41d1bb627f104f364ffef3392fe4e3d98b5cb4b7c9a76ba5eb375544dceb7b7
5
5
  SHA512:
6
- metadata.gz: 3e874e6162cc78d71a0c87df0d58635db9801903048ac7d77c93fca300fd1349805df377b8c4b4488ef05d0290a1c5a124401ee35aed8e25a626fe81722f5af0
7
- data.tar.gz: 42f355c657e752ab004ceee45158043a059237e9388645c48b857664e7e184f1e5959d48ca8f8802ae10b0cdae432f89629cd6cd2c268f8f3a214b353f5f70a9
6
+ metadata.gz: 12d0b0b8fc261672065828c51078dff7eb55e217745888291f6ca76d437875971aaef086f5bacd126e7d28302ccb4b5562e131c6ce3370d3c7bf8be4a4299de2
7
+ data.tar.gz: e1b759306b453d366aa6b92e027210faee49075e59eede975b46b029ce99e0d9d3504608451faeaf22a70f1b26137014250eaf1336e2d2e03df471b07c0d83e0
@@ -1,18 +1,32 @@
1
1
  require_relative 'command_line'
2
2
 
3
3
  BuildLabels::CommandLine::COMMANDS[:cache] = Class.new do
4
+ def options(parser)
5
+ parser.on('', '--cache-from CACHE FROM', 'type=[local,registry] ... ')
6
+ parser.on('', '--cache-to CACHE TO', 'type=[local,registry] ...')
7
+ end
4
8
  def run(builder, params, compose_text)
5
9
  compose = YAML.load compose_text
6
- compose['services'].each do |name, service|
10
+ compose['services'].each do |service_name, service|
7
11
  next unless service['build']
8
12
 
9
13
  if service['build'].class == String
10
14
  service['build'] = { 'context' => service['build'] }
11
15
  end
16
+ # p params
12
17
  # registry = params[:registry]
13
- image = service['image']
14
- service['build']['cache_from'] = [ "type=registry,ref=#{image}:cache" ]
15
- service['build']['cache_to'] = [ "type=registry,ref=#{image}:cache,mode=max" ]
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
24
+
25
+ if params[:'cache-to']
26
+ service['build']['cache_to'] = [ params[:'cache-to'] % {image: image, service_name: service_name} ]
27
+ else
28
+ service['build']['cache_to'] = [ "type=registry,ref=#{image}:cache,mode=max" ]
29
+ end
16
30
  # # - type=local,src=./.cache
17
31
  # # - type=local,dest=./.cache,mode=max
18
32
  end
@@ -46,6 +46,8 @@ module BuildLabels
46
46
  o.on('-c', '--compose COMPOSE_FILE', 'Compose file')
47
47
  o.on('-e', '--env FILE', 'Load .build_info FILE') { load_env _1 }
48
48
  o.on('-n', '--no-env', 'Do not process env variables') { true }
49
+ COMMANDS.values.select{_1.options(o) if _1.respond_to? :options }
50
+
49
51
  o.on('-h', '--help') { puts o; exit }
50
52
  rest = o.parse! args, into: params
51
53
 
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module BuildLabels
2
2
  class Builder
3
- VERSION = '0.0.12'
3
+ VERSION = '0.0.14'
4
4
  end
5
5
  end
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.12
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-22 00:00:00.000000000 Z
11
+ date: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake