docker_core 0.0.28 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/docker_core.rb +99 -50
- 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: 3462495808e195a26c503fcb47e809cd1cf3b14234785f54906da57c1312fadd
|
4
|
+
data.tar.gz: ca4e5679e8ea61bd243355a9b4ad68258d7da68086d51356e6105df10f51d206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bc578621035135247e128d111ff55393725de6b3f237bc2c6d3eb7af2e8e8f36b8382461a3005a02ab4aa4f25a8a59cc98c6185e7453215c12a3573bfae2bf9
|
7
|
+
data.tar.gz: e28f011b67bcee8e3fac989191b8d727c5abadb6d58793f0a166fa75f4ffd2e29fc0552103bdb6f67e87fc4267aaa0431959db7ad8a075bbe09a91c0db7bc007
|
data/lib/docker_core.rb
CHANGED
@@ -40,75 +40,118 @@ module DockerCore
|
|
40
40
|
module Image
|
41
41
|
end
|
42
42
|
|
43
|
+
module Orchestrator
|
44
|
+
end
|
45
|
+
|
43
46
|
module Command
|
44
|
-
|
45
|
-
# @param [String] image
|
46
|
-
# @param [String] registry
|
47
|
-
# @param [String] namespace
|
48
|
-
# @param [String] tag
|
49
|
-
def self.use_image(image, registry: REGISTRY, namespace: NAMESPACE, tag: 'latest')
|
50
|
-
return [registry, namespace, image].join('/') + ":#{tag}"
|
51
|
-
end
|
47
|
+
end
|
52
48
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
module Swarm
|
50
|
+
# @param [String] image
|
51
|
+
# @param [String] registry
|
52
|
+
# @param [String] namespace
|
53
|
+
# @param [String] tag
|
54
|
+
def self.from_image(image, registry: REGISTRY, namespace: NAMESPACE, tag: 'latest')
|
55
|
+
return "#{registry}/#{namespace}/#{image}:#{tag}"
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
def self.deploy_path
|
59
|
+
return File.expand_path('~/deploy')
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
62
|
+
def self.swarm_path
|
63
|
+
return File.expand_path('~/.swarm')
|
64
|
+
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
66
|
+
# @param [String] swarm
|
67
|
+
def self.write_swarm(swarm = '')
|
68
|
+
return File.write(self.swarm_path, "#{swarm}\n")
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
def self.read_swarm
|
72
|
+
file = self.swarm_path
|
73
|
+
return File.exists?(file) ? File.read(file).strip : ''
|
74
|
+
end
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
76
|
+
def self.detect_services
|
77
|
+
return { docker: Shell.is_active_unit('docker') }
|
78
|
+
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
def self.detect_orchestrator
|
81
|
+
swarm = self.read_swarm.to_sym
|
82
|
+
detect = self.detect_services
|
83
83
|
|
84
|
-
|
85
|
-
return "#{
|
84
|
+
if detect.has_key?(swarm) && detect[swarm]
|
85
|
+
return "#{swarm}"
|
86
86
|
end
|
87
87
|
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
index = detect.key(true)
|
89
|
+
return "#{index}"
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.swarm_status
|
93
|
+
color = Color::GREEN
|
94
|
+
Color.echo("Swarm: #{self.detect_orchestrator}", color)
|
95
|
+
Color.echo(self.detect_services.to_yaml, color)
|
96
|
+
end
|
91
97
|
|
92
|
-
|
93
|
-
|
98
|
+
# @param [String] swarm
|
99
|
+
def self.update_swarm(swarm = '')
|
100
|
+
if false == swarm.empty?
|
101
|
+
self.write_swarm(swarm)
|
94
102
|
end
|
95
103
|
|
96
|
-
|
97
|
-
|
98
|
-
if false == swarm.empty?
|
99
|
-
self.write_swarm(swarm)
|
100
|
-
end
|
104
|
+
orchestrator = self.detect_orchestrator
|
105
|
+
self.write_swarm(orchestrator)
|
101
106
|
|
102
|
-
|
103
|
-
|
107
|
+
if orchestrator.empty?
|
108
|
+
orchestrator = '<none>'
|
109
|
+
end
|
104
110
|
|
105
|
-
|
106
|
-
|
107
|
-
|
111
|
+
Color.echo("Swarm: #{orchestrator}", Color::GREEN)
|
112
|
+
end
|
113
|
+
|
114
|
+
# @param [String] base
|
115
|
+
# @param [String] relative
|
116
|
+
def self.pair_paths(base, relative = '')
|
117
|
+
items = {}
|
108
118
|
|
109
|
-
|
119
|
+
{ inside: base, outside: Dir.pwd }.each do |key, value|
|
120
|
+
items[key] = File.join(value, relative)
|
110
121
|
end
|
122
|
+
|
123
|
+
return items
|
124
|
+
end
|
125
|
+
|
126
|
+
# @param [Array] arguments
|
127
|
+
# @param [Hash] environment
|
128
|
+
# @param [Hash] bind
|
129
|
+
# @param [Boolean] throw
|
130
|
+
# @param [Numeric] wait
|
131
|
+
# @param [Boolean] strip
|
132
|
+
# @param [Boolean] echo
|
133
|
+
# @return [String]
|
134
|
+
def self.capture_command(*arguments, environment: {}, bind: {}, throw: false, wait: 0, strip: true, echo: false)
|
135
|
+
raise "No implement #{__method__} method"
|
111
136
|
end
|
137
|
+
|
138
|
+
# @param [Array] arguments
|
139
|
+
# @param [Hash] environment
|
140
|
+
# @param [Hash] bind
|
141
|
+
# @param [Boolean] throw
|
142
|
+
# @param [Numeric] wait
|
143
|
+
# @param [Boolean] echo
|
144
|
+
# @return [Boolean]
|
145
|
+
def self.run_command(*arguments, environment: {}, bind: {}, throw: true, wait: 0, echo: true)
|
146
|
+
raise "No implement #{__method__} method"
|
147
|
+
end
|
148
|
+
|
149
|
+
#noinspection RubyClassVariableUsageInspection
|
150
|
+
def self.orchestrator
|
151
|
+
@@orchestrator ||= self.detect_orchestrator
|
152
|
+
return "#{@@orchestrator}"
|
153
|
+
end
|
154
|
+
|
112
155
|
end
|
113
156
|
|
114
157
|
module Paser
|
@@ -271,6 +314,11 @@ module DockerCore
|
|
271
314
|
return hash.fetch(machine.to_sym, machine)
|
272
315
|
end
|
273
316
|
|
317
|
+
# @param [String] unit
|
318
|
+
def self.is_active_unit(unit)
|
319
|
+
return 'active' == Process.capture("systemctl is-active #{unit}").downcase
|
320
|
+
end
|
321
|
+
|
274
322
|
# @param [Array<String>] arguments
|
275
323
|
# @return [Array<String>]
|
276
324
|
def self.find_paths(*arguments)
|
@@ -494,6 +542,7 @@ module DockerCore
|
|
494
542
|
uri = URI("https://api.github.com/repos/#{repository}/releases/latest")
|
495
543
|
data = JSON.parse(Net::HTTP.get(uri))['tag_name']
|
496
544
|
return "#{data}"
|
545
|
+
|
497
546
|
end
|
498
547
|
end
|
499
548
|
|
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.32
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fileutils
|