-
Notifications
You must be signed in to change notification settings - Fork 12
/
clientconfig_types.go
375 lines (315 loc) · 16.6 KB
/
clientconfig_types.go
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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
// Copyright 2022 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Package types specifies the types for clientconfig
package types
import (
"time"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// ServerType is the type of server.
//
// Deprecated: This API is deprecated. Superseded by Target.
type ServerType string
const (
// ManagementClusterServerType is a management cluster server.
//
// Deprecated: This variable is deprecated. Use TargetK8s instead.
ManagementClusterServerType ServerType = "managementcluster"
// GlobalServerType is a global control plane server.
//
// Deprecated: This variable is deprecated. Use TargetTMC instead.
GlobalServerType ServerType = "global"
)
// Server connection.
//
// Deprecated: This struct is deprecated. Use Context instead.
type Server struct {
// Name of the server.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Type of the endpoint.
Type ServerType `json:"type,omitempty" yaml:"type,omitempty"`
// GlobalOpts if the server is global.
GlobalOpts *GlobalServer `json:"globalOpts,omitempty" yaml:"globalOpts,omitempty"`
// ManagementClusterOpts if the server is a management cluster.
ManagementClusterOpts *ManagementClusterServer `json:"managementClusterOpts,omitempty" yaml:"managementClusterOpts,omitempty"`
// DiscoverySources determines from where to discover plugins
// associated with this server
DiscoverySources []PluginDiscovery `json:"discoverySources,omitempty" yaml:"discoverySources,omitempty"`
}
// Context configuration for a control plane. This can one of the following,
// 1. Kubernetes Cluster
// 2. Tanzu Mission Control endpoint
// 3. Tanzu control plane endpoint
type Context struct {
// Name of the context.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Target of the context.
// Deprecated: This field is deprecated. Please use ContextType
Target Target `json:"target,omitempty" yaml:"target,omitempty"`
// ContextType of the context.
ContextType ContextType `json:"contextType,omitempty" yaml:"contextType,omitempty"`
// GlobalOpts if the context is a global control plane (e.g., TMC).
GlobalOpts *GlobalServer `json:"globalOpts,omitempty" yaml:"globalOpts,omitempty"`
// ClusterOpts if the context is a kubernetes cluster.
ClusterOpts *ClusterServer `json:"clusterOpts,omitempty" yaml:"clusterOpts,omitempty"`
// AdditionalMetadata to provide any additional data that is respective to each context
AdditionalMetadata map[string]interface{} `json:"additionalMetadata,omitempty" yaml:"additionalMetadata,omitempty"`
// DiscoverySources determines from where to discover plugins
// associated with this context.
// Deprecated: This field is deprecated. It is currently no used.
DiscoverySources []PluginDiscovery `json:"discoverySources,omitempty" yaml:"discoverySources,omitempty"`
}
// ManagementClusterServer is the configuration for a management cluster kubeconfig.
//
// Deprecated: This struct is deprecated. Use ClusterServer instead.
type ManagementClusterServer struct {
// Endpoint for the login.
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// Path to the kubeconfig.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// The context to use (if required), defaults to current.
Context string `json:"context,omitempty" yaml:"context,omitempty"`
}
// ClusterServer contains the configuration for a kubernetes cluster (kubeconfig).
type ClusterServer struct {
// Endpoint for the login.
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// Path to the kubeconfig.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// The kubernetes context to use (if required), defaults to current.
Context string `json:"context,omitempty" yaml:"context,omitempty"`
// Denotes whether this server is a management cluster or not (workload cluster).
// Deprecated: This field is deprecated.
IsManagementCluster bool `json:"isManagementCluster,omitempty" yaml:"isManagementCluster,omitempty"`
}
// GlobalServer is the configuration for a global server.
type GlobalServer struct {
// Endpoint for the server.
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// Auth for the global server.
Auth GlobalServerAuth `json:"auth,omitempty" yaml:"auth,omitempty"`
}
// GlobalServerAuth is authentication for a global server.
type GlobalServerAuth struct {
// Issuer url for IDP, compliant with OIDC Metadata Discovery.
Issuer string `json:"issuer,omitempty" yaml:"issuer,omitempty"`
// UserName is the authorized user the token is assigned to.
UserName string `json:"userName,omitempty" yaml:"userName,omitempty"`
// Permissions are roles assigned to the user.
Permissions []string `json:"permissions,omitempty" yaml:"permissions,omitempty"`
// AccessToken is the current access token based on the context.
AccessToken string `json:"accessToken,omitempty" yaml:"accessToken,omitempty"`
// IDToken is the current id token based on the context scoped to the CLI.
IDToken string `json:"IDToken,omitempty" yaml:"IDToken,omitempty"`
// RefreshToken will be stored only in case of api-token login flow.
RefreshToken string `json:"refresh_token,omitempty" yaml:"refresh_token,omitempty"`
// Expiration times of the token.
Expiration time.Time `json:"expiration,omitempty" yaml:"expiration,omitempty"`
// Type of the token (user or client).
Type string `json:"type" yaml:"type,omitempty"`
}
// ClientOptions are the client specific options.
type ClientOptions struct {
// CLI options specific to the CLI.
//
// Deprecated: CLI has been deprecated and will be removed from future version. use CoreCliOptions
CLI *CLIOptions `json:"cli,omitempty" yaml:"cli,omitempty"`
Features map[string]FeatureMap `json:"features,omitempty" yaml:"features,omitempty"`
Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"`
}
// FeatureMap is simply a hash table, but needs an explicit type to be an object in another hash map (cf ClientOptions.Features)
type FeatureMap map[string]string
// EnvMap is simply a hash table, but needs an explicit type to be an object in another hash map (cf ClientOptions.Env)
type EnvMap map[string]string
// CLIOptions are options for the CLI.
//
// Deprecated: CLIOptions has been deprecated and will be removed from future version
type CLIOptions struct {
// Repositories are the plugin repositories.
//
// Deprecated: Repositories has been deprecated and will be removed from future version
Repositories []PluginRepository `json:"repositories,omitempty" yaml:"repositories,omitempty"`
// DiscoverySources determines from where to discover stand-alone plugins
//
// Deprecated: DiscoverySources has been deprecated and will be removed in a future version. use CoreCliOptions.DiscoverySources
DiscoverySources []PluginDiscovery `json:"discoverySources,omitempty" yaml:"discoverySources,omitempty"`
// UnstableVersionSelector determined which version tags are allowed
//
// Deprecated: UnstableVersionSelector has been deprecated and will be removed from future version
UnstableVersionSelector VersionSelectorLevel `json:"unstableVersionSelector,omitempty" yaml:"unstableVersionSelector,omitempty"`
// Edition
//
// Deprecated: Edition has been deprecated and will be removed from future version
Edition EditionSelector `json:"edition,omitempty" yaml:"edition,omitempty"`
// BOMRepo is the root repository URL used to resolve the compatibiilty file
// and bill of materials. An example URL is projects.registry.vmware.com/tkg.
//
// Deprecated: BOMRepo has been deprecated and will be removed from future version
BOMRepo string `json:"bomRepo,omitempty" yaml:"bomRepo,omitempty"`
// CompatibilityFilePath is the path, from the BOM repo, to download and access the compatibility file.
// the compatibility file is used for resolving the bill of materials for creating clusters.
//
// Deprecated: CompatibilityFilePath has been deprecated and will be removed from future version
CompatibilityFilePath string `json:"compatibilityFilePath,omitempty" yaml:"compatibilityFilePath,omitempty"`
}
// PluginDiscovery contains a specific distribution mechanism. Only one of the
// configs must be set.
type PluginDiscovery struct {
// GCPStorage is set if the plugins are to be discovered via Google Cloud Storage.
//
// Deprecated: GCP has been deprecated and will be removed from future version
GCP *GCPDiscovery `json:"gcp,omitempty" yaml:"gcp,omitempty"`
// OCIDiscovery is set if the plugins are to be discovered via an OCI Image Registry.
OCI *OCIDiscovery `json:"oci,omitempty" yaml:"oci,omitempty"`
// GenericRESTDiscovery is set if the plugins are to be discovered via a REST API endpoint.
REST *GenericRESTDiscovery `json:"rest,omitempty" yaml:"rest,omitempty"`
// KubernetesDiscovery is set if the plugins are to be discovered via the Kubernetes API server.
Kubernetes *KubernetesDiscovery `json:"k8s,omitempty" yaml:"k8s,omitempty"`
// LocalDiscovery is set if the plugins are to be discovered via Local Manifest fast.
Local *LocalDiscovery `json:"local,omitempty" yaml:"local,omitempty"`
}
// GCPDiscovery provides a plugin discovery mechanism via a Google Cloud Storage
// bucket with a manifest.yaml file.
//
// Deprecated: GCPDiscovery has been deprecated and will be removed from future version
type GCPDiscovery struct {
// Name is a name of the discovery
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Bucket is a Google Cloud Storage bucket.
// E.g., tanzu-cli
Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"`
// BasePath is a URI path that is prefixed to the object name/path.
// E.g., plugins/cluster
ManifestPath string `json:"manifestPath,omitempty" yaml:"manifestPath,omitempty"`
}
// OCIDiscovery provides a plugin discovery mechanism via a OCI Image Registry
type OCIDiscovery struct {
// Name is a name of the discovery
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Image is an OCI compliant image. Which include DNS-compatible registry name,
// a valid URI path(MAY contain zero or more ‘/’) and a valid tag.
// E.g., harbor.my-domain.local/tanzu-cli/plugins-manifest:latest
// Contains a directory containing YAML files, each of which contains single
// CLIPlugin API resource.
Image string `json:"image,omitempty" yaml:"image,omitempty"`
}
// GenericRESTDiscovery provides a plugin discovery mechanism via any REST API
// endpoint. The fully qualified list URL is constructed as
// `https://{Endpoint}/{BasePath}` and the get plugin URL is constructed as .
// `https://{Endpoint}/{BasePath}/{Plugin}`.
type GenericRESTDiscovery struct {
// Name is a name of the discovery
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Endpoint is the REST API server endpoint.
// E.g., api.my-domain.local
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
// BasePath is the base URL path of the plugin discovery API.
// E.g., /v1alpha1/cli/plugins
BasePath string `json:"basePath,omitempty" yaml:"basePath,omitempty"`
}
// KubernetesDiscovery provides a plugin discovery mechanism via the Kubernetes API server.
type KubernetesDiscovery struct {
// Name is a name of the discovery
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Path to the kubeconfig.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// The context to use (if required), defaults to current.
Context string `json:"context,omitempty" yaml:"context,omitempty"`
// KubeConfigBytes is the entire kube configuration
// Note: Either Path or KubeConfigBytes should be configured and not both
KubeConfigBytes []byte `json:"kubeConfigBytes,omitempty" yaml:"kubeConfigBytes,omitempty"`
// Version of the CLIPlugins API to query.
// E.g., v1alpha1
Version string `json:"version,omitempty" yaml:"version,omitempty"`
}
// LocalDiscovery is a artifact discovery endpoint utilizing a local host OS.
type LocalDiscovery struct {
// Name is a name of the discovery
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Path is a local path pointing to directory
// containing YAML files, each of which contains single
// CLIPlugin API resource.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
}
// PluginRepository is a CLI plugin repository
//
// Deprecated: PluginRepository has been deprecated and will be removed from future version
type PluginRepository struct {
// GCPPluginRepository is a plugin repository that utilizes GCP cloud storage.
GCPPluginRepository *GCPPluginRepository `json:"gcpPluginRepository,omitempty" yaml:"gcpPluginRepository,omitempty"`
}
// GCPPluginRepository is a plugin repository that utilizes GCP cloud storage.
//
// Deprecated: GCPPluginRepository has been deprecated and will be removed from future version
type GCPPluginRepository struct {
// Name of the repository.
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// BucketName is the name of the bucket.
BucketName string `json:"bucketName,omitempty" yaml:"bucketName,omitempty"`
// RootPath within the bucket.
RootPath string `json:"rootPath,omitempty" yaml:"rootPath,omitempty"`
}
// CoreCliOptions are core CLI specific options that are specific to CLI(not for plugins) like ceipOptIn, etc
// that goes into nextgen configuration file.
type CoreCliOptions struct {
// CEIPOptIn is the user's CEIP opt-in/opt-out status.
CEIPOptIn string `json:"ceipOptIn,omitempty" yaml:"ceipOptIn,omitempty"`
// EULAStatus is the EULA acceptance status.
EULAStatus string `json:"eulaStatus,omitempty" yaml:"eulaStatus,omitempty"`
// EULAAcceptedVersions is comma-separated list of EULA versions accepted.
EULAAcceptedVersions string `json:"eulaAcceptedVersions,omitempty" yaml:"eulaAcceptedVersions,omitempty"`
// DiscoverySources determine where to discover plugins
DiscoverySources []PluginDiscovery `json:"discoverySources,omitempty" yaml:"discoverySources,omitempty"`
// CliID is the uuid uniquely identifying the CLI instance
CliID string `json:"cliId,omitempty" yaml:"cliId,omitempty"`
// TelemetryOptions are the core CLI specific telemetry options
TelemetryOptions *TelemetryOptions `json:"telemetry,omitempty" yaml:"telemetry,omitempty"`
}
type TelemetryOptions struct {
// Source is the path of the telemetry source database
Source string `json:"source,omitempty" yaml:"source,omitempty"`
// CSPOrgID is the organization ID the user
CSPOrgID string `json:"cspOrgID,omitempty" yaml:"cspOrgID,omitempty"`
// EntitlementAccountNumber is the organization ID the user
EntitlementAccountNumber string `json:"entitlementAccountNumber,omitempty" yaml:"entitlementAccountNumber,omitempty"`
}
// Cert provides a certificate configuration for an endpoint
type Cert struct {
// Host is the host(or ipaddress) or host:port for which the certificate configuration is applicable
Host string `json:"host,omitempty" yaml:"host,omitempty"`
// CACertData is the CA certificate for the host
CACertData string `json:"caCertData,omitempty" yaml:"caCertData,omitempty"`
// Insecure is to allow insecure connections with host
Insecure string `json:"insecure,omitempty" yaml:"insecure,omitempty"`
// SkipCertVerify is to skip certificate validation
SkipCertVerify string `json:"skipCertVerify,omitempty" yaml:"skipCertVerify,omitempty"`
}
// ClientConfig is the Schema for the configs API
type ClientConfig struct {
// KnownServers available.
//
// Deprecated: This field is deprecated. Use KnownContexts instead.
KnownServers []*Server `json:"servers,omitempty" yaml:"servers,omitempty"`
// CurrentServer in use.
//
// Deprecated: This field is deprecated. Use CurrentContext instead.
CurrentServer string `json:"current,omitempty" yaml:"current,omitempty"`
// KnownContexts available.
KnownContexts []*Context `json:"contexts,omitempty" yaml:"contexts,omitempty"`
// CurrentContext for every type.
CurrentContext map[ContextType]string `json:"currentContext,omitempty" yaml:"currentContext,omitempty"`
// ClientOptions are client specific options like feature flags, environment variables, repositories, discoverySources, etc.
ClientOptions *ClientOptions `json:"clientOptions,omitempty" yaml:"clientOptions,omitempty"`
// CoreCliOptions are core CLI specific options that are specific to CLI(not for plugins) like ceipOptIn, etc
// that goes into nextgen configuration file.
CoreCliOptions *CoreCliOptions `json:"cli,omitempty" yaml:"cli,omitempty"`
// Certs is the collection of host, and its certificate data used to communicate with the host
Certs []*Cert `json:"certs,omitempty" yaml:"certs,omitempty"`
}
// ClientConfigList contains a list of ClientConfig
//
// Deprecated: ClientConfigList struct is deprecated. Use ClientConfig instead.
type ClientConfigList struct {
Items []ClientConfig `json:"items"`
}