Change:
yaml.Marshal a kubeconfig, as done in the example tests here LocationOfOrigin is not seen in output, as comment says "never serialized." Click "run example" doesn't suffer from this as it does some conversion <details</details<details</details<details</details<details</details<details</details<details</details
/assign
/sig api-machinery
/assign /triage accepted
is what's known as internal type. It is not intended to be serialized by code. The serialization version is in and does not have this field. I could get behind removing all json tags from the internal version, but I wouldn't refine tags that shouldn't be used.

Discussion:
// Output: // clusters: //   cow-cluster: <del> //     LocationOfOrigin: "" </del> //     certificate-authority-data: DATA+OMITTED //     server: http://cow.org:8080 // contexts: //   federal-context: <del> //     LocationOfOrigin: "" </del> //     cluster: cow-cluster //     user: red-user // current-context: federal-context // preferences: {} // users: //   red-user: <del> //     LocationOfOrigin: "" </del> //     client-certificate-data: DATA+OMITTED //     client-key-data: DATA+OMITTED //     token: REDACTED

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 <del> LocationOfOrigin string </del> <ins> LocationOfOrigin string `json:"-"` </ins> // 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.

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 <del> LocationOfOrigin string </del> <ins> LocationOfOrigin string `json:"-"` </ins> // ClientCertificate is the path to a client cert file for TLS. // +optional ClientCertificate string `json:"client-certificate,omitempty"`

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 <del> LocationOfOrigin string </del> <ins> LocationOfOrigin string `json:"-"` </ins> // Cluster is the name of the cluster for this context Cluster string `json:"cluster"` // AuthInfo is the name of the authInfo for this context

// recommended as one of the prime benefits of exec plugins is that no secrets need // to be stored directly in the kubeconfig. // +k8s:conversion-gen=false <del> Config runtime.Object </del> <ins> Config runtime.Object `json:"-"` </ins> // InteractiveMode determines this plugin's relationship with standard input. Valid // values are "Never" (this exec plugin never uses standard input), "IfAvailable" (this

// client.authentication.k8s.io/v1beta1, then this field is optional and defaults // to "IfAvailable" when unset. Otherwise, this field is required. // +optional <del> InteractiveMode ExecInteractiveMode </del> <ins> InteractiveMode ExecInteractiveMode `json:"interactiveMode,omitempty"` </ins> // StdinUnavailable indicates whether the exec authenticator can pass standard // input through to this exec plugin. For example, a higher level entity might be using

// plugin to use standard input. This is kept here in order to keep all of the exec configuration // together, but it is never serialized. // +k8s:conversion-gen=false <del> StdinUnavailable bool </del> <ins> StdinUnavailable bool `json:"-"` </ins> // StdinUnavailableMessage is an optional message to be displayed when the exec authenticator // cannot successfully run this exec plugin because it needs to use standard input and // StdinUnavailable is true. For example, a process that is already using standard input to // read user instructions might set this to "used by my-program to read user instructions". // +k8s:conversion-gen=false <del> StdinUnavailableMessage string </del> <ins> StdinUnavailableMessage string `json:"-"` </ins> } var _ fmt.Stringer = new(ExecConfig)

// Output: // clusters: //   alfa: <del> //     LocationOfOrigin: "" </del> //     certificate-authority: path/to/my/cert-ca-filename //     disable-compression: true //     insecure-skip-tls-verify: true //     server: https://alfa.org:8080 //   bravo: <del> //     LocationOfOrigin: "" </del> //     server: https://bravo.org:8080 // contexts: //   alfa-as-black-mage: <del> //     LocationOfOrigin: "" </del> //     cluster: alfa //     namespace: zulu //     user: black-mage-via-auth-provider //   alfa-as-white-mage: <del> //     LocationOfOrigin: "" </del> //     cluster: alfa //     user: white-mage-via-cert //   bravo-as-black-mage: <del> //     LocationOfOrigin: "" </del> //     cluster: bravo //     namespace: yankee //     user: black-mage-via-auth-provider

//   colors: true // users: //   black-mage-via-auth-provider: <del> //     LocationOfOrigin: "" </del> //     auth-provider: //       config: //         foo: bar //         token: s3cr3t-t0k3n //       name: gcp //   red-mage-via-token: <del> //     LocationOfOrigin: "" </del> //     token: my-secret-token //   white-mage-via-cert: <del> //     LocationOfOrigin: "" </del> //     client-certificate: path/to/my/client-cert-filename //     client-key: path/to/my/client-key-filename }