platform_sh 0.2.7 → 0.2.8

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
- SHA1:
3
- metadata.gz: 7aeb45fb5a76a1849fa9c9917499b282d803b33c
4
- data.tar.gz: b261cf656d12ce56f54d8caea8ee57a58e363920
2
+ SHA256:
3
+ metadata.gz: fe97479e3a48a0e81274343bcd1a879a47924549207bbf35216d4e8e3ddfd78a
4
+ data.tar.gz: 459317e327b61bcf6ce794d7fad6a76c7ecdef9582fe8522dc417a427adb0854
5
5
  SHA512:
6
- metadata.gz: 853c31801c2445a14ed4e5e132d6251fb8b90463775e39f27fdf2a26bb74af89e20a2eaa46a5bdd07bf3dba1767f0474aa12d04852d98b02d35293dfc69d585c
7
- data.tar.gz: 063cddeeb559054cd891ec84d8d96d8874b9b27b6cdda70f3e9cb0613eded2c0eb5cf7afaf4d884ea26bbfa32944c0ba23a4af50d2f56adee40fb1c121bd84b4
6
+ metadata.gz: 70c1ffc94864a2e72a1f4d57dfddf2646991c303a434091ab7c80dd11291406dbee9051dda99d7bd894ea688af5b11714e99d738719437c2b4ad0d30069ca329
7
+ data.tar.gz: 3fb1b4a8158bce8287c501e1b80d8e4d4da98ab2db73e6e132d245368a83f457bf8ac3f32bee71b59642c9ae6226b189d702c9927ef2b034f2e393986dcf6d49
@@ -2,6 +2,7 @@ require "platform_sh/version"
2
2
  require "base64"
3
3
  require 'json'
4
4
  require 'logger'
5
+ require 'uri'
5
6
 
6
7
  $logger = Logger.new(STDOUT)
7
8
  $logger.level = Logger::WARN
@@ -13,6 +14,7 @@ class PlatformSH
13
14
  if on_platform?
14
15
  conf = {}
15
16
  conf["application"] = read_base64_json('PLATFORM_APPLICATION')
17
+ conf["routes"] = read_base64_json('PLATFORM_ROUTES')
16
18
  conf["application_name"] =ENV["PLATFORM_APPLICATION_NAME"] || nil
17
19
  conf["app_dir"] =ENV["PLATFORM_APP_DIR"] || nil
18
20
  conf["project"] =ENV["PLATFORM_PROJECT"] || nil
@@ -60,6 +62,24 @@ class PlatformSH
60
62
  JSON.parse(File.read('/run/config.json'))
61
63
  end
62
64
 
65
+ #Tries to guess the hostname it takes the first upstream
66
+ def self.guess_hostname
67
+ upstreams = PlatformSH::config["routes"].select {|k,v| v["type"]=="upstream"}
68
+ begin
69
+ if upstreams.length > 1
70
+ $logger.info "More than one upstream. Picking first in list."
71
+ end
72
+ if upstreams.length > 0
73
+ return URI.parse(upstreams.keys[0]).host
74
+ else
75
+ $logger.error "Found no upstreams in PLATFORM_ROUTES"
76
+ return nil
77
+ end
78
+ rescue Exception => e
79
+ $logger.error "Error encountered while guessing hostname. #{e.message}"
80
+ return nil
81
+ end
82
+ end
63
83
 
64
84
  #Tries to guess relational database url
65
85
  def self.guess_database_url
@@ -1,3 +1,3 @@
1
1
  class PlatformSH
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platform_sh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ori Pekelman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2018-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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.6.13
108
+ rubygems_version: 2.7.6
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Platform.sh helper gem to ease interacting with the environment