dry-stack 0.1.62 → 0.1.63

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8407e55c9630cfdc80cfa951e57b9c4620865112d5b6aaef980b0934d3d89fcb
4
- data.tar.gz: a149c902f4f9e6f8c2adcebc0481607db26558e142ba4eae7683a6f0684421f9
3
+ metadata.gz: ce9d6102c6ff6cb17fedabdde36397e51449af498dd69e939b978f3dc70fa2cf
4
+ data.tar.gz: 0667c093ab72a2c2c09ac7975ea16b0f43971d7e8bf5cf11e5556af8a107400c
5
5
  SHA512:
6
- metadata.gz: 8cd9f91b0307d4ea4b16b5fa9e4b3d5a4a30d52ba27c51ca78721edbf38bbb45d5eaccb9b16829db08891b13f993a62e993708a6e41050fbb1660254b118aa43
7
- data.tar.gz: 3649e25ba13bd508a618dc34df3cea11474eae3aa98040bdd6329c6dc29e65e9c27ea1a9d323a66281fb131666be176d80e85922baf334f647aebb895cb53c11
6
+ metadata.gz: f201a90b5f82f24fd95ac74cd2e1c0d8b4674abb7de6fcb90ca9b1424dc1ba613d916bbc07c0bf17ecef03de762d39536e89a04d51443674f2576f3aa95ef795
7
+ data.tar.gz: 3b398ac9953210735570f4720da66e3e4dedd45c0e1e7924f45a683539dfeaabdb693002c209838a6155eef9325c93bf6175c4f944da69db269a3bc9ac3a0b0a
@@ -143,6 +143,23 @@ module Dry
143
143
  @configurations[configuration.to_sym][:block_function].call
144
144
  end
145
145
 
146
+ private def ingress_mount(ing)
147
+ return unless ing.key?(:mount)
148
+
149
+ conflicts = %i[path path_sub path_regexp host_sni] & ing.keys
150
+ raise ArgumentError, "ingress mount cannot be combined with #{conflicts.join(', ')}" unless conflicts.empty?
151
+
152
+ mount = ing[:mount]
153
+ unless mount.is_a?(String) && mount.match?(%r{\A/[A-Za-z0-9._~!$&'()*+;=:@/-]+\z})
154
+ raise ArgumentError, 'ingress mount requires a literal absolute URL path without encoding, query, fragment or comma'
155
+ end
156
+ mount = mount.delete_suffix('/')
157
+ if mount.empty? || mount.split('/', -1).drop(1).any? { _1.empty? || %w[. ..].include?(_1) }
158
+ raise ArgumentError, 'ingress mount must have nonempty path segments other than . or ..'
159
+ end
160
+ mount
161
+ end
162
+
146
163
  def to_compose(opts = @options)
147
164
  @name = @options[:name] || @name
148
165
  deploy_source = opts[:deploy_source].to_s.strip
@@ -198,6 +215,7 @@ module Dry
198
215
  ingress[0][:port] ||= service[:ports]&.first
199
216
 
200
217
  ingress.each_with_index do |ing, index|
218
+ mount = ingress_mount(ing)
201
219
  ing[:port] ||= service[:ports]&.first
202
220
  load_balancer = []
203
221
  load_balancer << "server.url=#{ing[:url]}" if ing[:url]
@@ -258,7 +276,11 @@ module Dry
258
276
  rule = []
259
277
  rule << "HostRegexp(`{name:#{nginx_host2regexp ing[:host]}}`)" if ing[:host]
260
278
  rule << "ClientIP(#{[ing[:client_ip]].flatten.map{ "`#{_1}`" }.join ','})" if ing[:client_ip]
261
- rule << "PathPrefix(`#{ing[:path]}`)" if ing[:path]
279
+ if mount
280
+ rule << "(Path(`#{mount}`) || PathPrefix(`#{mount}/`))".gsub('$', '$$')
281
+ else
282
+ rule << "PathPrefix(`#{ing[:path]}`)" if ing[:path]
283
+ end
262
284
  rule << "PathRegexp(`#{ing[:path_regexp]}`)" if ing[:path_regexp]
263
285
  rule << "#{ing[:rule]}" if ing[:rule]
264
286
 
@@ -282,6 +304,18 @@ module Dry
282
304
  service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.rule=#{rule.join ' && '}"
283
305
  service[:deploy][:labels] << "traefik.http.routers.#{service_name}-#{index}.priority=#{ing[:priority].to_i}" if ing[:priority]
284
306
 
307
+ if mount
308
+ prefix = "#{service_name}-#{index}-mount"
309
+ regex = "^(https?://[^/]+#{Regexp.escape(mount)})(\\?.*)?$"
310
+ middlewares += ["#{prefix}-redirect", "#{prefix}-strip"]
311
+ service[:deploy][:labels] += [
312
+ "traefik.http.middlewares.#{prefix}-redirect.redirectregex.regex=#{regex.gsub('$', '$$')}",
313
+ "traefik.http.middlewares.#{prefix}-redirect.redirectregex.replacement=$${1}/$${2}",
314
+ "traefik.http.middlewares.#{prefix}-redirect.redirectregex.permanent=false",
315
+ "traefik.http.middlewares.#{prefix}-strip.stripprefix.prefixes=#{mount.gsub('$', '$$')}"
316
+ ]
317
+ end
318
+
285
319
  if ing[:path_sub]
286
320
  middlewares << "#{service_name}-#{index}-path_sub"
287
321
  service[:deploy][:labels] += [
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  class Stack
3
- VERSION = '0.1.62'
3
+ VERSION = '0.1.63'
4
4
  end
5
5
  end
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.62
4
+ version: 0.1.63
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-08 00:00:00.000000000 Z
11
+ date: 2026-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -131,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.3.7
134
+ rubygems_version: 3.3.27
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Dry docker swarm stack definition