avm-tools 0.23.0 → 0.24.0

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: 9cc8ec766645c9ba79f3bbee342a271a47dfbc9921b433b0de06c2dbdac82470
4
- data.tar.gz: f2efe1291c604c06320b386de40ab0035641017c040ebc0fa3ff5a56a1b57b3b
3
+ metadata.gz: 4deaa72e5e51d1dc4db756e57ea2bd1c8c6578f531d1ef2084a330719d74fb15
4
+ data.tar.gz: 6dd2b7bf04bdaa95b24d020fa7f4947ed3197588e497fe40ce51c0a5f90a688c
5
5
  SHA512:
6
- metadata.gz: 31f9530c35e93e73fa80ea12e25c1301dadeda7028624cea0ca58253b201f7c3f7b4f3c015f6e9bc6f4fd7db183010be9adb6c89fe8d858f3e38e97d600e90d7
7
- data.tar.gz: 3aaa766a741baf3d4e3dd5d33219bc1342fe9c0683802e33ca79472327d7b7909c0e45c4d1fde482fbae3a3f817d9a5315958dac26a02ee9e534b02b23fb10e0
6
+ metadata.gz: 85cbe7adec68930b3d499a5d9765a8d86072a32f2f41730455c7236d5ba940dcee7fe259718840146143972c90cd0b50799c059f3745801051322ad5e733b978
7
+ data.tar.gz: 8dc0bb879ed769cc3760c4cbaf02dc2b62a7d765e97eb7bf7fcfc5cfaa15e761b1b95e57504e7ec79c7519dadd19077301a2ca679deddac41789feed60640fa0
@@ -7,6 +7,16 @@ require 'avm/patches/object/template'
7
7
  module Avm
8
8
  module Docker
9
9
  class Image
10
+ attr_reader :registry
11
+ attr_accessor :snapshot
12
+ attr_accessor :version
13
+
14
+ def initialize(registry)
15
+ @registry = registry
16
+ self.snapshot = true
17
+ self.version = true
18
+ end
19
+
10
20
  def build(extra_args = [])
11
21
  on_build_dir do
12
22
  template.apply(self, build_dir)
@@ -14,6 +24,10 @@ module Avm
14
24
  end
15
25
  end
16
26
 
27
+ def generator_version
28
+ ::Avm::Tools::VERSION
29
+ end
30
+
17
31
  def push
18
32
  ::Avm::Executables.docker.command.append(['push', tag]).system!
19
33
  end
@@ -29,6 +43,30 @@ module Avm
29
43
  run_run(instance) if container_exist?(instance)
30
44
  end
31
45
 
46
+ def tag
47
+ r = tag_name
48
+ r += ":#{tag_version}" if tag_version.present?
49
+ r
50
+ end
51
+
52
+ def tag_name
53
+ return registry.name if registry.name.present?
54
+
55
+ raise 'Registry name is blank'
56
+ end
57
+
58
+ def tag_version
59
+ [tag_version_version, stereotype_tag].reject(&:blank?).join('_')
60
+ end
61
+
62
+ def tag_version_version
63
+ return nil unless version
64
+
65
+ r = generator_version
66
+ r += '-snapshot' if snapshot
67
+ r
68
+ end
69
+
32
70
  private
33
71
 
34
72
  attr_reader :build_dir
@@ -25,6 +25,8 @@ module Avm
25
25
  -B --build-arg=<build-arg> Argument for "docker build".
26
26
  -E --entrypoint-arg=<run-arg> Argument for entrypoint on "docker run"
27
27
  -c --clear Remove container if exist before run.
28
+ -S --no-snapshot Does not add "-snapshot" to image tag.
29
+ -V --no-version Does not add version to image tag.
28
30
  DOCOPT
29
31
 
30
32
  def run
@@ -38,11 +40,17 @@ module Avm
38
40
  private
39
41
 
40
42
  def setup
41
- instance.docker_registry = registry
43
+ instance.docker_image_options = {
44
+ registry: registry,
45
+ snapshot: snapshot?,
46
+ version: version?
47
+ }
42
48
  end
43
49
 
44
50
  def banner
45
51
  infov 'Registry name', registry
52
+ infov 'Version?', version?
53
+ infov 'Snapshot?', snapshot?
46
54
  infov 'Image name', instance.docker_image.tag
47
55
  infov 'Build arguments', build_args
48
56
  infov 'Entrypoint arguments', entrypoint_args
@@ -79,6 +87,14 @@ module Avm
79
87
  end
80
88
  end
81
89
 
90
+ def snapshot?
91
+ !options.fetch('--no-snapshot')
92
+ end
93
+
94
+ def version?
95
+ !options.fetch('--no-version')
96
+ end
97
+
82
98
  def instance
83
99
  context(:instance)
84
100
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_utils/core_ext'
3
4
  require 'avm/docker/container'
4
5
 
5
6
  module Avm
@@ -7,10 +8,10 @@ module Avm
7
8
  class Base
8
9
  module Dockerizable
9
10
  enable_simple_cache
10
- attr_reader :docker_registry
11
+ attr_reader :docker_image_options
11
12
 
12
- def docker_registry=(new_value)
13
- @docker_registry = new_value
13
+ def docker_image_options=(options)
14
+ @docker_image_options = ::ActiveSupport::HashWithIndifferentAccess.new(options)
14
15
  reset_cache
15
16
  end
16
17
 
@@ -31,7 +32,10 @@ module Avm
31
32
  end
32
33
 
33
34
  def docker_image_uncached
34
- docker_image_class.new(docker_registry)
35
+ r = docker_image_class.new(docker_image_options.fetch(:registry))
36
+ r.version = docker_image_options[:version] if docker_image_options.key?(:version)
37
+ r.snapshot = docker_image_options[:snapshot] if docker_image_options.key?(:snapshot)
38
+ r
35
39
  end
36
40
  end
37
41
  end
@@ -6,10 +6,8 @@ require 'avm/docker/image'
6
6
  module Avm
7
7
  module Self
8
8
  class DockerImage < ::Avm::Docker::Image
9
- common_constructor :registry
10
-
11
- def tag
12
- registry.name
9
+ def stereotype_tag
10
+ nil
13
11
  end
14
12
  end
15
13
  end
@@ -7,11 +7,8 @@ module Avm
7
7
  module Stereotypes
8
8
  module EacUbuntuBase0
9
9
  class DockerImage < ::Avm::Docker::Image
10
- enable_simple_cache
11
- common_constructor :registry
12
-
13
- def tag
14
- "#{registry.name}:eac_ubuntu_base0"
10
+ def stereotype_tag
11
+ 'eac_ubuntu_base0'
15
12
  end
16
13
  end
17
14
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.23.0'
5
+ VERSION = '0.24.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-11-20 00:00:00.000000000 Z
11
+ date: 2019-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers