dry-stack 0.1.14 → 0.1.16
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 +23 -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: b5ebf65f6db6234c39d5bfe0b4b6c0be4dc1a2528a361a497b3aa80d093b3e02
|
4
|
+
data.tar.gz: 823bc35c24d568a2c76b4ed921e13e2ed6c9779a1deab5abcf22cc54bb97bc58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0eb24c92c82d33345308c66f430ffce14cad8fc841c212c9f9927f13c3273c9d66eff66f9dffe25ca7aad43e26a10b5cedda1fef1572b45ac23875490497e03c
|
7
|
+
data.tar.gz: 829f7596fda69391400a2166256632c2e4b5516cf6b07ae445a7c7eb49c24c90e8df80cc9558424b2dc9d3e6f36a33fc0e2abb56eb82be89fac18f262dd17a30
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -41,6 +41,19 @@ module Dry
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
def expand_hash(hash)
|
45
|
+
hash.select { _1.to_s =~ /\./ }.each do |k, v|
|
46
|
+
name = k.to_s.scan(/([^\.]*)\.(.*)/).flatten
|
47
|
+
hash.delete k
|
48
|
+
hash[name[0]] ||= {}
|
49
|
+
hash[name[0]][name[1]] ||= {}
|
50
|
+
hash[name[0]][name[1]].merge! v if v.is_a?(Hash)
|
51
|
+
hash[name[0]][name[1]] = v unless v.is_a?(Hash)
|
52
|
+
end
|
53
|
+
hash.each { expand_hash(_2) if _2.is_a?(Hash) }
|
54
|
+
hash
|
55
|
+
end
|
56
|
+
|
44
57
|
attr_accessor :cmd_params
|
45
58
|
@cmd_params = {}
|
46
59
|
|
@@ -64,6 +77,7 @@ module Dry
|
|
64
77
|
def command(cmd)= @service[:command] = cmd
|
65
78
|
def entrypoint(cmd)= @service[:entrypoint] = cmd
|
66
79
|
def deploy_label(str)= @service[:deploy][:labels] << str
|
80
|
+
def deploy(opts)=@service[:deploy].merge! expand_hash(opts)
|
67
81
|
def config(name = nil, opts)= (@service[:configs] ||= []) << {source: name.to_s}.merge(opts)
|
68
82
|
def logging(opts) = (@service[:logging] ||= {}).merge! opts
|
69
83
|
def user(user) = @service[:user] = user # "${UID}:${GID}", "www-data:www-data"
|
@@ -106,19 +120,6 @@ module Dry
|
|
106
120
|
@configurations = {}
|
107
121
|
end
|
108
122
|
|
109
|
-
def expand_hash(hash)
|
110
|
-
hash.select { _1.to_s =~ /\./ }.each do |k, v|
|
111
|
-
name = k.to_s.scan(/([^\.]*)\.(.*)/).flatten
|
112
|
-
hash.delete k
|
113
|
-
hash[name[0]] ||= {}
|
114
|
-
hash[name[0]][name[1]] ||= {}
|
115
|
-
hash[name[0]][name[1]].merge! v if v.is_a?(Hash)
|
116
|
-
hash[name[0]][name[1]] = v unless v.is_a?(Hash)
|
117
|
-
end
|
118
|
-
hash.each { expand_hash(_2) if _2.is_a?(Hash) }
|
119
|
-
hash
|
120
|
-
end
|
121
|
-
|
122
123
|
def nginx_host2regexp(str)
|
123
124
|
# http://nginx.org/en/docs/http/server_names.html
|
124
125
|
if str[0] == '~'
|
@@ -231,13 +232,15 @@ module Dry
|
|
231
232
|
|
232
233
|
service[:deploy].deep_merge! @deploy[name] if @deploy[name]
|
233
234
|
|
234
|
-
hash = {'service-name': service_name, 'stack-name': @name}
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
235
|
+
# hash = {'service-name': service_name, 'stack-name': @name}
|
236
|
+
env_sub = ->(s) {
|
237
|
+
s = s.to_s.dup
|
238
|
+
s.gsub!('%{stack-name}', @name.to_s)
|
239
|
+
s.gsub!('%{service-name}', service_name)
|
240
|
+
s
|
241
|
+
}
|
242
|
+
service[:deploy][:labels] = service[:deploy][:labels].map{ env_sub[_1] }
|
243
|
+
service[:environment].transform_values!{ _1.is_a?(String) ? (env_sub[_1]) : _1 }
|
241
244
|
|
242
245
|
pp_i = @publish_ports[name]&.reject { _1.class == String }
|
243
246
|
pp_s = @publish_ports[name]&.select { _1.class == String }
|
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.16
|
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-09-
|
11
|
+
date: 2024-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|