k8s.io/client-go@v0.22.2/tools/clientcmd/api/v1/types.go (about) 1 /* 2 Copyright 2014 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 "k8s.io/apimachinery/pkg/runtime" 21 ) 22 23 // Where possible, json tags match the cli argument names. 24 // Top level config objects and all values required for proper functioning are not "omitempty". Any truly optional piece of config is allowed to be omitted. 25 26 // Config holds the information needed to build connect to remote kubernetes clusters as a given user 27 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 28 type Config struct { 29 // Legacy field from pkg/api/types.go TypeMeta. 30 // TODO(jlowdermilk): remove this after eliminating downstream dependencies. 31 // +k8s:conversion-gen=false 32 // +optional 33 Kind string `json:"kind,omitempty"` 34 // Legacy field from pkg/api/types.go TypeMeta. 35 // TODO(jlowdermilk): remove this after eliminating downstream dependencies. 36 // +k8s:conversion-gen=false 37 // +optional 38 APIVersion string `json:"apiVersion,omitempty"` 39 // Preferences holds general information to be use for cli interactions 40 Preferences Preferences `json:"preferences"` 41 // Clusters is a map of referencable names to cluster configs 42 Clusters []NamedCluster `json:"clusters"` 43 // AuthInfos is a map of referencable names to user configs 44 AuthInfos []NamedAuthInfo `json:"users"` 45 // Contexts is a map of referencable names to context configs 46 Contexts []NamedContext `json:"contexts"` 47 // CurrentContext is the name of the context that you would like to use by default 48 CurrentContext string `json:"current-context"` 49 // Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields 50 // +optional 51 Extensions []NamedExtension `json:"extensions,omitempty"` 52 } 53 54 type Preferences struct { 55 // +optional 56 Colors bool `json:"colors,omitempty"` 57 // Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields 58 // +optional 59 Extensions []NamedExtension `json:"extensions,omitempty"` 60 } 61 62 // Cluster contains information about how to communicate with a kubernetes cluster 63 type Cluster struct { 64 // Server is the address of the kubernetes cluster (https://hostname:port). 65 Server string `json:"server"` 66 // TLSServerName is used to check server certificate. If TLSServerName is empty, the hostname used to contact the server is used. 67 // +optional 68 TLSServerName string `json:"tls-server-name,omitempty"` 69 // InsecureSkipTLSVerify skips the validity check for the server's certificate. This will make your HTTPS connections insecure. 70 // +optional 71 InsecureSkipTLSVerify bool `json:"insecure-skip-tls-verify,omitempty"` 72 // CertificateAuthority is the path to a cert file for the certificate authority. 73 // +optional 74 CertificateAuthority string `json:"certificate-authority,omitempty"` 75 // CertificateAuthorityData contains PEM-encoded certificate authority certificates. Overrides CertificateAuthority 76 // +optional 77 CertificateAuthorityData []byte `json:"certificate-authority-data,omitempty"` 78 // ProxyURL is the URL to the proxy to be used for all requests made by this 79 // client. URLs with "http", "https", and "socks5" schemes are supported. If 80 // this configuration is not provided or the empty string, the client 81 // attempts to construct a proxy configuration from http_proxy and 82 // https_proxy environment variables. If these environment variables are not 83 // set, the client does not attempt to proxy requests. 84 // 85 // socks5 proxying does not currently support spdy streaming endpoints (exec, 86 // attach, port forward). 87 // +optional 88 ProxyURL string `json:"proxy-url,omitempty"` 89 // Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields 90 // +optional 91 Extensions []NamedExtension `json:"extensions,omitempty"` 92 } 93 94 // AuthInfo contains information that describes identity information. This is use to tell the kubernetes cluster who you are. 95 type AuthInfo struct { 96 // ClientCertificate is the path to a client cert file for TLS. 97 // +optional 98 ClientCertificate string `json:"client-certificate,omitempty"` 99 // ClientCertificateData contains PEM-encoded data from a client cert file for TLS. Overrides ClientCertificate 100 // +optional 101 ClientCertificateData []byte `json:"client-certificate-data,omitempty"` 102 // ClientKey is the path to a client key file for TLS. 103 // +optional 104 ClientKey string `json:"client-key,omitempty"` 105 // ClientKeyData contains PEM-encoded data from a client key file for TLS. Overrides ClientKey 106 // +optional 107 ClientKeyData []byte `json:"client-key-data,omitempty" datapolicy:"security-key"` 108 // Token is the bearer token for authentication to the kubernetes cluster. 109 // +optional 110 Token string `json:"token,omitempty" datapolicy:"token"` 111 // TokenFile is a pointer to a file that contains a bearer token (as described above). If both Token and TokenFile are present, Token takes precedence. 112 // +optional 113 TokenFile string `json:"tokenFile,omitempty"` 114 // Impersonate is the username to imperonate. The name matches the flag. 115 // +optional 116 Impersonate string `json:"as,omitempty"` 117 // ImpersonateGroups is the groups to imperonate. 118 // +optional 119 ImpersonateGroups []string `json:"as-groups,omitempty"` 120 // ImpersonateUserExtra contains additional information for impersonated user. 121 // +optional 122 ImpersonateUserExtra map[string][]string `json:"as-user-extra,omitempty"` 123 // Username is the username for basic authentication to the kubernetes cluster. 124 // +optional 125 Username string `json:"username,omitempty"` 126 // Password is the password for basic authentication to the kubernetes cluster. 127 // +optional 128 Password string `json:"password,omitempty" datapolicy:"password"` 129 // AuthProvider specifies a custom authentication plugin for the kubernetes cluster. 130 // +optional 131 AuthProvider *AuthProviderConfig `json:"auth-provider,omitempty"` 132 // Exec specifies a custom exec-based authentication plugin for the kubernetes cluster. 133 // +optional 134 Exec *ExecConfig `json:"exec,omitempty"` 135 // Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields 136 // +optional 137 Extensions []NamedExtension `json:"extensions,omitempty"` 138 } 139 140 // Context is 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) 141 type Context struct { 142 // Cluster is the name of the cluster for this context 143 Cluster string `json:"cluster"` 144 // AuthInfo is the name of the authInfo for this context 145 AuthInfo string `json:"user"` 146 // Namespace is the default namespace to use on unspecified requests 147 // +optional 148 Namespace string `json:"namespace,omitempty"` 149 // Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields 150 // +optional 151 Extensions []NamedExtension `json:"extensions,omitempty"` 152 } 153 154 // NamedCluster relates nicknames to cluster information 155 type NamedCluster struct { 156 // Name is the nickname for this Cluster 157 Name string `json:"name"` 158 // Cluster holds the cluster information 159 Cluster Cluster `json:"cluster"` 160 } 161 162 // NamedContext relates nicknames to context information 163 type NamedContext struct { 164 // Name is the nickname for this Context 165 Name string `json:"name"` 166 // Context holds the context information 167 Context Context `json:"context"` 168 } 169 170 // NamedAuthInfo relates nicknames to auth information 171 type NamedAuthInfo struct { 172 // Name is the nickname for this AuthInfo 173 Name string `json:"name"` 174 // AuthInfo holds the auth information 175 AuthInfo AuthInfo `json:"user"` 176 } 177 178 // NamedExtension relates nicknames to extension information 179 type NamedExtension struct { 180 // Name is the nickname for this Extension 181 Name string `json:"name"` 182 // Extension holds the extension information 183 Extension runtime.RawExtension `json:"extension"` 184 } 185 186 // AuthProviderConfig holds the configuration for a specified auth provider. 187 type AuthProviderConfig struct { 188 Name string `json:"name"` 189 Config map[string]string `json:"config"` 190 } 191 192 // ExecConfig specifies a command to provide client credentials. The command is exec'd 193 // and outputs structured stdout holding credentials. 194 // 195 // See the client.authentication.k8s.io API group for specifications of the exact input 196 // and output format 197 type ExecConfig struct { 198 // Command to execute. 199 Command string `json:"command"` 200 // Arguments to pass to the command when executing it. 201 // +optional 202 Args []string `json:"args"` 203 // Env defines additional environment variables to expose to the process. These 204 // are unioned with the host's environment, as well as variables client-go uses 205 // to pass argument to the plugin. 206 // +optional 207 Env []ExecEnvVar `json:"env"` 208 209 // Preferred input version of the ExecInfo. The returned ExecCredentials MUST use 210 // the same encoding version as the input. 211 APIVersion string `json:"apiVersion,omitempty"` 212 213 // This text is shown to the user when the executable doesn't seem to be 214 // present. For example, `brew install foo-cli` might be a good InstallHint for 215 // foo-cli on Mac OS systems. 216 InstallHint string `json:"installHint,omitempty"` 217 218 // ProvideClusterInfo determines whether or not to provide cluster information, 219 // which could potentially contain very large CA data, to this exec plugin as a 220 // part of the KUBERNETES_EXEC_INFO environment variable. By default, it is set 221 // to false. Package k8s.io/client-go/tools/auth/exec provides helper methods for 222 // reading this environment variable. 223 ProvideClusterInfo bool `json:"provideClusterInfo"` 224 225 // InteractiveMode determines this plugin's relationship with standard input. Valid 226 // values are "Never" (this exec plugin never uses standard input), "IfAvailable" (this 227 // exec plugin wants to use standard input if it is available), or "Always" (this exec 228 // plugin requires standard input to function). See ExecInteractiveMode values for more 229 // details. 230 // 231 // If APIVersion is client.authentication.k8s.io/v1alpha1 or 232 // client.authentication.k8s.io/v1beta1, then this field is optional and defaults 233 // to "IfAvailable" when unset. Otherwise, this field is required. 234 //+optional 235 InteractiveMode ExecInteractiveMode `json:"interactiveMode,omitempty"` 236 } 237 238 // ExecEnvVar is used for setting environment variables when executing an exec-based 239 // credential plugin. 240 type ExecEnvVar struct { 241 Name string `json:"name"` 242 Value string `json:"value"` 243 } 244 245 // ExecInteractiveMode is a string that describes an exec plugin's relationship with standard input. 246 type ExecInteractiveMode string 247 248 const ( 249 // NeverExecInteractiveMode declares that this exec plugin never needs to use standard 250 // input, and therefore the exec plugin will be run regardless of whether standard input is 251 // available for user input. 252 NeverExecInteractiveMode ExecInteractiveMode = "Never" 253 // IfAvailableExecInteractiveMode declares that this exec plugin would like to use standard input 254 // if it is available, but can still operate if standard input is not available. Therefore, the 255 // exec plugin will be run regardless of whether stdin is available for user input. If standard 256 // input is available for user input, then it will be provided to this exec plugin. 257 IfAvailableExecInteractiveMode ExecInteractiveMode = "IfAvailable" 258 // AlwaysExecInteractiveMode declares that this exec plugin requires standard input in order to 259 // run, and therefore the exec plugin will only be run if standard input is available for user 260 // input. If standard input is not available for user input, then the exec plugin will not be run 261 // and an error will be returned by the exec plugin runner. 262 AlwaysExecInteractiveMode ExecInteractiveMode = "Always" 263 )