dry-stack 0.0.78 → 0.0.79

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: a17cdb3001d7c72255229cb88956602fe754b531cdb7b9e487dc2f7720a72bd4
4
- data.tar.gz: e8b606cd6394aa9541cd63232af35af44b8ff200f97a2ad81e4732409b16878f
3
+ metadata.gz: 8823f4774a66a511374052a8358d1f55b5fdd9828fe5de1805078ca2d6ed6e6f
4
+ data.tar.gz: 92c42ce074daa1565f3b927eeee50c90721741be2ec1748c220016d53c5e21a7
5
5
  SHA512:
6
- metadata.gz: bb9ca568d9a5bf2209e2b9f6681d0b353dbcd3e6406246ec19ea4b00cd4f2e6125372eca4148000b5086c75713551a0e6a0eb1c297efaaa8ea1043215a042340
7
- data.tar.gz: 4cbb642e2bf1e8b71369d861f43369a13678bdc63cc467faf1604ff7e9b9f2cfb5a6a31aeb5771395ccb98e547005c55315c5a0621f74ec63f8bd67dce6012d7
6
+ metadata.gz: fe64f228952239381ea0babe811d65f2f0a868e4f21a8452e3568314f0b89f2baf2da28c220620f4d7c46a8af586e3e417c1f35856f891f52164a6008e54ca3b
7
+ data.tar.gz: 4ab470216298a7d48417a5db86b1c5d955ab1eaf393aa4f3ec4b746c41995bfb098ffca4a19c896218d5f27fbb269c8b2954b225f9f30071212570fb0957527a
@@ -2,10 +2,10 @@ require_relative 'command_line'
2
2
 
3
3
  Dry::CommandLine::COMMANDS[:to_compose] = Class.new do
4
4
  def run(stack, params, args, extra)
5
- raise "unsupported args: #{args}" unless args.empty?
5
+ raise "none or one deploy name may be specified: #{args}" unless args.empty? || args.size == 1
6
6
  _params = stack.options.merge params
7
7
  stack.name = _params[:name] if _params[:name]
8
- yaml = stack.to_compose(_params).lines[1..].join
8
+ yaml = stack.to_compose(_params, args[0]&.to_sym ).lines[1..].join
9
9
 
10
10
  # substitute ENV variables
11
11
  _params[:'no-env'] ? $stdout.puts(yaml) : system("echo \"#{yaml.gsub("`", '\\\`')}\"")
@@ -61,6 +61,7 @@ module Dry
61
61
  class SwarmFunction
62
62
  def initialize(swarm, &); @swarm = swarm; instance_exec(&) end
63
63
  def env(variables)= @swarm[:environment].merge! variables
64
+ def options(variables)= @swarm[:options].merge! variables
64
65
  def context_host(host)= @swarm[:context_host] = host
65
66
  def context_name(name)= @swarm[:context_name] = name
66
67
  def stack_name(name)= @swarm[:stack_name] = name
@@ -119,7 +120,12 @@ module Dry
119
120
  end
120
121
  end
121
122
 
122
- def to_compose(opts = @options )
123
+ def to_compose(opts = @options, deploy_name = nil )
124
+ if deploy_name
125
+ raise "Deploy not found: #{deploy_name}" unless @swarm_deploy[deploy_name]
126
+
127
+ opts.merge! @swarm_deploy[deploy_name][:options]
128
+ end
123
129
  compose = {
124
130
  # name: @name.to_s, # https://docs.docker.com/compose/compose-file/#name-top-level-element
125
131
  # Not allowed by docker stack deploy
@@ -358,7 +364,7 @@ module Dry
358
364
  def SwarmDeploy(name, opts = {}, &)
359
365
  opts[:environment] = opts.delete(:env) if opts.key? :env
360
366
 
361
- swarm = @swarm_deploy[name.to_sym] ||= { environment: {} }
367
+ swarm = @swarm_deploy[name.to_sym] ||= { environment: {}, options: {} }
362
368
  swarm.merge! opts
363
369
  SwarmFunction.new(swarm, &) if block_given?
364
370
  end
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  class Stack
3
- VERSION = '0.0.78'
3
+ VERSION = '0.0.79'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.78
4
+ version: 0.0.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B