platform_sh 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/platform_sh.rb +9 -8
- data/lib/platform_sh/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aeb45fb5a76a1849fa9c9917499b282d803b33c
|
4
|
+
data.tar.gz: b261cf656d12ce56f54d8caea8ee57a58e363920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853c31801c2445a14ed4e5e132d6251fb8b90463775e39f27fdf2a26bb74af89e20a2eaa46a5bdd07bf3dba1767f0474aa12d04852d98b02d35293dfc69d585c
|
7
|
+
data.tar.gz: 063cddeeb559054cd891ec84d8d96d8874b9b27b6cdda70f3e9cb0613eded2c0eb5cf7afaf4d884ea26bbfa32944c0ba23a4af50d2f56adee40fb1c121bd84b4
|
data/lib/platform_sh.rb
CHANGED
@@ -76,23 +76,24 @@ class PlatformSH
|
|
76
76
|
return mysql_url || postgresql_url
|
77
77
|
end
|
78
78
|
|
79
|
-
def self.guess_url(
|
80
|
-
services = PlatformSH::config["relationships"].select {|k,v| v[0]["
|
79
|
+
def self.guess_url(scheme, url_template, port=nil)
|
80
|
+
services = PlatformSH::config["relationships"].select {|k,v| v[0]["scheme"]==scheme && (!port || v[0]["port"].to_s==port.to_s )} #For ElasticSearch and InfluxDB both on HTTP we also look at the port
|
81
81
|
case services.length
|
82
82
|
when 0
|
83
|
-
$logger.info "Could not find an #{
|
83
|
+
$logger.info "Could not find an #{scheme}"
|
84
84
|
return nil
|
85
85
|
when 1
|
86
86
|
service = services.first[1][0]
|
87
87
|
service = service.each_with_object({}){|(k,v), h| h[k.to_sym] = v} #keys need to be symbols
|
88
88
|
return url_template % service
|
89
89
|
else
|
90
|
-
$logger.warn "More than one #{
|
90
|
+
$logger.warn "More than one #{scheme}, giving up, set configuration by hand"
|
91
|
+
return nil
|
91
92
|
end
|
92
93
|
end
|
93
94
|
|
94
95
|
def self.guess_elasticsearch_url
|
95
|
-
self.guess_url("
|
96
|
+
self.guess_url("http", "http://%{host}:%{port}",9200)
|
96
97
|
end
|
97
98
|
|
98
99
|
def self.guess_redis_url
|
@@ -118,15 +119,15 @@ class PlatformSH
|
|
118
119
|
end
|
119
120
|
|
120
121
|
def self.guess_rabbitmq_url
|
121
|
-
self.guess_url("
|
122
|
+
self.guess_url("amqp","amqp://%{username}:%{password}@%{host}:%{port}")
|
122
123
|
end
|
123
124
|
|
124
125
|
def self.guess_postgresql_url
|
125
|
-
self.guess_url("
|
126
|
+
self.guess_url("pgsql","postgresql://%{username}:%{password}@%{host}:%{port}")
|
126
127
|
end
|
127
128
|
|
128
129
|
def self.guess_influxdb_url
|
129
|
-
self.guess_url("
|
130
|
+
self.guess_url("http","http://%{host}:%{port}", 8086)
|
130
131
|
end
|
131
132
|
|
132
133
|
def self.export_services_urls
|
data/lib/platform_sh/version.rb
CHANGED