dry-stack 0.1.11 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dry-stack/stack.rb +22 -20
- data/lib/version.rb +1 -1
- 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: 54ac4c65eb9a540d8b78351dc5bdc4510034618928f212532fa18a18db143ac2
|
4
|
+
data.tar.gz: cc6ccabf6a2a75b31236355012cfb033ce732f1b2379996aa519068ba95a51bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4873a1ff78e0ff316448b84d33d2dee65c928069b30a575dc45af76635884ee77de33dd8aa6178aff29e21d05cbd2dc35c488d21c4cc92ff71830414771bc2b0
|
7
|
+
data.tar.gz: 8f85f6126686c34d6219dd8a21f50d8765d34fe1db4e9a4b6f753894d48bb5f0a609035dc9fd92b550d9df863b27948044ad081208d528435b9996c7977e1fdf
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -14,6 +14,8 @@ require_relative 'apache_specific_md5'
|
|
14
14
|
# end
|
15
15
|
|
16
16
|
module Dry
|
17
|
+
EMPTY_HASH = :empty_hash
|
18
|
+
|
17
19
|
class ::Hash
|
18
20
|
def deep_merge!(second)
|
19
21
|
merger = proc { |_, v1, v2|
|
@@ -65,7 +67,7 @@ module Dry
|
|
65
67
|
def config(name = nil, opts)= (@service[:configs] ||= []) << {source: name.to_s}.merge(opts)
|
66
68
|
def logging(opts) = (@service[:logging] ||= {}).merge! opts
|
67
69
|
def user(user) = @service[:user] = user # "${UID}:${GID}", "www-data:www-data"
|
68
|
-
def network(
|
70
|
+
def network(name, opts = {}) = (@service[:networks][name] ||={}).merge! opts
|
69
71
|
def ingress(ing) = ((@service[:ingress] ||=[]) << ing).flatten!
|
70
72
|
end
|
71
73
|
|
@@ -160,9 +162,9 @@ module Dry
|
|
160
162
|
service[:deploy][:labels] += @labels.map { "#{_1}=#{_2}" }
|
161
163
|
|
162
164
|
if ingress[0] && (opts[:ingress] || opts[:traefik] || opts[:traefik_tls])
|
163
|
-
service[:networks] ||=
|
164
|
-
service[:networks]
|
165
|
-
service[:networks]
|
165
|
+
service[:networks] ||= {}
|
166
|
+
service[:networks][:default] ||= {} if service[:networks].empty?
|
167
|
+
service[:networks][:ingress_routing] ||= {}
|
166
168
|
end
|
167
169
|
|
168
170
|
ingress.each do |rule|
|
@@ -266,21 +268,15 @@ module Dry
|
|
266
268
|
end
|
267
269
|
end
|
268
270
|
|
269
|
-
service[:networks]&.
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
(compose[:networks][n_name] ||= {}).merge! network
|
275
|
-
end
|
276
|
-
n_name
|
277
|
-
else
|
278
|
-
$stderr.puts ':name must be specified in network declaration'
|
279
|
-
raise 'invalid network declaration'
|
280
|
-
end
|
281
|
-
else
|
282
|
-
network
|
271
|
+
service[:networks]&.each do |name, network|
|
272
|
+
next unless network.is_a? Hash
|
273
|
+
|
274
|
+
if network[:name]
|
275
|
+
(compose[:networks][name] ||= {}).merge! network.except(:aliases).merge(name: network[:name])
|
283
276
|
end
|
277
|
+
network.delete :external
|
278
|
+
network.delete :name
|
279
|
+
service[:networks][name] = EMPTY_HASH if network.empty?
|
284
280
|
end
|
285
281
|
|
286
282
|
service[:configs]&.each_with_index do |config, index|
|
@@ -309,16 +305,22 @@ module Dry
|
|
309
305
|
end
|
310
306
|
end
|
311
307
|
|
308
|
+
compose[:networks].transform_values! do |network|
|
309
|
+
network.empty? ? EMPTY_HASH : network
|
310
|
+
end
|
311
|
+
|
312
312
|
prune = ->(o) {
|
313
313
|
o.each { prune[_2] } if o.is_a? Hash
|
314
|
-
o.delete_if { _2.nil? || (_2.respond_to?(:empty?) && _2.empty?) } if o.is_a? Hash
|
314
|
+
o.delete_if { _2.nil? || ( _2.respond_to?(:empty?) && _2.empty?) } if o.is_a? Hash
|
315
315
|
}
|
316
316
|
prune[compose]
|
317
317
|
|
318
318
|
each_recursive _root: compose do |_path, node, v|
|
319
|
+
|
319
320
|
v.transform_keys!(&:to_s) if v.is_a? Hash
|
320
321
|
node.transform_keys!(&:to_s) if node.is_a? Hash
|
321
322
|
_path.last[node] = v.to_s if v.is_a? Symbol
|
323
|
+
_path.last[node] = nil if v == EMPTY_HASH
|
322
324
|
|
323
325
|
_path.last[node] = v.to_s if node.to_s == 'fluentd-async'
|
324
326
|
end
|
@@ -376,7 +378,7 @@ module Dry
|
|
376
378
|
opts[:ports] = [opts[:ports]].flatten if opts.key? :ports
|
377
379
|
opts[:environment] = opts.delete(:env) if opts.key? :env
|
378
380
|
|
379
|
-
service = @services[name.to_sym] ||= {environment: {}, deploy: {labels: []}}
|
381
|
+
service = @services[name.to_sym] ||= {environment: {}, deploy: {labels: []}, networks: {}}
|
380
382
|
service.deep_merge! opts
|
381
383
|
ServiceFunction.new(service, &) if block_given?
|
382
384
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dry-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artyom B
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|