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 +4 -4
- data/lib/dry-stack/command_compose.rb +2 -2
- data/lib/dry-stack/stack.rb +8 -2
- data/lib/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8823f4774a66a511374052a8358d1f55b5fdd9828fe5de1805078ca2d6ed6e6f
|
4
|
+
data.tar.gz: 92c42ce074daa1565f3b927eeee50c90721741be2ec1748c220016d53c5e21a7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 "
|
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("`", '\\\`')}\"")
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -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