Skip to content

Commit f9cfc8a

Browse files
authored
Merge pull request #11 from IBM-Swift/obj-store
Added Object storage
2 parents 9cd67c7 + 8f00bd3 commit f9cfc8a

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

Sources/CloudFoundryConfig/Extensions.swift

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ extension ConfigurationManager {
5656
throw ConfigurationManagerError.noServiceWithName(name)
5757
}
5858
}
59-
59+
60+
public func getObjectStorageService(name: String) throws -> ObjectStorageService {
61+
62+
if let service = getService(spec: name),
63+
let objStrService = ObjectStorageService(withService: service) {
64+
return objStrService
65+
} else {
66+
throw ConfigurationManagerError.noServiceWithName(name)
67+
}
68+
}
69+
6070
public func getPostgreSQLService(name: String) throws -> PostgreSQLService {
6171

6272
if let service = getService(spec: name),

Sources/CloudFoundryConfig/Services.swift

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,58 @@ public class RedisService: Service {
166166
}
167167
}
168168

169+
public class ObjectStorageService: Service {
170+
171+
public let authURL: String
172+
public let project: String
173+
public let projectID: String
174+
public let region: String
175+
public let userID: String
176+
public let username: String
177+
public let password: String
178+
public let domainID: String
179+
public let domainName: String
180+
181+
public init?(withService service: Service) {
182+
183+
guard let credentials = service.credentials,
184+
let authURL = credentials["auth_url"] as? String,
185+
let project = credentials["project"] as? String,
186+
let projectID = credentials["projectId"] as? String,
187+
let region = credentials["region"] as? String,
188+
let userID = credentials["userId"] as? String,
189+
let username = credentials["username"] as? String,
190+
let password = credentials["password"] as? String,
191+
let domainID = credentials["domainId"] as? String,
192+
let domainName = credentials["domainName"] as? String
193+
else {
194+
195+
return nil
196+
197+
}
198+
199+
self.authURL = authURL
200+
self.project = project
201+
self.projectID = projectID
202+
self.region = region
203+
self.userID = userID
204+
self.username = username
205+
self.password = password
206+
self.domainID = domainID
207+
self.domainName = domainName
208+
209+
super.init(name: service.name,
210+
label: service.label,
211+
plan: service.plan,
212+
tags: service.tags,
213+
credentials: service.credentials)
214+
215+
}
216+
217+
}
218+
219+
// other services
220+
169221
public class PostgreSQLService: Service {
170222

171223
public let host : String

0 commit comments

Comments
 (0)