capistrano-consul_kv_lock 0.2.2 → 0.3.1

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
  SHA1:
3
- metadata.gz: 054025d77f91b796cce6adc6a0e0c142da62d75b
4
- data.tar.gz: 838748f9450e7bfc29dc251b1e2d28620c9d37fb
3
+ metadata.gz: 4bf44fabccbfc651c90fe736d86d43482637988a
4
+ data.tar.gz: 9fb2c1d41f8fe68929dbb66cd066235cca84c6dc
5
5
  SHA512:
6
- metadata.gz: 915ac3ee71d21d003800496b0d2d2723889a8f9f542d792dcf5bc4a90d9d8c07c421d301079028b7122dc5d671a5202920f618c650dc4f56944ca830001232ed
7
- data.tar.gz: 4cd3ca73cf866b8f0d1272611a4a05085135a56b8f643162db4bfc90554c857b66708fb6bb2928bcfe6fd3e1dce6263df2410f7511098a01462bde68a28b45b4
6
+ metadata.gz: e859f7cb88484826a2a9ef6ca1aef7f7fc892fe6d9ea63f76e6c2943f65fb150e9f20667a8c80d400546ccdfd9ab267977a1239704f4f54850dace59c9fb83f1
7
+ data.tar.gz: 1ae576c9efddb295121b622333e39ca82ea0beddc41abcaeba3ba3b386be65633841dfb79cc15bcff3359de5e46055a3f1ee3b21fbcd5a61b429aa5d6f03ef33
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "capistrano", ">= 3"
22
- spec.add_dependency "consul-client"
22
+ spec.add_dependency "diplomat"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
@@ -1,3 +1,5 @@
1
+ require 'diplomat'
2
+
1
3
  module Capistrano
2
4
  module ConsulKvLock
3
5
  class SSHKittyLogger
@@ -30,14 +32,11 @@ module Capistrano
30
32
  end
31
33
 
32
34
  def initialize(consul_url, options={})
33
- @client = begin
34
- consul = URI.parse(consul_url)
35
- Consul::Client.v1.http(host: consul.host, port: consul.port, logger: logger)
36
- end
35
+ Diplomat.configuration.url = consul_url
37
36
  @lock_key = options[:consul_lock_key] || 'deployment/locked'
38
37
  @session_id = nil
39
38
  end
40
- attr_reader :client, :lock_key
39
+ attr_reader :lock_key
41
40
 
42
41
  def logger
43
42
  self.class.logger
@@ -51,9 +50,8 @@ module Capistrano
51
50
  end
52
51
 
53
52
  def locked?
54
- r = client.get("/kv/#{lock_key}")
55
- !!(Base64.decode64(r[0]['Value']) =~ /\A["'](t(rue)?|1|y(es)?)["']\z/)
56
- rescue Consul::Client::ResponseException => e
53
+ !!(Diplomat::Kv.get(lock_key) =~ /\A["'](t(rue)?|1|y(es)?)["']\z/)
54
+ rescue => e
57
55
  # in case of 404
58
56
  if e.message.include?('404')
59
57
  return false
@@ -64,23 +62,22 @@ module Capistrano
64
62
 
65
63
  def create_session
66
64
  logger.debug "Session request: #{session_request.inspect}"
67
- r = client.put("/session/create", session_request)
68
- @session_id = r['ID']
65
+ @session_id = Diplomat::Session.create(session_request)
69
66
  end
70
67
 
71
68
  def delete_session
72
69
  with_session {
73
- client.put("/session/destroy/#{@session_id}", "")
70
+ Diplomat::Session.destroy(@session_id)
74
71
  }
75
72
  @session_id = nil
76
73
  end
77
74
 
78
75
  def lock
79
- with_session { client.put("/kv/#{lock_key}?acquire=#{@session_id}", "true") }
76
+ with_session { Diplomat::Lock.acquire(lock_key, @session_id, "true") }
80
77
  end
81
78
 
82
79
  def unlock
83
- with_session { client.put("/kv/#{lock_key}?release=#{@session_id}", "false") }
80
+ with_session { Diplomat::Lock.release(lock_key, @session_id) }
84
81
  end
85
82
 
86
83
  private
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module ConsulKvLock
3
- VERSION = "0.2.2"
3
+ VERSION = "0.3.1"
4
4
  end
5
5
  end
@@ -1,8 +1,3 @@
1
- require 'uri'
2
- require 'base64'
3
-
4
- require 'consul/client'
5
-
6
1
  namespace :consul_kv_lock do
7
2
  def latch
8
3
  Capistrano::ConsulKvLock::Latch.instance || \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-consul_kv_lock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio KONDO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-17 00:00:00.000000000 Z
11
+ date: 2016-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: consul-client
28
+ name: diplomat
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.2.3
108
+ rubygems_version: 2.4.5.1
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Introduces deployment lock using consul KVS