dry-stack 0.1.16 → 0.1.17
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_swarm_deploy.rb +20 -18
- data/lib/dry-stack/stack.rb +6 -1
- 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: 564df6a1d13aa1bee43bbeffe9df029c89efe2d258bba2f661564d11c208f473
|
4
|
+
data.tar.gz: '010148312840649614e0a764d8c0033fce189363ffd4229ffcb58baba6b9e053'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4e90f05692e8660643c869fbe6bbabaa64d51a517b7ceff61c6dac9cc9981956642251950bf03f58326b8eaf9e31286438f7c570ff4d6fc42349177f15d7410
|
7
|
+
data.tar.gz: 0bfb77155f6bbf2e8ace9fcb00998073c0c09895420f17adef5785e5ff61166e7f67c808a84e88c77652ccfee93a53ee1b90047fcd4b5ea4176453d13324bb94
|
@@ -9,31 +9,33 @@ 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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
ENV['DOCKER_CONTEXT'] = name.to_s
|
12
|
+
raise 'Context endpoint required' unless params[:context_endpoint]
|
13
|
+
|
14
|
+
name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_')
|
15
|
+
name = "dry-#{name}".to_sym
|
16
|
+
endpoint = params[:context_endpoint]
|
17
|
+
$stdout.puts "Looking for docker context '#{name}'"
|
18
|
+
|
19
|
+
contexts = {}
|
20
|
+
exec_o_lines 'docker context ls --format json' do |line|
|
21
|
+
ctx = JSON.parse line, symbolize_names: true
|
22
|
+
contexts[ctx[:Name].to_sym] = ctx # {"Current":false,"Description":"","DockerEndpoint":"ssh://root@x.x.x.x","Error":"","Name":"prod-swarm"}
|
23
|
+
end
|
24
|
+
|
25
|
+
if contexts[name] && contexts[name][:DockerEndpoint] != endpoint
|
26
|
+
raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}"
|
29
27
|
end
|
30
28
|
|
29
|
+
exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name]
|
30
|
+
|
31
|
+
ENV['DOCKER_CONTEXT'] = name.to_s
|
32
|
+
|
31
33
|
# substitute ENV variables
|
32
34
|
yaml = stack.to_compose(_params).lines[1..].join
|
33
35
|
# system " echo \"#{yaml.gsub("`", '\\\`')}\" | docker stack deploy -c - #{stack.name} --prune --resolve-image changed"
|
34
36
|
|
35
37
|
# --prune --resolve-image changed
|
36
|
-
exec_i "docker stack deploy -c - #{stack.name}
|
38
|
+
exec_i "docker stack deploy -c - --with-registry-auth #{extra}" #{stack.name} , yaml
|
37
39
|
system "docker config rm $(docker config ls --filter label=com.docker.stack.namespace=#{stack.name} --format \"{{.ID}}\")"
|
38
40
|
|
39
41
|
exec_i "docker config rm #{stack.name}_readme || echo 'failed to remove config #{stack.name}_readme'"
|
data/lib/dry-stack/stack.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative 'apache_specific_md5'
|
|
15
15
|
|
16
16
|
module Dry
|
17
17
|
EMPTY_HASH = :empty_hash
|
18
|
+
DEFAULT_INIT_SERVICE = true # add "init: true" option
|
18
19
|
|
19
20
|
class ::Hash
|
20
21
|
def deep_merge!(second)
|
@@ -381,7 +382,11 @@ module Dry
|
|
381
382
|
opts[:ports] = [opts[:ports]].flatten if opts.key? :ports
|
382
383
|
opts[:environment] = opts.delete(:env) if opts.key? :env
|
383
384
|
|
384
|
-
service = @services[name.to_sym] ||=
|
385
|
+
service = @services[name.to_sym] ||= begin
|
386
|
+
s = {environment: {}, deploy: {labels: []}, networks: {}}
|
387
|
+
DEFAULT_INIT_SERVICE ? s.merge(init: true) : s
|
388
|
+
end
|
389
|
+
|
385
390
|
service.deep_merge! opts
|
386
391
|
ServiceFunction.new(service, &) if block_given?
|
387
392
|
end
|
data/lib/version.rb
CHANGED