docker_core 0.0.32 → 0.0.33

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 +119 -6
  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: 78790883b936bcf19663c2f53215d29a5d7712a7faaebd89f13e492ac9e99098
4
+ data.tar.gz: 21c7d7253185dc285019a21892359f2d48c28109c003af75b56272e0afe166d8
5
5
  SHA512:
6
- metadata.gz: 5bc578621035135247e128d111ff55393725de6b3f237bc2c6d3eb7af2e8e8f36b8382461a3005a02ab4aa4f25a8a59cc98c6185e7453215c12a3573bfae2bf9
7
- data.tar.gz: e28f011b67bcee8e3fac989191b8d727c5abadb6d58793f0a166fa75f4ffd2e29fc0552103bdb6f67e87fc4267aaa0431959db7ad8a075bbe09a91c0db7bc007
6
+ metadata.gz: 8be30ce90786a532a67b224ecd1e15a9608eb36536f71790d1d4deb7a9c6a98c03402022d3a197b3a4d4d5dddd0be252cdee24b4059c31c796511b290646b804
7
+ data.tar.gz: d274f01d320675e32986af240fe0a65f96a2a3d8acfbe410b7a49b64a4d016743a7da6ab7128edd8aa85560df06ccb3c09cf056438b92824ae4122ba81c9039f
data/lib/docker_core.rb CHANGED
@@ -14,6 +14,52 @@ 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
+ end
62
+
17
63
  class Color < Thor::Shell::Color
18
64
  # @param [String] text
19
65
  # @param [Array<String>] colors
@@ -35,6 +81,63 @@ module DockerCore
35
81
  end
36
82
 
37
83
  class Runner < Thor
84
+ desc('swarm_command', 'show swarm command')
85
+ def swarm_command
86
+ Process.run('ruby', Swarm.runner_path, sudo: false)
87
+ end
88
+
89
+ desc('swarm_setup', 'setup swarm')
90
+ def swarm_setup
91
+ Error.no_method(__method__)
92
+ end
93
+
94
+ desc('swarm_leave', 'leave swarm')
95
+ def swarm_leave
96
+ Error.no_method(__method__)
97
+ end
98
+
99
+ desc('stack_deploy', 'deploy stack')
100
+ def stack_deploy
101
+ Error.no_method(__method__)
102
+ end
103
+
104
+ desc('stack_remove', 'remove stack')
105
+ def stack_remove
106
+ Error.no_method(__method__)
107
+ end
108
+
109
+ desc('swarm_status', 'show swarm service status')
110
+ def swarm_status
111
+ Swarm.swarm_status
112
+ end
113
+
114
+ desc('update_swarm [orchestrator]', 'update default orchestrator')
115
+ def update_swarm(orchestrator = '')
116
+ Swarm.update_swarm(orchestrator)
117
+ end
118
+
119
+ desc('update_core', 'update gem docker_core')
120
+ def update_core
121
+ Process.run('gem update docker_core')
122
+ Process.run('gem clean')
123
+ end
124
+
125
+ desc('update_alias', 'update alias')
126
+ def update_alias
127
+ script = Swarm.script_path
128
+ method = __method__.to_s
129
+ items = ['unalias -a']
130
+
131
+ self.class.all_commands.filter do |key, value|
132
+ next false == ['help', method].include?("#{key}")
133
+ end.each do |key, value|
134
+ items << "alias #{key}='#{__FILE__} #{key}' "
135
+ end
136
+
137
+ items << "alias #{method}='source #{script}' \n"
138
+ File.write(File.expand_path('~/.bash_aliases'), items.join("\n"))
139
+ Color.echo("Update #{items.size} aliases", Color::GREEN)
140
+ end
38
141
  end
39
142
 
40
143
  module Image
@@ -55,6 +158,16 @@ module DockerCore
55
158
  return "#{registry}/#{namespace}/#{image}:#{tag}"
56
159
  end
57
160
 
161
+ # @return [String]
162
+ def self.script_path
163
+ Error.no_method(__method__)
164
+ end
165
+
166
+ # @return [String]
167
+ def self.runner_path
168
+ Error.no_method(__method__)
169
+ end
170
+
58
171
  def self.deploy_path
59
172
  return File.expand_path('~/deploy')
60
173
  end
@@ -95,10 +208,10 @@ module DockerCore
95
208
  Color.echo(self.detect_services.to_yaml, color)
96
209
  end
97
210
 
98
- # @param [String] swarm
99
- def self.update_swarm(swarm = '')
100
- if false == swarm.empty?
101
- self.write_swarm(swarm)
211
+ # @param [String] orchestrator
212
+ def self.update_swarm(orchestrator = '')
213
+ if false == orchestrator.empty?
214
+ self.write_swarm(orchestrator)
102
215
  end
103
216
 
104
217
  orchestrator = self.detect_orchestrator
@@ -132,7 +245,7 @@ module DockerCore
132
245
  # @param [Boolean] echo
133
246
  # @return [String]
134
247
  def self.capture_command(*arguments, environment: {}, bind: {}, throw: false, wait: 0, strip: true, echo: false)
135
- raise "No implement #{__method__} method"
248
+ Error.no_method(__method__)
136
249
  end
137
250
 
138
251
  # @param [Array] arguments
@@ -143,7 +256,7 @@ module DockerCore
143
256
  # @param [Boolean] echo
144
257
  # @return [Boolean]
145
258
  def self.run_command(*arguments, environment: {}, bind: {}, throw: true, wait: 0, echo: true)
146
- raise "No implement #{__method__} method"
259
+ Error.no_method(__method__)
147
260
  end
148
261
 
149
262
  #noinspection RubyClassVariableUsageInspection
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.33
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-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fileutils