dry-stack 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 516984772a050079922f9bb5382f61562454fc49079b478cf4f6ac58ba86fcf7
4
- data.tar.gz: 55213cc08e7512c0aab51362fa12c9758090c3d16c4a341fb212f9ea8a963ddd
3
+ metadata.gz: 1cf8aa8cb9489eb7287cdf9c78c3c5c9da3f6d311ff6c949249af4e0f615a3b5
4
+ data.tar.gz: a7d0e07feac23d18478c8890b9f9934e657b4964feae95bbd1da1d26e208a1ec
5
5
  SHA512:
6
- metadata.gz: 90bbba8c4cdc86faf47b285ef2af1c071e4101c18f80ee25471fab603f03ddcfa988ebbfd8bffec248b3944c792e8a42db24e792f35a97e543455967cf0f5d4a
7
- data.tar.gz: f672f19d5a13377aee80d23d513147adb11c4a9f5814aac1e45c55b97a40f7ab2470b02c643b035391bfe389ced0b08ccbec17708fca22f85c6d88ca10b78d8c
6
+ metadata.gz: a68af80fb155c93aadd9031ae0e16d94debff2926f71e6ff1f643069815ee8fa52823c84e7348699bde8a348fdeba76e203d9812d0982fecef40be9d1d7d4704
7
+ data.tar.gz: fc170d04a11489ef3fc468f0621038909541de3a4187dfb9b3c55c3db895526e6b31c643a1c3879ec06c8db67483d244652c94b4e2f9886d01d725fce196f1be
@@ -38,7 +38,10 @@ module Dry
38
38
  end
39
39
 
40
40
  def safe_eval(drs, params)
41
- Dry::Stack(params[:name], params[:configuration]) { eval drs, self.binding }
41
+ Dry::Stack(params[:name], params[:configuration]) do
42
+ eval drs, self.binding
43
+ @after_blocks&.each { instance_exec &_1 }
44
+ end
42
45
  end
43
46
 
44
47
  def run(args)
@@ -82,6 +85,7 @@ module Dry
82
85
 
83
86
  params.transform_keys!{_1.to_s.gsub('-','_').to_sym}
84
87
  params[:traefik_tls] = true if params[:tls_domain]
88
+ Dry.cmd_params = params
85
89
 
86
90
  raise 'Stack file not defined' if $stdin.tty? && !params[:stack]
87
91
 
@@ -9,10 +9,10 @@ Dry::CommandLine::COMMANDS[:swarm_deploy] = Class.new do
9
9
  _params = stack.options.merge params
10
10
  stack.name = _params[:name] if _params[:name]
11
11
 
12
- if params[:'context-endpoint']
13
- name = params[:'context-endpoint'].gsub( /[\/.:@]/,'_').gsub( '__','_')
12
+ if params[:context_endpoint]
13
+ name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_')
14
14
  name = "dry-#{name}".to_sym
15
- endpoint = params[:'context-endpoint']
15
+ endpoint = params[:context_endpoint]
16
16
  contexts = {}
17
17
  exec_o_lines 'docker context ls --format json' do |line|
18
18
  ctx = JSON.parse line, symbolize_names: true
@@ -39,6 +39,9 @@ module Dry
39
39
  end
40
40
  end
41
41
 
42
+ attr_accessor :cmd_params
43
+ @cmd_params = {}
44
+
42
45
  def Stack(name = nil, configuration = nil, &)
43
46
  Stack.last_stack = Stack.new name
44
47
  Stack.last_stack.instance_exec(&) if block_given?
@@ -303,6 +306,15 @@ module Dry
303
306
  JSON.parse(compose.to_json).to_yaml
304
307
  end
305
308
 
309
+ def Include(file_name)
310
+ dir = Dry.cmd_params[:stack] ? File.dirname(Dry.cmd_params[:stack]) : '.'
311
+ eval IO.read( File.join dir, file_name )
312
+ end
313
+
314
+ def After(&block)
315
+ (@after_blocks ||=[]) << block
316
+ end
317
+
306
318
  def PublishPorts(ports)
307
319
  @publish_ports.merge! ports.to_h { |k, v| [k,[v].flatten] }
308
320
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  class Stack
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.5'
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.3
4
+ version: 0.1.5
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-07-28 00:00:00.000000000 Z
11
+ date: 2024-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake