docker_core 0.0.33 → 0.0.37
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.
- checksums.yaml +4 -4
- data/lib/docker_core.rb +59 -68
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0375cb2f88d368c24f8b45c30ef14a8be4bf0f599b1bbf09aa889ffb4e7ff37
|
4
|
+
data.tar.gz: eb33596964712179047258e7ae4736d7d342fabb8fb0af55f7ee732d52a71e39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 977cc7b87c3e7385cde5f924445c505f4d7c5ca9067ab7e1d35ab4e0cb8d04df470bb95ffb13bc26fbc661636f52565c18666b7d090d2a5bab2666745e389cec
|
7
|
+
data.tar.gz: a800981a96c1978b33236991d25c04dae4f452f952ba55a7a46f5125ed93c01a4e4e5d0b50a0ec283f85f9695dd996f9f5234e193d67d3a1c4b0ec013e482c72
|
data/lib/docker_core.rb
CHANGED
@@ -58,6 +58,10 @@ module DockerCore
|
|
58
58
|
def self.no_method(method)
|
59
59
|
raise("#{method} method should be implemented in concrete class")
|
60
60
|
end
|
61
|
+
|
62
|
+
def self.maximum_redirect
|
63
|
+
raise('maximum redirect reached')
|
64
|
+
end
|
61
65
|
end
|
62
66
|
|
63
67
|
class Color < Thor::Shell::Color
|
@@ -81,63 +85,6 @@ module DockerCore
|
|
81
85
|
end
|
82
86
|
|
83
87
|
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
|
141
88
|
end
|
142
89
|
|
143
90
|
module Image
|
@@ -158,16 +105,6 @@ module DockerCore
|
|
158
105
|
return "#{registry}/#{namespace}/#{image}:#{tag}"
|
159
106
|
end
|
160
107
|
|
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
|
-
|
171
108
|
def self.deploy_path
|
172
109
|
return File.expand_path('~/deploy')
|
173
110
|
end
|
@@ -176,6 +113,47 @@ module DockerCore
|
|
176
113
|
return File.expand_path('~/.swarm')
|
177
114
|
end
|
178
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
|
+
|
124
|
+
# @see https://github.com/moby/moby/issues/31564
|
125
|
+
# @param [String] name
|
126
|
+
# @param [Boolean] echo
|
127
|
+
def self.check_name(name, echo: false)
|
128
|
+
color = Color::YELLOW
|
129
|
+
name = "#{name}"
|
130
|
+
items = name.chars
|
131
|
+
|
132
|
+
if items.empty? || 63 < items.length
|
133
|
+
if echo
|
134
|
+
Color.echo("'#{name}' should be between 1 and 63 characters long", color)
|
135
|
+
end
|
136
|
+
|
137
|
+
return false
|
138
|
+
end
|
139
|
+
|
140
|
+
if [items.first, items.last].include?('-')
|
141
|
+
if echo
|
142
|
+
Color.echo("'#{name}' should not start or end with a hyphen(-)", color)
|
143
|
+
end
|
144
|
+
|
145
|
+
return false
|
146
|
+
end
|
147
|
+
|
148
|
+
test = name.match?(/^[a-zA-Z0-9-]+$/)
|
149
|
+
|
150
|
+
if false == test && echo
|
151
|
+
Color.echo("'#{name}' should be a-z or A-Z or 0-9 and hyphen (-)", color)
|
152
|
+
end
|
153
|
+
|
154
|
+
return test
|
155
|
+
end
|
156
|
+
|
179
157
|
# @param [String] swarm
|
180
158
|
def self.write_swarm(swarm = '')
|
181
159
|
return File.write(self.swarm_path, "#{swarm}\n")
|
@@ -236,6 +214,18 @@ module DockerCore
|
|
236
214
|
return items
|
237
215
|
end
|
238
216
|
|
217
|
+
# @param [Array<String>] arguments
|
218
|
+
# @param [Array<String>] folders
|
219
|
+
def self.prepare_folders(*services, folders: %w[stack volume])
|
220
|
+
deploy = self.deploy_path
|
221
|
+
folders.each do |folder|
|
222
|
+
services.each do |service|
|
223
|
+
FileUtils.mkdir_p(File.join(deploy, folder, service))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
#noinspection RubyUnusedLocalVariable
|
239
229
|
# @param [Array] arguments
|
240
230
|
# @param [Hash] environment
|
241
231
|
# @param [Hash] bind
|
@@ -248,6 +238,7 @@ module DockerCore
|
|
248
238
|
Error.no_method(__method__)
|
249
239
|
end
|
250
240
|
|
241
|
+
#noinspection RubyUnusedLocalVariable
|
251
242
|
# @param [Array] arguments
|
252
243
|
# @param [Hash] environment
|
253
244
|
# @param [Hash] bind
|
@@ -509,7 +500,7 @@ module DockerCore
|
|
509
500
|
max_redirect = max_redirect - 1
|
510
501
|
|
511
502
|
if 0 == max_redirect
|
512
|
-
|
503
|
+
Error.maximum_redirect
|
513
504
|
end
|
514
505
|
|
515
506
|
return self.resolve_link(response['location'], max_redirect)
|
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.
|
4
|
+
version: 0.0.37
|
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-
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|