docker_core 0.0.32 → 0.0.36

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 (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docker_core.rb +80 -9
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3462495808e195a26c503fcb47e809cd1cf3b14234785f54906da57c1312fadd
4
- data.tar.gz: ca4e5679e8ea61bd243355a9b4ad68258d7da68086d51356e6105df10f51d206
3
+ metadata.gz: fd55c6918dc257c2505498aa7df47baa69323551f0fc044bfb1f7b5550e5fff1
4
+ data.tar.gz: 96e1e4a3c8c855d4c11f79da51edb8ec0530ff1d08f2df904ae6dc1560d5bd1b
5
5
  SHA512:
6
- metadata.gz: 5bc578621035135247e128d111ff55393725de6b3f237bc2c6d3eb7af2e8e8f36b8382461a3005a02ab4aa4f25a8a59cc98c6185e7453215c12a3573bfae2bf9
7
- data.tar.gz: e28f011b67bcee8e3fac989191b8d727c5abadb6d58793f0a166fa75f4ffd2e29fc0552103bdb6f67e87fc4267aaa0431959db7ad8a075bbe09a91c0db7bc007
6
+ metadata.gz: dc8cfe3b768718901c057f780a0ee73425c24ddb6cff24046ce123a0079e428c962ac6c0372209558f191a442e077c5c12e558f2505860613e7de650a90fd6ee
7
+ data.tar.gz: 07d546f99ec45bf205a6721e3ac457f44cd86e62702fa48acdf83f5bd9a34ecfac5aaea66b14ad329679632db894d93fe61ec08b07ab2fab27dedd8567bac337
data/lib/docker_core.rb CHANGED
@@ -14,6 +14,56 @@ module DockerCore
14
14
  REGISTRY = 'docker.io'
15
15
  NAMESPACE = 'library'
16
16
 
17
+ module Base
18
+ module Command
19
+ module ClassMethod
20
+ # @return [String]
21
+ def from_image
22
+ Error.no_method(__method__)
23
+ end
24
+
25
+ # @return [String]
26
+ def work_folder
27
+ Error.no_method(__method__)
28
+ end
29
+
30
+ # @param [Array] arguments
31
+ # @param [Boolean] throw
32
+ # @param [Numeric] wait
33
+ # @param [Boolean] strip
34
+ # @param [Boolean] echo
35
+ def capture_command(*arguments, environment: {}, bind: {}, throw: false, wait: 0, strip: true, echo: false)
36
+ bind[Dir.pwd] = self.work_folder
37
+ Swarm.capture_command(self.from_image, *arguments, environment: environment, bind: bind, throw: throw, wait: wait, strip: strip, echo: echo)
38
+ end
39
+
40
+ # @param [Array] arguments
41
+ # @param [Boolean] throw
42
+ # @param [Numeric] wait
43
+ # @param [Boolean] echo
44
+ def run_command(*arguments, environment: {}, bind: {}, throw: true, wait: 0, echo: true)
45
+ bind[Dir.pwd] = self.work_folder
46
+ Swarm.run_command(self.from_image, *arguments, environment: environment, bind: bind, throw: throw, wait: wait, echo: echo)
47
+ end
48
+ end
49
+
50
+ def self.included(base)
51
+ base.extend(ClassMethod)
52
+ end
53
+ end
54
+ end
55
+
56
+ module Error
57
+ # @param [Symbol] method
58
+ def self.no_method(method)
59
+ raise("#{method} method should be implemented in concrete class")
60
+ end
61
+
62
+ def self.maximum_redirect
63
+ raise('maximum redirect reached')
64
+ end
65
+ end
66
+
17
67
  class Color < Thor::Shell::Color
18
68
  # @param [String] text
19
69
  # @param [Array<String>] colors
@@ -63,6 +113,14 @@ module DockerCore
63
113
  return File.expand_path('~/.swarm')
64
114
  end
65
115
 
116
+ # def self.profile_path
117
+ # return File.realpath('profile.sh', self.deploy_path)
118
+ # end
119
+ #
120
+ # def self.runner_path
121
+ # return File.realpath('runner.rb', self.deploy_path)
122
+ # end
123
+
66
124
  # @param [String] swarm
67
125
  def self.write_swarm(swarm = '')
68
126
  return File.write(self.swarm_path, "#{swarm}\n")
@@ -95,10 +153,10 @@ module DockerCore
95
153
  Color.echo(self.detect_services.to_yaml, color)
96
154
  end
97
155
 
98
- # @param [String] swarm
99
- def self.update_swarm(swarm = '')
100
- if false == swarm.empty?
101
- self.write_swarm(swarm)
156
+ # @param [String] orchestrator
157
+ def self.update_swarm(orchestrator = '')
158
+ if false == orchestrator.empty?
159
+ self.write_swarm(orchestrator)
102
160
  end
103
161
 
104
162
  orchestrator = self.detect_orchestrator
@@ -123,6 +181,18 @@ module DockerCore
123
181
  return items
124
182
  end
125
183
 
184
+ # @param [Array<String>] arguments
185
+ # @param [Array<String>] folders
186
+ def self.prepare_folders(*services, folders: %w[stack volume])
187
+ deploy = self.deploy_path
188
+ folders.each do |folder|
189
+ services.each do |service|
190
+ FileUtils.mkdir_p(File.join(deploy, folder, service))
191
+ end
192
+ end
193
+ end
194
+
195
+ #noinspection RubyUnusedLocalVariable
126
196
  # @param [Array] arguments
127
197
  # @param [Hash] environment
128
198
  # @param [Hash] bind
@@ -132,9 +202,10 @@ module DockerCore
132
202
  # @param [Boolean] echo
133
203
  # @return [String]
134
204
  def self.capture_command(*arguments, environment: {}, bind: {}, throw: false, wait: 0, strip: true, echo: false)
135
- raise "No implement #{__method__} method"
205
+ Error.no_method(__method__)
136
206
  end
137
207
 
208
+ #noinspection RubyUnusedLocalVariable
138
209
  # @param [Array] arguments
139
210
  # @param [Hash] environment
140
211
  # @param [Hash] bind
@@ -143,7 +214,7 @@ module DockerCore
143
214
  # @param [Boolean] echo
144
215
  # @return [Boolean]
145
216
  def self.run_command(*arguments, environment: {}, bind: {}, throw: true, wait: 0, echo: true)
146
- raise "No implement #{__method__} method"
217
+ Error.no_method(__method__)
147
218
  end
148
219
 
149
220
  #noinspection RubyClassVariableUsageInspection
@@ -396,7 +467,7 @@ module DockerCore
396
467
  max_redirect = max_redirect - 1
397
468
 
398
469
  if 0 == max_redirect
399
- raise('maximum redirect reached')
470
+ Error.maximum_redirect
400
471
  end
401
472
 
402
473
  return self.resolve_link(response['location'], max_redirect)
@@ -512,8 +583,8 @@ module DockerCore
512
583
 
513
584
  Process.run('deluser', USER, throw: false)
514
585
  Process.run('delgroup', GROUP, throw: false)
515
- Process.run('addgroup', { system: true, gid: gid }, GROUP)
516
- Process.run('adduser', { system: true, 'disabled-password': true, 'no-create-home': true, ingroup: GROUP, gecos: USER, shell: '/bin/bash', uid: uid }, USER)
586
+ Process.run('addgroup', { system: true, gid: gid }, GROUP, throw: false)
587
+ Process.run('adduser', { system: true, 'disabled-password': true, 'no-create-home': true, ingroup: GROUP, gecos: USER, shell: '/bin/bash', uid: uid }, USER, throw: false)
517
588
  end
518
589
 
519
590
  # @param [String] stdout
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.32
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - agrozyme
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-08 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils