dry-stack 0.1.11 → 0.1.12
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 +18 -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: cbaeac98b043b8dccbbd59e01fd5777b7e9f6a94a7020e560750ee537c283e83
|
4
|
+
data.tar.gz: 7cb8549b37702848f761d7a56afb4baed6a73a419282415bd680aae2b76d7ebd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20109696956962c30782c47495ffcf267e7c9360fd9793bff44e9dbd30cdec3efb2824b8ac729399f01b2abcc3544daa61c5b71c5ba31f6593af1ce34a41d5ea
|
7
|
+
data.tar.gz: a14a9a310271f6dfa43059ad027dc6f8e3ac18d8e776d952af24ce9a4de11e365d58ce25de5b46914e454665ebed1d8c432604048947a5451667d5de74ff3ac2
|
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|
|
@@ -311,14 +307,16 @@ module Dry
|
|
311
307
|
|
312
308
|
prune = ->(o) {
|
313
309
|
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
|
310
|
+
o.delete_if { _2.nil? || ( _2.respond_to?(:empty?) && _2.empty?) } if o.is_a? Hash
|
315
311
|
}
|
316
312
|
prune[compose]
|
317
313
|
|
318
314
|
each_recursive _root: compose do |_path, node, v|
|
315
|
+
|
319
316
|
v.transform_keys!(&:to_s) if v.is_a? Hash
|
320
317
|
node.transform_keys!(&:to_s) if node.is_a? Hash
|
321
318
|
_path.last[node] = v.to_s if v.is_a? Symbol
|
319
|
+
_path.last[node] = nil if v == EMPTY_HASH
|
322
320
|
|
323
321
|
_path.last[node] = v.to_s if node.to_s == 'fluentd-async'
|
324
322
|
end
|
@@ -376,7 +374,7 @@ module Dry
|
|
376
374
|
opts[:ports] = [opts[:ports]].flatten if opts.key? :ports
|
377
375
|
opts[:environment] = opts.delete(:env) if opts.key? :env
|
378
376
|
|
379
|
-
service = @services[name.to_sym] ||= {environment: {}, deploy: {labels: []}}
|
377
|
+
service = @services[name.to_sym] ||= {environment: {}, deploy: {labels: []}, networks: {}}
|
380
378
|
service.deep_merge! opts
|
381
379
|
ServiceFunction.new(service, &) if block_given?
|
382
380
|
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.12
|
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
|