docker_core 0.0.27 → 0.0.31
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 +99 -43
- 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: 3844eb4ee913899cab8113bb7ce6ef006eca4a3c20520ccbd1e9c9b74f5245e4
|
4
|
+
data.tar.gz: 1ee372fce84dcc125d3ded1f14d65c583ef919949d4d722e2be1672f40fea992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6b3c402892459520958a46ed72d79fa2f7b9ec16daa447b34cae359a3a0b0f461a077f2a77ea39cf69c4148e399d0e4fb0cecbcd3ac5ce15291a3eb02681566
|
7
|
+
data.tar.gz: a2a5d399de5ee88cc83795a175ec3ec0f829aa3756adda5b575f68325893125b206526e588a4242303d7996616931c6f67a29d48caf6005b1713d3d7edcbdbcd
|
data/lib/docker_core.rb
CHANGED
@@ -11,6 +11,8 @@ module DockerCore
|
|
11
11
|
SUDO = false
|
12
12
|
USER = 'core'
|
13
13
|
GROUP = 'core'
|
14
|
+
REGISTRY = 'docker.io'
|
15
|
+
NAMESPACE = 'library'
|
14
16
|
|
15
17
|
class Color < Thor::Shell::Color
|
16
18
|
# @param [String] text
|
@@ -39,66 +41,112 @@ module DockerCore
|
|
39
41
|
end
|
40
42
|
|
41
43
|
module Command
|
42
|
-
|
43
|
-
def self.swarm_path
|
44
|
-
return File.expand_path('~/.swarm')
|
45
|
-
end
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
46
|
+
module Swarm
|
47
|
+
# @param [String] image
|
48
|
+
# @param [String] registry
|
49
|
+
# @param [String] namespace
|
50
|
+
# @param [String] tag
|
51
|
+
def self.use_image(image, registry: REGISTRY, namespace: NAMESPACE, tag: 'latest')
|
52
|
+
return [registry, namespace, image].join('/') + ":#{tag}"
|
53
|
+
end
|
51
54
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
55
|
+
def self.deploy_path
|
56
|
+
return File.expand_path('~/deploy')
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
end
|
59
|
+
def self.swarm_path
|
60
|
+
return File.expand_path('~/.swarm')
|
61
|
+
end
|
61
62
|
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
# @param [String] swarm
|
64
|
+
def self.write_swarm(swarm = '')
|
65
|
+
return File.write(self.swarm_path, "#{swarm}\n")
|
66
|
+
end
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
def self.read_swarm
|
69
|
+
file = self.swarm_path
|
70
|
+
return File.exists?(file) ? File.read(file).strip : ''
|
71
|
+
end
|
69
72
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
def self.detect_services
|
74
|
+
return { docker: Shell.is_active_unit('docker') }
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.detect_swarm
|
78
|
+
swarm = self.read_swarm.to_sym
|
79
|
+
detect = self.detect_services
|
73
80
|
|
74
|
-
|
75
|
-
return "#{
|
81
|
+
if detect.has_key?(swarm) && detect[swarm]
|
82
|
+
return "#{swarm}"
|
76
83
|
end
|
77
84
|
|
78
|
-
|
79
|
-
|
80
|
-
|
85
|
+
index = detect.key(true)
|
86
|
+
return "#{index}"
|
87
|
+
end
|
81
88
|
|
82
|
-
|
83
|
-
|
84
|
-
|
89
|
+
def self.swarm_status
|
90
|
+
color = Color::GREEN
|
91
|
+
detect = self.detect_swarm
|
85
92
|
|
86
|
-
#
|
87
|
-
|
88
|
-
|
89
|
-
self.write_swarm(swarm)
|
90
|
-
end
|
93
|
+
Color.echo("Swarm: #{detect}", color)
|
94
|
+
Color.echo(self.detect_services.to_yaml, color)
|
95
|
+
end
|
91
96
|
|
92
|
-
|
97
|
+
# @param [String] swarm
|
98
|
+
def self.update_swarm(swarm = '')
|
99
|
+
if false == swarm.empty?
|
93
100
|
self.write_swarm(swarm)
|
101
|
+
end
|
94
102
|
|
95
|
-
|
96
|
-
|
97
|
-
|
103
|
+
swarm = self.detect_swarm
|
104
|
+
self.write_swarm(swarm)
|
105
|
+
|
106
|
+
if swarm.empty?
|
107
|
+
swarm = 'none'
|
108
|
+
end
|
109
|
+
|
110
|
+
Color.echo("Swarm: #{swarm}", Color::GREEN)
|
111
|
+
end
|
98
112
|
|
99
|
-
|
113
|
+
# @param [String] base
|
114
|
+
# @param [String] relative
|
115
|
+
def self.pair_paths(base, relative = '')
|
116
|
+
items = {}
|
117
|
+
|
118
|
+
{ inside: base, outside: Dir.pwd }.each do |key, value|
|
119
|
+
items[key] = File.join(value, relative)
|
100
120
|
end
|
121
|
+
|
122
|
+
return items
|
123
|
+
end
|
124
|
+
|
125
|
+
# @param [Array] arguments
|
126
|
+
# @param [Boolean] throw
|
127
|
+
# @param [Numeric] wait
|
128
|
+
# @param [Boolean] strip
|
129
|
+
# @param [Boolean] echo
|
130
|
+
# @return [String]
|
131
|
+
def self.capture_command(*arguments, environment: {}, throw: false, wait: 0, strip: true, echo: false)
|
132
|
+
raise "No implement #{__method__} method"
|
133
|
+
end
|
134
|
+
|
135
|
+
# @param [Array] arguments
|
136
|
+
# @param [Boolean] throw
|
137
|
+
# @param [Numeric] wait
|
138
|
+
# @param [Boolean] echo
|
139
|
+
# @return [Boolean]
|
140
|
+
def self.run_command(*arguments, environment: {}, throw: true, wait: 0, echo: true)
|
141
|
+
raise "No implement #{__method__} method"
|
142
|
+
end
|
143
|
+
|
144
|
+
#noinspection RubyClassVariableUsageInspection
|
145
|
+
def self.swarm
|
146
|
+
@@swarm ||= self.detect_swarm
|
147
|
+
return "#{@@swarm}"
|
101
148
|
end
|
149
|
+
|
102
150
|
end
|
103
151
|
|
104
152
|
module Paser
|
@@ -261,6 +309,11 @@ module DockerCore
|
|
261
309
|
return hash.fetch(machine.to_sym, machine)
|
262
310
|
end
|
263
311
|
|
312
|
+
# @param [String] unit
|
313
|
+
def self.is_active_unit(unit)
|
314
|
+
return 'active' == Process.capture("systemctl is-active #{unit}").downcase
|
315
|
+
end
|
316
|
+
|
264
317
|
# @param [Array<String>] arguments
|
265
318
|
# @return [Array<String>]
|
266
319
|
def self.find_paths(*arguments)
|
@@ -484,6 +537,9 @@ module DockerCore
|
|
484
537
|
uri = URI("https://api.github.com/repos/#{repository}/releases/latest")
|
485
538
|
data = JSON.parse(Net::HTTP.get(uri))['tag_name']
|
486
539
|
return "#{data}"
|
540
|
+
|
541
|
+
|
542
|
+
|
487
543
|
end
|
488
544
|
end
|
489
545
|
|
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.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- agrozyme
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08
|
11
|
+
date: 2021-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|