From 4d9261c7567a7498d16754b7c5bf3b9ea834e5a6 Mon Sep 17 00:00:00 2001 From: Shiming Zhang Date: Tue, 25 Apr 2023 10:58:07 +0800 Subject: [PATCH] Fix LocationOfOrigin shows up unexpectedly --- .../k8s.io/client-go/tools/clientcmd/api/helpers_test.go | 3 --- staging/src/k8s.io/client-go/tools/clientcmd/api/types.go | 6 +++--- .../k8s.io/client-go/tools/clientcmd/api/types_test.go | 8 -------- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/staging/src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go b/staging/src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go index 169191f1cec..9cab27b1453 100644 --- a/staging/src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go +++ b/staging/src/k8s.io/client-go/tools/clientcmd/api/helpers_test.go @@ -228,19 +228,16 @@ func Example_minifyAndShorten() { // Output: // clusters: // cow-cluster: - // LocationOfOrigin: "" // certificate-authority-data: DATA+OMITTED // server: http://cow.org:8080 // contexts: // federal-context: - // LocationOfOrigin: "" // cluster: cow-cluster // user: red-user // current-context: federal-context // preferences: {} // users: // red-user: - // LocationOfOrigin: "" // client-certificate-data: DATA+OMITTED // client-key-data: DATA+OMITTED // token: REDACTED diff --git a/staging/src/k8s.io/client-go/tools/clientcmd/api/types.go b/staging/src/k8s.io/client-go/tools/clientcmd/api/types.go index 71fb821b1e8..c4a64b83f11 100644 --- a/staging/src/k8s.io/client-go/tools/clientcmd/api/types.go +++ b/staging/src/k8s.io/client-go/tools/clientcmd/api/types.go @@ -67,7 +67,7 @@ type Preferences struct { type Cluster struct { // LocationOfOrigin indicates where this object came from. It is used for round tripping config post-merge, but never serialized. // +k8s:conversion-gen=false - LocationOfOrigin string + LocationOfOrigin string `json:"-"` // Server is the address of the kubernetes cluster (https://hostname:port). Server string `json:"server"` // TLSServerName is used to check server certificate. If TLSServerName is empty, the hostname used to contact the server is used. @@ -107,7 +107,7 @@ type Cluster struct { type AuthInfo struct { // LocationOfOrigin indicates where this object came from. It is used for round tripping config post-merge, but never serialized. // +k8s:conversion-gen=false - LocationOfOrigin string + LocationOfOrigin string `json:"-"` // ClientCertificate is the path to a client cert file for TLS. // +optional ClientCertificate string `json:"client-certificate,omitempty"` @@ -159,7 +159,7 @@ type AuthInfo struct { type Context struct { // LocationOfOrigin indicates where this object came from. It is used for round tripping config post-merge, but never serialized. // +k8s:conversion-gen=false - LocationOfOrigin string + LocationOfOrigin string `json:"-"` // Cluster is the name of the cluster for this context Cluster string `json:"cluster"` // AuthInfo is the name of the authInfo for this context diff --git a/staging/src/k8s.io/client-go/tools/clientcmd/api/types_test.go b/staging/src/k8s.io/client-go/tools/clientcmd/api/types_test.go index d2eb541d85d..21bb4c825fa 100644 --- a/staging/src/k8s.io/client-go/tools/clientcmd/api/types_test.go +++ b/staging/src/k8s.io/client-go/tools/clientcmd/api/types_test.go @@ -94,26 +94,21 @@ func Example_ofOptionsConfig() { // Output: // clusters: // alfa: - // LocationOfOrigin: "" // certificate-authority: path/to/my/cert-ca-filename // disable-compression: true // insecure-skip-tls-verify: true // server: https://alfa.org:8080 // bravo: - // LocationOfOrigin: "" // server: https://bravo.org:8080 // contexts: // alfa-as-black-mage: - // LocationOfOrigin: "" // cluster: alfa // namespace: zulu // user: black-mage-via-auth-provider // alfa-as-white-mage: - // LocationOfOrigin: "" // cluster: alfa // user: white-mage-via-cert // bravo-as-black-mage: - // LocationOfOrigin: "" // cluster: bravo // namespace: yankee // user: black-mage-via-auth-provider @@ -122,17 +117,14 @@ func Example_ofOptionsConfig() { // colors: true // users: // black-mage-via-auth-provider: - // LocationOfOrigin: "" // auth-provider: // config: // foo: bar // token: s3cr3t-t0k3n // name: gcp // red-mage-via-token: - // LocationOfOrigin: "" // token: my-secret-token // white-mage-via-cert: - // LocationOfOrigin: "" // client-certificate: path/to/my/client-cert-filename // client-key: path/to/my/client-key-filename }