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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b85cfaf1c36435fe45442d752db4af3cd369fd6a2fd81cdace143bec6a65e8a
4
- data.tar.gz: c070646158a61e2a19f4c017f13afd8e8a411bd8900098355e10a9813f0e58a5
3
+ metadata.gz: 1a5ba425df34f2e4411f349405fc1bbaffa2dc77728b32539f65b0d9fdc06318
4
+ data.tar.gz: 8d38be2e1cf2b67d46a383789106bb375db387be71800696ef5e1d27d2f2476b
5
5
  SHA512:
6
- metadata.gz: f46ab3c6660d66ace5c5c53b7f7fb55a8a9a1135e8a54f41e9731e798518ca4e67893f39a9434f71721fbb21b9a5db1d9102cde3849211a2473e1485d589a46a
7
- data.tar.gz: 5d4465001902e64df88e130f04a9a49cdc899e01cddc1b931155dad608c662c762e69f693127f28abca2b2b22777379ed8381a4688c94160a09ac8842364a685
6
+ metadata.gz: 2eb5688890bfac5f346de7a8afd87339dc4d9745861082fd7d7d5aa810fa0a6b96b0a284fcd510786ae0138aacc33bfd2ebaea9a6a711e08a4fc480f27273f52
7
+ data.tar.gz: f89e8608ae262f6dff7305b4080abff88ca4dac4f041512c096e88d91b0c17cbd8a1efb9a296a341531d334928995f9d46912ddb1585fee17ab34b3d8fc6e46e
data/cloudenv-hq.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'cloudenv-hq'
3
- s.version = '0.2.5'
3
+ s.version = '0.2.6'
4
4
  s.license = 'MIT'
5
5
  s.date = '2020-10-10'
6
6
  s.summary = 'Keep your ENV vars synced between your team members'
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.5'.freeze
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
- until File.exist?(@secret_key) || @secret_key.expand_path == Pathname.new('/.cloudenv-secret-key')
19
- @secret_key = @secret_key.parent.parent + @secret_key_filename
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 File.exist?(@secret_key)
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')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudenv-hq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson