gp-ruby-client 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gp-ruby-client.rb +3 -3
- data/lib/service_account.rb +19 -12
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c015def523f8f5b042d248552563b6d747a3abe
|
4
|
+
data.tar.gz: e76b774ec48bfa43d0192f56c1e523319004aedb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 472bd77b6a4e72d45e426eb39c0ce5d75144c2cdd2decb70a562b87e1a4be5aa7c7498a3954a88af7623fcbaefac039b17ab6dc21b9632566f71ccaffcc7606a
|
7
|
+
data.tar.gz: 6f29eb94f4b2790fcd0c77381a2f859dd73e2a674731a53f16f3baeb8cc268c78cb14b863cbe374ce66fb6ce2570b983fd0a4f919dc9588458f720ea6483245b
|
data/lib/gp-ruby-client.rb
CHANGED
@@ -44,8 +44,8 @@ module GP
|
|
44
44
|
@@just_started = true
|
45
45
|
@@use_service = true
|
46
46
|
|
47
|
-
def initialize(bundle_id)
|
48
|
-
|
47
|
+
def initialize(bundle_id, srvc_account=ServiceAccount.new)
|
48
|
+
@@bundle_id = bundle_id
|
49
49
|
|
50
50
|
if @@use_service && (Time.now - @@cache_control.get_last_accessed_time >= @@cache_control.get_ttl || @@just_started)
|
51
51
|
@@just_started = false
|
@@ -54,7 +54,7 @@ module GP
|
|
54
54
|
backend = {}
|
55
55
|
I18n.backend = I18n::Backend::Chain.new(I18n::Backend::KeyValue.new(backend), I18n.backend)
|
56
56
|
|
57
|
-
@@service_account =
|
57
|
+
@@service_account = srvc_account
|
58
58
|
if @@service_account.nil?
|
59
59
|
raise "No valid service account"
|
60
60
|
end
|
data/lib/service_account.rb
CHANGED
@@ -91,14 +91,17 @@ class ServiceAccount
|
|
91
91
|
|
92
92
|
def initialize(url_string = "", user_id = "", pwd = "", instance_id = "", api_key="", credsFilePath = "")
|
93
93
|
|
94
|
-
if !url_string.
|
94
|
+
if !url_string.nil? && !url_string.empty? &&
|
95
|
+
!user_id.nil? && !user_id.empty? &&
|
96
|
+
!pwd.nil? && !pwd.empty? &&
|
97
|
+
!instance_id.nil? && !instance_id.empty?
|
95
98
|
@url_string = url_string
|
96
99
|
@user_id = user_id
|
97
100
|
@pwd = pwd
|
98
101
|
@instance_id = instance_id
|
99
102
|
@iam_enabled = false
|
100
103
|
|
101
|
-
elsif !url_string.empty? && !instance_id.empty? && !api_key.empty?
|
104
|
+
elsif !url_string.nil? && !url_string.empty? && !instance_id.nil? && !instance_id.empty? && !api_key.nil? && !api_key.empty?
|
102
105
|
@url_string = url_string
|
103
106
|
@instance_id = instance_id
|
104
107
|
@api_key = api_key
|
@@ -110,14 +113,18 @@ class ServiceAccount
|
|
110
113
|
account = get_service_account_via_vcap_service
|
111
114
|
end
|
112
115
|
if account.nil? && !credsFilePath.empty?
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
119
|
-
account = extractCredsFromJson(creds)
|
116
|
+
File.open(credsFilePath) do |credsFile|
|
117
|
+
creds = JSON.parse(credsFile.read)
|
118
|
+
if !creds.nil?
|
119
|
+
if creds.has_key?("credentials")
|
120
|
+
creds=creds["credentials"]
|
120
121
|
end
|
122
|
+
account = extractCredsFromJson(creds)
|
123
|
+
if account.nil?
|
124
|
+
raise "Couldn't create a service account from file"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
121
128
|
end
|
122
129
|
if account.nil?
|
123
130
|
raise "Couldn't create a service account"
|
@@ -196,7 +203,7 @@ private
|
|
196
203
|
return
|
197
204
|
end
|
198
205
|
|
199
|
-
iam_enabled=api_key.nil
|
206
|
+
iam_enabled=api_key.nil??false:true
|
200
207
|
|
201
208
|
return [url_string, user_id, pwd, instance_id, api_key, iam_enabled]
|
202
209
|
end
|
@@ -213,7 +220,7 @@ private
|
|
213
220
|
|
214
221
|
app_name = ""
|
215
222
|
json_vcap_services.each do |key, value|
|
216
|
-
if (key =~ APP_NAME_REGEX or
|
223
|
+
if (key =~ APP_NAME_REGEX or APP_NAME.eql? key)
|
217
224
|
app_name = key
|
218
225
|
break
|
219
226
|
end
|
@@ -239,7 +246,7 @@ private
|
|
239
246
|
if (user_id.nil? || pwd.nil?) && api_key.nil?
|
240
247
|
return
|
241
248
|
end
|
242
|
-
iam_enabled=api_key.nil
|
249
|
+
iam_enabled=api_key.nil??false:true
|
243
250
|
return [url, user_id, pwd, instance_id, api_key, iam_enabled]
|
244
251
|
end
|
245
252
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gp-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Visaahan Anandarajah
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby SDK for Globalization Pipeline on IBM Cloud
|
14
14
|
email: icuintl@us.ibm.com
|
@@ -24,7 +24,9 @@ files:
|
|
24
24
|
homepage: https://github.com/IBM-Cloud/gp-ruby-client
|
25
25
|
licenses:
|
26
26
|
- Apache-2.0
|
27
|
-
metadata:
|
27
|
+
metadata:
|
28
|
+
documentation_uri: https://github.com/IBM-Cloud/gp-ruby-client
|
29
|
+
source_code_uri: https://github.com/IBM-Cloud/gp-ruby-client
|
28
30
|
post_install_message:
|
29
31
|
rdoc_options: []
|
30
32
|
require_paths:
|