-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.dart
312 lines (248 loc) · 9.72 KB
/
config.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
part of '../kubernetes.dart';
/// Kubernetes Configuration.
class K8SConfiguration {
/// The main constructor.
const K8SConfiguration({
this.preferences,
required this.apiVersion,
required this.kind,
this.currentContext,
this.contexts = const [],
this.clusters = const [],
this.users = const [],
this.extensions = const [],
});
/// Creates a K8SConfiguration from JSON data.
K8SConfiguration.fromJson(Map<String, dynamic> json)
: this(
apiVersion: json['apiVersion'],
kind: json['kind'],
currentContext: json['current-context'],
clusters: json['clusters'] == null
? const []
: Cluster.listFromJson((json['clusters'] as Iterable)
.map((e) => e as Map<String, dynamic>)),
users: json['users'] == null
? const []
: User.listFromJson((json['users'] as Iterable)
.map((e) => e as Map<String, dynamic>)),
contexts: json['contexts'] == null
? const []
: Context.listFromJson((json['contexts'] as Iterable)
.map((e) => e as Map<String, dynamic>)),
);
/// Gets or sets general information to be use for CLI interactions.
final Map<String, Object>? preferences;
/// API version.
final String apiVersion;
/// Kind.
final String kind;
/// Gets or sets the name of the context that you would like to use by default.
final String? currentContext;
/// Gets or sets a map of referencable names to context configs.
final Iterable<Context> contexts;
/// Gets or sets a map of referencable names to cluster configs.
final Iterable<Cluster> clusters;
/// Gets or sets a map of referencable names to user configs
final Iterable<User> users;
/// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
final Iterable<NamedExtension>? extensions;
}
/// Represents a tuple of references to a cluster (how do I communicate with a kubernetes cluster),
/// a user (how do I identify myself), and a namespace (what subset of resources do I want to work with)
class ContextDetails {
/// The main constructor.
ContextDetails({
required this.cluster,
required this.user,
this.namespace,
this.extensions,
});
/// Creates a ContextDetails from JSON data.
ContextDetails.fromJson(Map<String, dynamic> json)
: this(
cluster: json['cluster'],
user: json['user'],
namespace: json['namespace'],
//extensions: json['extensions'],
);
/// Gets or sets the name of the cluster for this context.
final String cluster;
/// Gets or sets the name of the user for this context.
final String user;
/// Gets or sets the default namespace to use on unspecified requests.
final String? namespace;
/// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
final Iterable<NamedExtension>? extensions;
}
/// Relates nicknames to context information.
class Context {
/// The default constructor.
Context({
required this.name,
this.contextDetails,
this.extensions,
});
/// Creates a Context from JSON data.
Context.fromJson(Map<String, dynamic> json)
: this(
name: json['name'],
contextDetails: ContextDetails.fromJson(json['context']),
//extensions: json['extensions'],
);
/// Creates a list of Context from JSON data.
static List<Context> listFromJson(Iterable<Map<String, dynamic>> list) {
return list.map((e) => Context.fromJson(e)).toList();
}
/// Gets or sets the context information.
final ContextDetails? contextDetails;
/// Gets or sets the nickname for this context.
final String name;
/// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
Iterable<NamedExtension>? extensions;
}
/// Relates nicknames to extension information
class NamedExtension {
/// Gets or sets the nickname for this extension.
String? name;
/// Get or sets the extension information.
dynamic extension;
}
/// Contains information about how to communicate with a kubernetes cluster
class ClusterEndpoint {
/// The default constructor.
ClusterEndpoint({
required this.server,
this.certificateAuthorityData,
this.certificateAuthority,
this.extensions,
this.skipTlsVerify,
});
/// Creates a ClusterEndpoint from JSON data.
ClusterEndpoint.fromJson(Map<String, dynamic> json)
: this(
server: json['server'],
certificateAuthorityData: json['certificate-authority-data'],
);
/// Gets or sets the path to a cert file for the certificate authority.
final String? certificateAuthority;
/// Gets or sets =PEM-encoded certificate authority certificates. Overrides <see cref="CertificateAuthority"/>.
final String? certificateAuthorityData;
/// Gets or sets the address of the kubernetes cluster (https://hostname:port).
final String server;
/// Gets or sets a value indicating whether to skip the validity check for the server's certificate.
/// This will make your HTTPS connections insecure.
final bool? skipTlsVerify;
/// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
final Iterable<NamedExtension>? extensions;
}
/// Relates nicknames to cluster information.
class Cluster {
/// Default constructor.
Cluster({
required this.name,
required this.clusterEndpoint,
});
/// Creates a Cluster from JSON data.
Cluster.fromJson(Map<String, dynamic> json)
: this(
name: json['name'],
clusterEndpoint: ClusterEndpoint.fromJson(json['cluster']),
);
/// Creates a list of Cluster from JSON data.
static List<Cluster> listFromJson(Iterable<Map<String, dynamic>> list) {
return list.map((e) => Cluster.fromJson(e)).toList();
}
/// Gets or sets the cluster information.
final ClusterEndpoint clusterEndpoint;
/// Gets or sets the nickname for this Cluster.
final String name;
}
/// Contains information that describes identity information. This is use to tell the kubernetes cluster who you are.
class AuthProvider {
/// Gets or sets the nickname for this auth provider.
String? name;
/// Gets or sets the configuration for this auth provider
Map<String, String>? config;
}
/// Contains information that describes identity information. This is use to tell the kubernetes cluster who you are.
class UserCredentials {
/// The default constructor.
UserCredentials({
this.clientCertificateData,
this.clientKeyData,
this.clientCertificate,
});
/// Creates a UserCredentials from JSON data.
UserCredentials.fromJson(Map<String, dynamic> json)
: this(
clientCertificateData: json['client-certificate-data'],
clientKeyData: json['client-key-data'],
);
/// Gets or sets PEM-encoded data from a client cert file for TLS. Overrides <see cref="ClientCertificate"/>.
final String? clientCertificateData;
/// Gets or sets the path to a client cert file for TLS.
final String? clientCertificate;
/// Gets or sets PEM-encoded data from a client key file for TLS. Overrides <see cref="ClientKey"/>.
String? clientKeyData;
/// Gets or sets the path to a client key file for TLS.
String? clientKey;
/// Gets or sets the bearer token for authentication to the kubernetes cluster.
String? token;
/// Gets or sets the username to impersonate. The name matches the flag.
String? impersonate;
/// Gets or sets the groups to impersonate.
Iterable<String> impersonateGroups = [];
/// Gets or sets additional information for impersonated user.
Map<String, String> impersonateUserExtra = {};
/// Gets or sets the username for basic authentication to the kubernetes cluster.
String? userName;
/// Gets or sets the password for basic authentication to the kubernetes cluster.
String? password;
/// Gets or sets custom authentication plugin for the kubernetes cluster.
AuthProvider? authProvider;
/// Gets or sets additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
Iterable<NamedExtension>? extensions;
/// Gets or sets external command and its arguments to receive user credentials
ExternalExecution? externalExecution;
}
/// Relates nicknames to auth information.
class User {
/// The default constructor.
User({
required this.name,
required this.userCredentials,
});
/// Creates a User from JSON data.
User.fromJson(Map<String, dynamic> json)
: this(
name: json['name'],
userCredentials: json['user'] == null
? null
: UserCredentials.fromJson(json['user']),
);
/// Creates a list of User from JSON data.
static List<User> listFromJson(Iterable<Map<String, dynamic>> list) {
return list.map((e) => User.fromJson(e)).toList();
}
/// Gets or sets the auth information.
final UserCredentials? userCredentials;
/// Gets or sets the nickname for this auth information.
final String name;
}
/// External Execution
class ExternalExecution {
/// API version.
String? apiVersion;
/// The command to execute. Required.
String? command;
/// Environment variables to set when executing the plugin. Optional.
List<Map<String, String>>? environmentVariables;
/// Arguments to pass when executing the plugin. Optional.
List<String>? arguments;
/// Text shown to the user when the executable doesn't seem to be present. Optional.
String? installHint;
/// Whether or not to provide cluster information to this exec plugin as a part of
/// the KUBERNETES_EXEC_INFO environment variable. Optional.
bool? provideClusterInfo;
}