aggkit 0.3.6 → 0.3.7

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: c156f847b57ffb06d37850c4119c7503da301329100855a826db70827aad4d48
4
- data.tar.gz: 91bc2e8238ae3075be4cf2dd095ac2369a7cf0d917903c149fda4f38c4ed8074
3
+ metadata.gz: 69e17d1ded80e27c4244257dc58e1afc16a42dca6c77f25a5f8d1197f8eb2268
4
+ data.tar.gz: 77d0b795fc18f949a6192b90977d8d039615ea673cda1265f6306406bfeadb61
5
5
  SHA512:
6
- metadata.gz: d875af24df50d76c408d15bf827f3173fb506d2e4fb1e6d932f8d220c1fda159b2a70e087a38809ce1febb57a5582205bd46879596d643b4c28456fc7bf7be84
7
- data.tar.gz: 8970df7a2b695a6b8eb45e6a672e69d6e45e498ae15c83bf3a6b8e8eaafc78c756af6014acf0d0689d5f13e2ca64ebbcc51841fb79448de6e0ce46ae2c858012
6
+ metadata.gz: 0df85c38a96fbb362d9e2affc50675691bdce2dd42c605e3de27bbc6cf2c3aad0faacdc3071f7f7b63a4f085843fcb033bcaab1a9c72c04258f597f8d92b9eb4
7
+ data.tar.gz: abc055cf5ed28dfc5e75d0d81a8584131f1748a3daf23817a377e110d24c16367692c273e37dfad6b0d6003a3d90fbbb910f8ea99b16d3c800f93646adfa4f95
data/Gemfile CHANGED
@@ -3,9 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in aggredator.gemspec
4
4
  gemspec
5
5
 
6
- gem 'diplomat', git: 'https://github.com/RnD-Soft/diplomat.git', branch: 'master'
7
-
8
-
9
6
  group :test do
10
7
  gem 'awesome_print'
11
8
  gem 'rspec'
data/bin/aggconsul CHANGED
@@ -8,7 +8,13 @@ require 'yaml'
8
8
  STDOUT.sync = true
9
9
  STDERR.sync = true
10
10
 
11
- @opts = {}
11
+ if ENV['CONSUL_HTTP_ADDR'].to_s.empty?
12
+ ENV['CONSUL_HTTP_ADDR'] = "http://#{ENV['CONSUL_HOST'] || 'localhost'}:8500"
13
+ end
14
+
15
+ @opts = {
16
+ consul: ENV['CONSUL_HTTP_ADDR']
17
+ }
12
18
 
13
19
  @opts[:exec] = (begin
14
20
  ARGV.join(' ').split(' -- ')[1].strip
@@ -19,10 +25,14 @@ STDERR.sync = true
19
25
  parser = OptionParser.new do |o|
20
26
  o.banner = 'Usage: consul.rb [options] -- exec'
21
27
 
22
- o.on('--consul url', 'Set up a custom Consul URL') do |url|
23
- Diplomat.configure do |config|
24
- config.url = url.strip
28
+ o.on('--consul url', 'Set up a custom Consul URL') do |consul|
29
+ if consul.to_s['http']
30
+ ENV['CONSUL_HTTP_ADDR'] = consul.to_s
31
+ else
32
+ ENV['CONSUL_HTTP_ADDR'] = "http://#{consul.to_s}:8500"
25
33
  end
34
+
35
+ @opts[:consul] = ENV['CONSUL_HTTP_ADDR']
26
36
  end
27
37
 
28
38
  o.on('--token token', 'Connect into consul with custom access token (ACL)') do |token|
@@ -79,6 +89,10 @@ parser = OptionParser.new do |o|
79
89
  end
80
90
  parser.parse!
81
91
 
92
+ Diplomat.configure do |config|
93
+ config.url = @opts[:consul]
94
+ end
95
+
82
96
  def die(message)
83
97
  STDERR.puts "Error: #{message}"
84
98
  exit 1
data/bin/aggwrap CHANGED
@@ -54,10 +54,14 @@ STDOUT.sync
54
54
 
55
55
  UTIL = File.basename(__FILE__)
56
56
 
57
+ if ENV['CONSUL_HTTP_ADDR'].to_s.empty?
58
+ ENV['CONSUL_HTTP_ADDR'] = "http://#{ENV['CONSUL_HOST'] || 'localhost'}:8500"
59
+ end
60
+
57
61
  @opts = {
58
62
  service: ENV['AGGREDATOR_SERVICE'],
59
63
  id: SecureRandom.hex(8),
60
- consul: ENV['CONSUL_HTTP_ADDR'] || ENV['CONSUL_HOST'] || 'localhost'
64
+ consul: ENV['CONSUL_HTTP_ADDR'],
61
65
  }
62
66
 
63
67
  @opts[:exec] = (begin
@@ -79,10 +83,13 @@ parser = Aggkit::OptionParser.new do |o|
79
83
  end
80
84
 
81
85
  o.on("--consul=#{@opts[:consul]}", 'Set consul host. CONSUL_HOST env used when missed') do |consul|
82
- @opts[:consul] = consul.to_s
83
- Diplomat.configure do |config|
84
- config.url = @opts[:consul]
86
+ if consul.to_s['http']
87
+ ENV['CONSUL_HTTP_ADDR'] = consul.to_s
88
+ else
89
+ ENV['CONSUL_HTTP_ADDR'] = "http://#{consul.to_s}:8500"
85
90
  end
91
+
92
+ @opts[:consul] = ENV['CONSUL_HTTP_ADDR']
86
93
  end
87
94
 
88
95
  o.on('--http <PORT>', 'Create TTL consul check and pass http result to it') do |port|
@@ -107,6 +114,11 @@ die 'service name must be provided' if @opts[:service].to_s.empty?
107
114
 
108
115
  die 'script must be provided' if @opts[:exec].empty?
109
116
 
117
+
118
+ Diplomat.configure do |config|
119
+ config.url = @opts[:consul]
120
+ end
121
+
110
122
  SERVICE_ID = "#{@opts[:service]}_#{@opts[:id]}".freeze
111
123
 
112
124
  @service = {
data/lib/aggkit/runner.rb CHANGED
@@ -36,7 +36,12 @@ module Aggkit
36
36
  end
37
37
 
38
38
  def load_envs_from_consul(consul, service)
39
- envs = execute!("aggconsul --consul=http://#{consul}:8500 --env services/env/#{service} --pristine -d", "Can't load envs")
39
+ consul_http = consul['http']
40
+ consul
41
+ else
42
+ "http://#{consul}:8500"
43
+ end
44
+ envs = execute!("aggconsul --consul=#{consul_http} --env services/env/#{service} --pristine -d", "Can't load envs")
40
45
  load_envs(envs)
41
46
  end
42
47
 
@@ -1,6 +1,6 @@
1
1
  module Aggkit
2
2
 
3
- VERSION = '0.3.6'.freeze
3
+ VERSION = '0.3.7'.freeze
4
4
 
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Godko Ivan