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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5ebf65f6db6234c39d5bfe0b4b6c0be4dc1a2528a361a497b3aa80d093b3e02
4
- data.tar.gz: 823bc35c24d568a2c76b4ed921e13e2ed6c9779a1deab5abcf22cc54bb97bc58
3
+ metadata.gz: 564df6a1d13aa1bee43bbeffe9df029c89efe2d258bba2f661564d11c208f473
4
+ data.tar.gz: '010148312840649614e0a764d8c0033fce189363ffd4229ffcb58baba6b9e053'
5
5
  SHA512:
6
- metadata.gz: 0eb24c92c82d33345308c66f430ffce14cad8fc841c212c9f9927f13c3273c9d66eff66f9dffe25ca7aad43e26a10b5cedda1fef1572b45ac23875490497e03c
7
- data.tar.gz: 829f7596fda69391400a2166256632c2e4b5516cf6b07ae445a7c7eb49c24c90e8df80cc9558424b2dc9d3e6f36a33fc0e2abb56eb82be89fac18f262dd17a30
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
- if params[:context_endpoint]
13
- name = params[:context_endpoint].gsub( /[\/.:@]/,'_').gsub( '__','_')
14
- name = "dry-#{name}".to_sym
15
- endpoint = params[:context_endpoint]
16
- contexts = {}
17
- exec_o_lines 'docker context ls --format json' do |line|
18
- ctx = JSON.parse line, symbolize_names: true
19
- contexts[ctx[:Name].to_sym] = ctx # {"Current":false,"Description":"","DockerEndpoint":"ssh://root@x.x.x.x","Error":"","Name":"prod-swarm"}
20
- end
21
-
22
- if contexts[name] && contexts[name][:DockerEndpoint] != endpoint
23
- raise "context '#{name}' has different host value: #{contexts[name][:DockerEndpoint]} != #{endpoint}"
24
- end
25
-
26
- exec_i "docker context create #{name} --docker host=#{endpoint}" unless contexts[name]
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} #{extra}", yaml
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'"
@@ -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] ||= {environment: {}, deploy: {labels: []}, networks: {}}
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
@@ -1,5 +1,5 @@
1
1
  module Dry
2
2
  class Stack
3
- VERSION = '0.1.16'
3
+ VERSION = '0.1.17'
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.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Artyom B