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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c7eaa8d84c009896dfc9bc3e68cd2f98c85045fe
4
- data.tar.gz: 952d74292f13f8b8db7eadea39f0d6631780c2eb
3
+ metadata.gz: 7aeb45fb5a76a1849fa9c9917499b282d803b33c
4
+ data.tar.gz: b261cf656d12ce56f54d8caea8ee57a58e363920
5
5
  SHA512:
6
- metadata.gz: 518bb82a01b507509380df30ec02b722ea60f755b82cb6429805f0fd395dcf8a6b3afb741b51ea790692d0022a611b2494705e710112e9d9af5c0f6ee0dea4f9
7
- data.tar.gz: cb118a34499833de5245f6aebb1d2cdc7fbac85949d6827346035306c928469ebc34e4b837b03c1ad4b7a876a541fb54ecb894c789be870247c8c3cbd719070d
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(platform_service, url_template)
80
- services = PlatformSH::config["relationships"].select {|k,v| v[0]["service"]==platform_service}
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 #{platform_service}"
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 #{platform_service}, giving up, set configuration by hand"
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("elasticsearch", "http://%{host}:%{port}")
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("rabbitmq","amqp://%{username}:%{password}@%{host}:%{port}")
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("postgresql","postgresql://%{username}:%{password}@%{host}:%{port}")
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("influxdb","http://%{host}:%{port}")
130
+ self.guess_url("http","http://%{host}:%{port}", 8086)
130
131
  end
131
132
 
132
133
  def self.export_services_urls
@@ -1,3 +1,3 @@
1
1
  class PlatformSH
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platform_sh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ori Pekelman