dapp 0.32.10 → 0.33.0

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dapp +1 -23
  3. data/config/en/net_status.yml +7 -0
  4. data/lib/dapp.rb +3 -3
  5. data/lib/dapp/dapp.rb +13 -0
  6. data/lib/dapp/dapp/dappfile.rb +2 -2
  7. data/lib/dapp/dapp/deps/base.rb +5 -37
  8. data/lib/dapp/dapp/deps/common.rb +25 -0
  9. data/lib/dapp/dapp/deps/gitartifact.rb +2 -25
  10. data/lib/dapp/dapp/deps/toolchain.rb +1 -23
  11. data/lib/dapp/dapp/logging/base.rb +3 -3
  12. data/lib/dapp/dapp/ruby2go.rb +96 -0
  13. data/lib/dapp/dapp/sentry.rb +0 -1
  14. data/lib/dapp/dapp/shellout/base.rb +4 -2
  15. data/lib/dapp/dimg/build/stage/artifact_base.rb +7 -6
  16. data/lib/dapp/dimg/build/stage/base.rb +37 -7
  17. data/lib/dapp/dimg/build/stage/from.rb +1 -1
  18. data/lib/dapp/dimg/builder/ansible.rb +1 -209
  19. data/lib/dapp/dimg/builder/base.rb +0 -5
  20. data/lib/dapp/dimg/builder/none.rb +1 -34
  21. data/lib/dapp/dimg/builder/ruby2go.rb +51 -0
  22. data/lib/dapp/dimg/builder/shell.rb +1 -25
  23. data/lib/dapp/dimg/cli/command/dimg/bp.rb +10 -15
  24. data/lib/dapp/dimg/cli/command/dimg/build.rb +0 -5
  25. data/lib/dapp/dimg/config/directive/docker/base.rb +1 -1
  26. data/lib/dapp/dimg/dapp/command/build_context/export.rb +1 -1
  27. data/lib/dapp/dimg/dapp/command/build_context/import.rb +1 -1
  28. data/lib/dapp/dimg/dapp/command/cleanup_repo.rb +59 -90
  29. data/lib/dapp/dimg/dapp/command/common.rb +60 -74
  30. data/lib/dapp/dimg/dapp/command/mrproper.rb +2 -17
  31. data/lib/dapp/dimg/dapp/command/stages/cleanup_local.rb +9 -6
  32. data/lib/dapp/dimg/dimg.rb +26 -43
  33. data/lib/dapp/dimg/docker_registry/base/authorization.rb +1 -16
  34. data/lib/dapp/dimg/git_artifact.rb +142 -21
  35. data/lib/dapp/dimg/git_repo/base.rb +11 -0
  36. data/lib/dapp/dimg/git_repo/local.rb +14 -0
  37. data/lib/dapp/dimg/git_repo/remote.rb +25 -34
  38. data/lib/dapp/dimg/image/argument.rb +12 -58
  39. data/lib/dapp/dimg/image/stage.rb +202 -43
  40. data/lib/dapp/kube/kubernetes/client.rb +0 -6
  41. data/lib/dapp/kube/kubernetes/manager/deployment.rb +18 -30
  42. data/lib/dapp/version.rb +1 -1
  43. metadata +8 -8
  44. data/lib/dapp/dimg/builder/ansible/assets.rb +0 -349
  45. data/lib/dapp/dimg/exception/introspect_image.rb +0 -7
  46. data/lib/dapp/dimg/image/docker.rb +0 -144
@@ -1,7 +0,0 @@
1
- module Dapp
2
- module Dimg
3
- module Exception
4
- class IntrospectImage < Base; end
5
- end
6
- end
7
- end
@@ -1,144 +0,0 @@
1
- module Dapp
2
- module Dimg
3
- module Image
4
- class Docker
5
- attr_reader :from
6
- attr_reader :name
7
- attr_reader :dapp
8
-
9
- class << self
10
- def image_by_name(name:, **kwargs)
11
- images[name] ||= new(name: name, **kwargs)
12
- end
13
-
14
- def image_reset(name)
15
- images.delete(name)
16
- end
17
-
18
- def images
19
- @images ||= {}
20
- end
21
- end
22
-
23
- def initialize(name:, dapp:, from: nil)
24
- @from = from
25
- @name = name
26
- @dapp = dapp
27
- end
28
-
29
- def id
30
- self.class.image_inspect(self.name)["Id"]
31
- end
32
-
33
- def untag!
34
- raise Error::Build, code: :image_already_untagged, data: { name: name } unless tagged?
35
- dapp.shellout!("#{dapp.host_docker} rmi #{name}")
36
- self.class.reset_image_inspect(self.name)
37
- end
38
-
39
- def push!
40
- raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
41
- dapp.log_secondary_process(dapp.t(code: 'process.image_push', data: { name: name })) do
42
- dapp.shellout!("#{dapp.host_docker} push #{name}", verbose: true)
43
- end
44
- end
45
-
46
- def pull!
47
- return if tagged?
48
- dapp.log_secondary_process(dapp.t(code: 'process.image_pull', data: { name: name })) do
49
- dapp.shellout!("#{dapp.host_docker} pull #{name}", verbose: true)
50
- end
51
-
52
- self.class.reset_image_inspect(self.name)
53
- end
54
-
55
- def tagged?
56
- not self.class.image_inspect(self.name).empty?
57
- end
58
-
59
- def created_at
60
- raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
61
- self.class.image_inspect(self.name)["Created"]
62
- end
63
-
64
- def size
65
- raise Error::Build, code: :image_not_exist, data: { name: name } unless tagged?
66
- Float(self.class.image_inspect(self.name)["Size"])
67
- end
68
-
69
- def config_option(option)
70
- raise Error::Build, code: :image_not_exist, data: { name: name } if built_id.nil?
71
- self.class.image_config_option(image_id: built_id, option: option)
72
- end
73
-
74
- class << self
75
- def image_inspect(image_id)
76
- image_inspects[image_id] ||= begin
77
- cmd = ::Dapp::Dapp.shellout("#{::Dapp::Dapp.host_docker} inspect --type=image #{image_id}")
78
-
79
- if cmd.exitstatus != 0
80
- if cmd.stderr.start_with? "Error: No such image:"
81
- {}
82
- else
83
- ::Dapp::Dapp.shellout_cmd_should_succeed! cmd
84
- end
85
- else
86
- Array(JSON.parse(cmd.stdout.strip)).first || {}
87
- end
88
- end
89
- end
90
-
91
- def image_config(image_id)
92
- image_inspect(image_id)["Config"] || {}
93
- end
94
-
95
- def image_config_option(image_id:, option:)
96
- image_config(image_id)[option]
97
- end
98
-
99
- def reset_image_inspect(image_id)
100
- image_inspects.delete(image_id)
101
- end
102
-
103
- def image_inspects
104
- @image_inspects ||= {}
105
- end
106
- end
107
-
108
- protected
109
-
110
- class << self
111
- def image_name_format
112
- "#{DockerRegistry.repo_name_format}(:(?<tag>#{tag_format}))?"
113
- end
114
-
115
- def tag_format
116
- '(?![-.])[a-zA-Z0-9_.-]{1,127}'
117
- end
118
-
119
- def image_name?(name)
120
- !(/^#{image_name_format}$/ =~ name).nil?
121
- end
122
-
123
- def tag?(name)
124
- !(/^#{tag_format}$/ =~ name).nil?
125
- end
126
-
127
- def tag!(id:, tag:, verbose: false, quiet: false)
128
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} tag #{id} #{tag}", verbose: verbose, quiet: quiet)
129
- image_inspects[tag] = image_inspect(id)
130
- end
131
-
132
- def save!(image_or_images, file_path, verbose: false, quiet: false)
133
- images = Array(image_or_images).join(' ')
134
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} save -o #{file_path} #{images}", verbose: verbose, quiet: quiet)
135
- end
136
-
137
- def load!(file_path, verbose: false, quiet: false)
138
- ::Dapp::Dapp.shellout!("#{::Dapp::Dapp.host_docker} load -i #{file_path}", verbose: verbose, quiet: quiet)
139
- end
140
- end
141
- end # Docker
142
- end # Image
143
- end # Dimg
144
- end # Dapp