cloudenv-hq 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cloudenv-hq.gemspec +1 -1
- data/lib/cloudenv-hq.rb +22 -13
- 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: 1a5ba425df34f2e4411f349405fc1bbaffa2dc77728b32539f65b0d9fdc06318
|
4
|
+
data.tar.gz: 8d38be2e1cf2b67d46a383789106bb375db387be71800696ef5e1d27d2f2476b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eb5688890bfac5f346de7a8afd87339dc4d9745861082fd7d7d5aa810fa0a6b96b0a284fcd510786ae0138aacc33bfd2ebaea9a6a711e08a4fc480f27273f52
|
7
|
+
data.tar.gz: f89e8608ae262f6dff7305b4080abff88ca4dac4f041512c096e88d91b0c17cbd8a1efb9a296a341531d334928995f9d46912ddb1585fee17ab34b3d8fc6e46e
|
data/cloudenv-hq.gemspec
CHANGED
data/lib/cloudenv-hq.rb
CHANGED
@@ -4,32 +4,41 @@ require 'tempfile'
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
class CloudenvHQ
|
7
|
-
VERSION = '0.2.
|
7
|
+
VERSION = '0.2.6'.freeze
|
8
8
|
|
9
9
|
API_HOST = 'https://app.cloudenv.com'.freeze
|
10
10
|
READ_PATH = '/api/v1/envs'.freeze
|
11
11
|
|
12
12
|
def initialize(options = {})
|
13
13
|
@environment = ENV['RAILS_ENV'] || ENV['RACK_ENV']
|
14
|
-
@bearer = ENV['CLOUDENV_BEARER_TOKEN'] || `cat #{options[:bearer] || '~/.cloudenvrc'}`.strip
|
15
|
-
@secret_key_filename = '.cloudenv-secret-key'
|
16
|
-
@secret_key = Pathname.new(@secret_key_filename)
|
17
14
|
|
18
|
-
|
19
|
-
@
|
15
|
+
if ENV['CLOUDENV_BEARER_TOKEN'] || options[:bearer]
|
16
|
+
@bearer = ENV['CLOUDENV_BEARER_TOKEN'] || options[:bearer]
|
17
|
+
else
|
18
|
+
@bearer_filename = File.expand_path(ENV['CLOUDENV_BEARER_FILE'] || '~/.cloudenvrc')
|
19
|
+
@bearer = IO.read(@secret_key).strip if File.exist?(@bearer_filename)
|
20
20
|
end
|
21
21
|
|
22
|
-
if
|
23
|
-
data = YAML.safe_load(IO.read(@secret_key))
|
24
|
-
|
25
|
-
@app = data['slug']
|
26
|
-
@secret_key = data['secret-key']
|
27
|
-
else
|
22
|
+
if ENV['CLOUDENV_APP_SLUG'] && ENV['CLOUDENV_APP_SECRET_KEY']
|
28
23
|
@app = ENV['CLOUDENV_APP_SLUG']
|
29
24
|
@secret_key = ENV['CLOUDENV_APP_SECRET_KEY']
|
25
|
+
else
|
26
|
+
@secret_key_filename = File.expand_path(ENV['CLOUDENV_APP_SECRET_KEY_FILE'] || '.cloudenv-secret-key')
|
27
|
+
@secret_key = Pathname.new(@secret_key_filename)
|
28
|
+
|
29
|
+
until File.exist?(@secret_key) || @secret_key.expand_path == Pathname.new('/.cloudenv-secret-key')
|
30
|
+
@secret_key = @secret_key.parent.parent + @secret_key_filename
|
31
|
+
end
|
32
|
+
|
33
|
+
if File.exist?(@secret_key)
|
34
|
+
data = YAML.safe_load(IO.read(@secret_key))
|
35
|
+
|
36
|
+
@app = data['slug']
|
37
|
+
@secret_key = data['secret-key']
|
38
|
+
end
|
30
39
|
end
|
31
40
|
|
32
|
-
if @app && @secret_key
|
41
|
+
if @bearer && @app && @secret_key
|
33
42
|
if @environment
|
34
43
|
data = `curl -s -H "Authorization: Bearer #{@bearer}" "https://app.cloudenv.com/api/v1/envs?name=#{@app}&environment=#{@environment}&version=#{VERSION}&lang=ruby" | openssl enc -a -aes-256-cbc -md sha512 -d -pass pass:"#{@secret_key}" 2> /dev/null`
|
35
44
|
file = Tempfile.new('cloudenv')
|