hekate 0.1.0.pre17 → 0.1.0.pre18

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: 69cd022959e65663fcc87c6d2df13f283a36322b
4
- data.tar.gz: 01d70b921e120d2b4ac81cbc72d06386b895e8a7
3
+ metadata.gz: 7fad00e55e891fe3c58593d84f97c1263b278ca1
4
+ data.tar.gz: f0c2b3bf40d00392bf1c8554da515e867a8ff102
5
5
  SHA512:
6
- metadata.gz: 0b4b05b72b32fb0272260ac12dbdc7878a04b9c330c3fc9916e9255fa00b1daf848fc39dbc8a8e35ecdd9dd07d7b30287a3e06ef4eb030c89c9a1f31cc594c75
7
- data.tar.gz: 8b6978a2b98314d0f8bcb89933f457b8814bb4695462f291e2f703e6927101ec0dd18690877072bd327615dc97238c69e6dae43131765d951df8564839f44be0
6
+ metadata.gz: 863c7291ae7fb62df27d9dab8b1488f56c145b60cf8f53b1d4b75ed85cbe1c1a6137489bb023686ed8073085b8dadb8e1a34eee2cffe34cde587c9d4d54fbe0c
7
+ data.tar.gz: d89652df57ae7bc9d61d080e86c47e73eaa82b7f3ff2dd91fbacf96d9a3269db0b91d7e2228443110e5b913acdcad2b17e03983c5612cdb96af03fbfca0e1b21
data/Gemfile.lock ADDED
@@ -0,0 +1,173 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hekate (0.1.0.pre18)
5
+ aws-sdk (~> 2.9.0, ~> 2.9)
6
+ commander (~> 4.4, >= 4.4.0)
7
+ dotenv (>= 2.2.1, >= 2.2)
8
+ ec2-metadata (~> 0.2, >= 0.2.0)
9
+ rails (~> 4)
10
+ railties (~> 4.2, >= 4.2.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ actionmailer (4.2.9)
16
+ actionpack (= 4.2.9)
17
+ actionview (= 4.2.9)
18
+ activejob (= 4.2.9)
19
+ mail (~> 2.5, >= 2.5.4)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ actionpack (4.2.9)
22
+ actionview (= 4.2.9)
23
+ activesupport (= 4.2.9)
24
+ rack (~> 1.6)
25
+ rack-test (~> 0.6.2)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ actionview (4.2.9)
29
+ activesupport (= 4.2.9)
30
+ builder (~> 3.1)
31
+ erubis (~> 2.7.0)
32
+ rails-dom-testing (~> 1.0, >= 1.0.5)
33
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
34
+ activejob (4.2.9)
35
+ activesupport (= 4.2.9)
36
+ globalid (>= 0.3.0)
37
+ activemodel (4.2.9)
38
+ activesupport (= 4.2.9)
39
+ builder (~> 3.1)
40
+ activerecord (4.2.9)
41
+ activemodel (= 4.2.9)
42
+ activesupport (= 4.2.9)
43
+ arel (~> 6.0)
44
+ activesupport (4.2.9)
45
+ i18n (~> 0.7)
46
+ minitest (~> 5.1)
47
+ thread_safe (~> 0.3, >= 0.3.4)
48
+ tzinfo (~> 1.1)
49
+ addressable (2.5.1)
50
+ public_suffix (~> 2.0, >= 2.0.2)
51
+ arel (6.0.4)
52
+ aws-sdk (2.9.44)
53
+ aws-sdk-resources (= 2.9.44)
54
+ aws-sdk-core (2.9.44)
55
+ aws-sigv4 (~> 1.0)
56
+ jmespath (~> 1.0)
57
+ aws-sdk-resources (2.9.44)
58
+ aws-sdk-core (= 2.9.44)
59
+ aws-sigv4 (1.0.1)
60
+ builder (3.2.3)
61
+ codecov (0.1.10)
62
+ json
63
+ simplecov
64
+ url
65
+ commander (4.4.3)
66
+ highline (~> 1.7.2)
67
+ concurrent-ruby (1.0.5)
68
+ crack (0.4.3)
69
+ safe_yaml (~> 1.0.0)
70
+ diff-lcs (1.3)
71
+ docile (1.1.5)
72
+ dotenv (2.2.1)
73
+ ec2-metadata (0.2.2)
74
+ erubis (2.7.0)
75
+ globalid (0.4.0)
76
+ activesupport (>= 4.2.0)
77
+ hashdiff (0.3.5)
78
+ highline (1.7.8)
79
+ i18n (0.8.6)
80
+ jmespath (1.3.1)
81
+ json (2.1.0)
82
+ loofah (2.0.3)
83
+ nokogiri (>= 1.5.9)
84
+ mail (2.6.6)
85
+ mime-types (>= 1.16, < 4)
86
+ mime-types (3.1)
87
+ mime-types-data (~> 3.2015)
88
+ mime-types-data (3.2016.0521)
89
+ mini_portile2 (2.2.0)
90
+ minitest (5.10.3)
91
+ nokogiri (1.8.0)
92
+ mini_portile2 (~> 2.2.0)
93
+ public_suffix (2.0.5)
94
+ rack (1.6.8)
95
+ rack-test (0.6.3)
96
+ rack (>= 1.0)
97
+ rails (4.2.9)
98
+ actionmailer (= 4.2.9)
99
+ actionpack (= 4.2.9)
100
+ actionview (= 4.2.9)
101
+ activejob (= 4.2.9)
102
+ activemodel (= 4.2.9)
103
+ activerecord (= 4.2.9)
104
+ activesupport (= 4.2.9)
105
+ bundler (>= 1.3.0, < 2.0)
106
+ railties (= 4.2.9)
107
+ sprockets-rails
108
+ rails-deprecated_sanitizer (1.0.3)
109
+ activesupport (>= 4.2.0.alpha)
110
+ rails-dom-testing (1.0.8)
111
+ activesupport (>= 4.2.0.beta, < 5.0)
112
+ nokogiri (~> 1.6)
113
+ rails-deprecated_sanitizer (>= 1.0.1)
114
+ rails-html-sanitizer (1.0.3)
115
+ loofah (~> 2.0)
116
+ railties (4.2.9)
117
+ actionpack (= 4.2.9)
118
+ activesupport (= 4.2.9)
119
+ rake (>= 0.8.7)
120
+ thor (>= 0.18.1, < 2.0)
121
+ rake (10.5.0)
122
+ rspec (3.6.0)
123
+ rspec-core (~> 3.6.0)
124
+ rspec-expectations (~> 3.6.0)
125
+ rspec-mocks (~> 3.6.0)
126
+ rspec-core (3.6.0)
127
+ rspec-support (~> 3.6.0)
128
+ rspec-expectations (3.6.0)
129
+ diff-lcs (>= 1.2.0, < 2.0)
130
+ rspec-support (~> 3.6.0)
131
+ rspec-mocks (3.6.0)
132
+ diff-lcs (>= 1.2.0, < 2.0)
133
+ rspec-support (~> 3.6.0)
134
+ rspec-support (3.6.0)
135
+ rspec_junit_formatter (0.3.0)
136
+ rspec-core (>= 2, < 4, != 2.12.0)
137
+ safe_yaml (1.0.4)
138
+ simplecov (0.15.0)
139
+ docile (~> 1.1.0)
140
+ json (>= 1.8, < 3)
141
+ simplecov-html (~> 0.10.0)
142
+ simplecov-html (0.10.2)
143
+ sprockets (3.7.1)
144
+ concurrent-ruby (~> 1.0)
145
+ rack (> 1, < 3)
146
+ sprockets-rails (3.2.1)
147
+ actionpack (>= 4.0)
148
+ activesupport (>= 4.0)
149
+ sprockets (>= 3.0.0)
150
+ thor (0.19.4)
151
+ thread_safe (0.3.6)
152
+ tzinfo (1.2.3)
153
+ thread_safe (~> 0.1)
154
+ url (0.3.2)
155
+ webmock (3.0.1)
156
+ addressable (>= 2.3.6)
157
+ crack (>= 0.3.2)
158
+ hashdiff
159
+
160
+ PLATFORMS
161
+ ruby
162
+
163
+ DEPENDENCIES
164
+ bundler (~> 1.15)
165
+ codecov (~> 0.1.0, ~> 0.1)
166
+ hekate!
167
+ rake (~> 10.0)
168
+ rspec (~> 3.0)
169
+ rspec_junit_formatter (~> 0.3.0)
170
+ webmock (~> 3.0.0, ~> 3.0)
171
+
172
+ BUNDLED WITH
173
+ 1.15.3
data/README.md CHANGED
@@ -41,7 +41,7 @@ The resulting environment settings would be
41
41
 
42
42
  ENV["SOMEKEY"] = stagingvalue
43
43
 
44
-
44
+
45
45
  ## Usage
46
46
  ### AWS Authentication
47
47
  Hekate requires AWS authentication in order to read or set parameters and assumes credentials are provided via one of the available amazon authentication methods. Please see amazon documentation for more details
@@ -103,6 +103,13 @@ Hekate Admin - read/write access for a parameter maintainer
103
103
  }
104
104
  ]
105
105
  }
106
+
107
+ ### Environment Configuration
108
+ Use the following environment settings to customize Hekate
109
+
110
+ ENV["HAKATE_DISABLE"] = any value - Disable hekate and fall back to .env files
111
+ ENV["HEKATE_SSM_TIMEOUT"] - float representing the the time to wait for a connection to SSM to be made. A timeout will result in hekate falling back to offline mode.
112
+
106
113
  ```
107
114
  ### Binary Commands
108
115
  Hekate provides a command line interface for reading and writing secrets to the parameter store. Note that it will automatically create an amazon kms key with the following naming convention as needed `application.environment`
data/lib/hekate/aws.rb CHANGED
@@ -2,8 +2,9 @@ require 'aws-sdk'
2
2
 
3
3
  module Hekate
4
4
  class Aws
5
- def initialize(region)
5
+ def initialize(region, environment)
6
6
  @region = region
7
+ @environment = environment
7
8
  end
8
9
 
9
10
  def get_parameter(name)
data/lib/hekate/engine.rb CHANGED
@@ -25,13 +25,15 @@ module Hekate
25
25
 
26
26
  def online?
27
27
  require 'socket'
28
- begin
29
- socket = TCPSocket.new 'ssm.us-east-1.amazonaws.com', 443
30
- socket.close
31
- true
32
- rescue SocketError
33
- false
34
- end
28
+
29
+ return false if ENV['HAKATE_DISABLE']
30
+
31
+ timeout = ENV.fetch('HEKATE_SSM_TIMEOUT') { 0.5 }
32
+ can_connect?(
33
+ 'ssm.us-east-1.amazonaws.com',
34
+ 443,
35
+ timeout
36
+ )
35
37
  end
36
38
 
37
39
  def root
@@ -49,6 +51,55 @@ module Hekate
49
51
  raise 'Could not find .env files while falling back to dotenv' if files.empty?
50
52
  files
51
53
  end
54
+
55
+ private
56
+
57
+ def can_connect?(host, port, timeout = 2)
58
+
59
+ # Convert the passed host into structures the non-blocking calls
60
+ # can deal with
61
+ addr = Socket.getaddrinfo(host, nil)
62
+ sockaddr = Socket.pack_sockaddr_in(port, addr[0][3])
63
+
64
+ result = false
65
+ Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0).tap do |socket|
66
+ socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
67
+
68
+ begin
69
+ # Initiate the socket connection in the background. If it doesn't fail
70
+ # immediatelyit will raise an IO::WaitWritable (Errno::EINPROGRESS)
71
+ # indicating the connection is in progress.
72
+ socket.connect_nonblock(sockaddr)
73
+
74
+ rescue IO::WaitWritable
75
+ # IO.select will block until the socket is writable or the timeout
76
+ # is exceeded - whichever comes first.
77
+ if IO.select(nil, [socket], nil, timeout)
78
+ begin
79
+ # Verify there is now a good connection
80
+ socket.connect_nonblock(sockaddr)
81
+ rescue Errno::EISCONN
82
+ # Good news everybody, the socket is connected!
83
+ result = true
84
+ rescue
85
+ # An unexpected exception was raised - the connection is no good.
86
+ socket.close
87
+ result = false
88
+ end
89
+ result = true
90
+ else
91
+ # IO.select returns nil when the socket is not ready before timeout
92
+ # seconds have elapsed
93
+ socket.close
94
+ result = false
95
+ end
96
+ rescue
97
+ result = false
98
+ end
99
+ end
100
+
101
+ result
102
+ end
52
103
  end
53
104
 
54
105
  def initialize(region, environment, application = nil)
@@ -58,7 +109,7 @@ module Hekate
58
109
  end
59
110
 
60
111
  def awsclient
61
- @awsclient ||= Hekate::Aws.new(@region)
112
+ @awsclient ||= Hekate::Aws.new(@region, @environment)
62
113
  end
63
114
 
64
115
  def load_environment
@@ -1,3 +1,3 @@
1
1
  module Hekate
2
- VERSION = '0.1.0.pre17'.freeze
2
+ VERSION = '0.1.0.pre18'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hekate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre17
4
+ version: 0.1.0.pre18
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasonrisch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -234,6 +234,7 @@ files:
234
234
  - ".rspec"
235
235
  - CODE_OF_CONDUCT.md
236
236
  - Gemfile
237
+ - Gemfile.lock
237
238
  - LICENSE.txt
238
239
  - README.md
239
240
  - Rakefile