Skip to content

Commit 845473a

Browse files
ewilkeniabudiab
authored andcommitted
add Hashable & Equatable conformance and public initializers to some KubeConfig child structs
1 parent dfa8f66 commit 845473a

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

Sources/SwiftkubeClient/Config/KubeConfig.swift

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,22 @@ public struct KubeConfig: Codable, Sendable {
5252
// MARK: - Cluster
5353

5454
/// Cluster contains information about how to communicate with a kubernetes cluster.
55-
public struct Cluster: Codable, Sendable {
55+
public struct Cluster: Codable, Sendable, Hashable, Equatable {
56+
public init(
57+
server: String,
58+
tlsServerName: String? = nil,
59+
insecureSkipTLSVerify: Bool? = nil,
60+
certificateAuthority: String? = nil,
61+
certificateAuthorityData: Data? = nil,
62+
proxyURL: String? = nil
63+
) {
64+
self.server = server
65+
self.tlsServerName = tlsServerName
66+
self.insecureSkipTLSVerify = insecureSkipTLSVerify
67+
self.certificateAuthority = certificateAuthority
68+
self.certificateAuthorityData = certificateAuthorityData
69+
self.proxyURL = proxyURL
70+
}
5671

5772
enum CodingKeys: String, CodingKey {
5873
case server
@@ -85,7 +100,36 @@ public struct Cluster: Codable, Sendable {
85100
// MARK: - AuthInfo
86101

87102
/// AuthInfo contains information that describes identity information. This is use to tell the kubernetes cluster who you are.
88-
public struct AuthInfo: Codable, Sendable {
103+
public struct AuthInfo: Codable, Sendable, Hashable, Equatable {
104+
public init(
105+
clientCertificate: String? = nil,
106+
clientCertificateData: Data? = nil,
107+
clientKey: String? = nil,
108+
clientKeyData: Data? = nil,
109+
token: String? = nil,
110+
tokenFile: String? = nil,
111+
impersonate: String? = nil,
112+
impersonateGroups: [String]? = nil,
113+
impersonateUserExtra: [String: String]? = nil,
114+
username: String? = nil,
115+
password: String? = nil,
116+
authProvider: AuthProviderConfig? = nil,
117+
exec: ExecConfig? = nil
118+
) {
119+
self.clientCertificate = clientCertificate
120+
self.clientCertificateData = clientCertificateData
121+
self.clientKey = clientKey
122+
self.clientKeyData = clientKeyData
123+
self.token = token
124+
self.tokenFile = tokenFile
125+
self.impersonate = impersonate
126+
self.impersonateGroups = impersonateGroups
127+
self.impersonateUserExtra = impersonateUserExtra
128+
self.username = username
129+
self.password = password
130+
self.authProvider = authProvider
131+
self.exec = exec
132+
}
89133

90134
enum CodingKeys: String, CodingKey {
91135
case clientCertificate = "client-certificate"
@@ -201,7 +245,7 @@ public struct NamedAuthInfo: Codable, Sendable {
201245
// MARK: - AuthProviderConfig
202246

203247
/// AuthProviderConfig holds the configuration for a specified auth provider.
204-
public struct AuthProviderConfig: Codable, Sendable {
248+
public struct AuthProviderConfig: Codable, Sendable, Hashable, Equatable {
205249

206250
/// Name is the nickname for this AuthProviderConfig.
207251
public var name: String
@@ -215,7 +259,7 @@ public struct AuthProviderConfig: Codable, Sendable {
215259
/// ExecConfig specifies a command to provide client credentials.
216260
/// The command is exec'd and outputs structured stdout holding credentials.
217261
/// See the client.authentication.k8s.io API group for specifications of the exact input and output format
218-
public struct ExecConfig: Codable, Sendable {
262+
public struct ExecConfig: Codable, Sendable, Hashable, Equatable {
219263
/// Command to execute.
220264
public var command: String
221265

@@ -233,7 +277,7 @@ public struct ExecConfig: Codable, Sendable {
233277
// MARK: - ExecEnvVar
234278

235279
/// ExecEnvVar is used for setting environment variables when executing an exec-based credential plugin.
236-
public struct ExecEnvVar: Codable, Sendable {
280+
public struct ExecEnvVar: Codable, Sendable, Hashable, Equatable {
237281

238282
/// Variable name.
239283
public var name: String

0 commit comments

Comments
 (0)