Skip to content

Commit 341bf07

Browse files
authored
Merge pull request #7 from YouClap/feat/restructure
Modularize the lib, just throwing an idea
2 parents 87ec144 + ef8d321 commit 341bf07

38 files changed

+79
-40
lines changed

Sources/GoogleCloudKit/Configuration/Credentials/GoogleCloudCredentials.swift renamed to Core/Sources/Configuration/Credentials/GoogleCloudCredentials.swift

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import Foundation
99
import AsyncHTTPClient
1010

1111
/// Loads credentials from `~/.config/gcloud/application_default_credentials.json`
12-
struct GoogleApplicationDefaultCredentials: Codable {
13-
let clientId: String
14-
let clientSecret: String
15-
let refreshToken: String
16-
let type: String
12+
public struct GoogleApplicationDefaultCredentials: Codable {
13+
public let clientId: String
14+
public let clientSecret: String
15+
public let refreshToken: String
16+
public let type: String
1717

18-
init(fromFilePath path: String) throws {
18+
public init(fromFilePath path: String) throws {
1919
let decoder = JSONDecoder()
2020
decoder.keyDecodingStrategy = .convertFromSnakeCase
2121
if let contents = try String(contentsOfFile: path).data(using: .utf8) {
@@ -25,7 +25,7 @@ struct GoogleApplicationDefaultCredentials: Codable {
2525
}
2626
}
2727

28-
init(fromJsonString json: String) throws {
28+
public init(fromJsonString json: String) throws {
2929
let decoder = JSONDecoder()
3030
decoder.keyDecodingStrategy = .convertFromSnakeCase
3131
if let data = json.data(using: .utf8) {
@@ -37,19 +37,19 @@ struct GoogleApplicationDefaultCredentials: Codable {
3737
}
3838

3939
/// Loads credentials from a file specified in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
40-
struct GoogleServiceAccountCredentials: Codable {
41-
let type: String
42-
let projectId: String
43-
let privateKeyId: String
44-
let privateKey: String
45-
let clientEmail: String
46-
let clientId: String
47-
let authUri: URL
48-
let tokenUri: URL
49-
let authProviderX509CertUrl: URL
50-
let clientX509CertUrl: URL
40+
public struct GoogleServiceAccountCredentials: Codable {
41+
public let type: String
42+
public let projectId: String
43+
public let privateKeyId: String
44+
public let privateKey: String
45+
public let clientEmail: String
46+
public let clientId: String
47+
public let authUri: URL
48+
public let tokenUri: URL
49+
public let authProviderX509CertUrl: URL
50+
public let clientX509CertUrl: URL
5151

52-
init(fromFilePath path: String) throws {
52+
public init(fromFilePath path: String) throws {
5353
let decoder = JSONDecoder()
5454
decoder.keyDecodingStrategy = .convertFromSnakeCase
5555
if let contents = try String(contentsOfFile: path).data(using: .utf8) {
@@ -59,7 +59,7 @@ struct GoogleServiceAccountCredentials: Codable {
5959
}
6060
}
6161

62-
init(fromJsonString json: String) throws {
62+
public init(fromJsonString json: String) throws {
6363
let decoder = JSONDecoder()
6464
decoder.keyDecodingStrategy = .convertFromSnakeCase
6565
if let data = json.data(using: .utf8) {

Sources/GoogleCloudKit/Configuration/GoogleCloudAPIConfiguration.swift renamed to Core/Sources/Configuration/GoogleCloudAPIConfiguration.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/GoogleCloudCredentialsConfiguration.swift renamed to Core/Sources/Configuration/GoogleCloudCredentialsConfiguration.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import Foundation
99

1010
public struct GoogleCloudCredentialsConfiguration {
11-
let serviceAccountCredentialsPath: String
12-
let project: String?
11+
public let serviceAccountCredentialsPath: String
12+
public let project: String?
1313

1414
public init(projectId: String? = nil, credentialsFile: String? = nil) {
1515
project = projectId

Sources/GoogleCloudKit/Configuration/GoogleCloudError.swift renamed to Core/Sources/Configuration/GoogleCloudError.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/OAuth/OAuthAccessToken.swift renamed to Core/Sources/Configuration/OAuth/OAuthAccessToken.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
/// An access token returned from the authorization server used to authenticate against Google APIs.
1111
public struct OAuthAccessToken: Codable {
12-
let accessToken: String
13-
let tokenType: String
14-
let expiresIn: Int
12+
public let accessToken: String
13+
public let tokenType: String
14+
public let expiresIn: Int
1515
}

Sources/GoogleCloudKit/Configuration/OAuth/OAuthApplicationDefault.swift renamed to Core/Sources/Configuration/OAuth/OAuthApplicationDefault.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/OAuth/OAuthComputeEngine+AppEngineFlex.swift renamed to Core/Sources/Configuration/OAuth/OAuthComputeEngine+AppEngineFlex.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/OAuth/OAuthPayload.swift renamed to Core/Sources/Configuration/OAuth/OAuthPayload.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/OAuth/OAuthRefreshable.swift renamed to Core/Sources/Configuration/OAuth/OAuthRefreshable.swift

File renamed without changes.

Sources/GoogleCloudKit/Configuration/OAuth/OAuthServiceAccount.swift renamed to Core/Sources/Configuration/OAuth/OAuthServiceAccount.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import AsyncHTTPClient
1212
import Foundation
1313

1414
public class OAuthServiceAccount: OAuthRefreshable {
15-
let httpClient: HTTPClient
16-
let credentials: GoogleServiceAccountCredentials
17-
let scope: String
15+
public let httpClient: HTTPClient
16+
public let credentials: GoogleServiceAccountCredentials
17+
public let scope: String
18+
1819
private let decoder = JSONDecoder()
1920

2021
init(credentials: GoogleServiceAccountCredentials, scopes: [GoogleCloudAPIScope], httpClient: HTTPClient) {

0 commit comments

Comments
 (0)