Deprecate kubeconfig's preference field in favor of kuberc

Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: 8cf5e8db78deb186ef362f64ab779c09e9520156
This commit is contained in:
Maciej Szulik 2025-05-13 13:39:13 +02:00 committed by Kubernetes Publisher
parent 025e06660a
commit 5334fcaa9c
5 changed files with 11 additions and 13 deletions

View File

@ -225,7 +225,6 @@ func Example_minifyAndShorten() {
// cluster: cow-cluster // cluster: cow-cluster
// user: red-user // user: red-user
// current-context: federal-context // current-context: federal-context
// preferences: {}
// users: // users:
// red-user: // red-user:
// client-certificate-data: DATA+OMITTED // client-certificate-data: DATA+OMITTED

View File

@ -40,7 +40,8 @@ type Config struct {
// +optional // +optional
APIVersion string `json:"apiVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty"`
// Preferences holds general information to be use for cli interactions // Preferences holds general information to be use for cli interactions
Preferences Preferences `json:"preferences"` // Deprecated: this field is deprecated in v1.34. It is not used by any of the Kubernetes components.
Preferences Preferences `json:"preferences,omitzero"`
// Clusters is a map of referencable names to cluster configs // Clusters is a map of referencable names to cluster configs
Clusters map[string]*Cluster `json:"clusters"` Clusters map[string]*Cluster `json:"clusters"`
// AuthInfos is a map of referencable names to user configs // AuthInfos is a map of referencable names to user configs
@ -55,6 +56,7 @@ type Config struct {
} }
// IMPORTANT if you add fields to this struct, please update IsConfigEmpty() // IMPORTANT if you add fields to this struct, please update IsConfigEmpty()
// Deprecated: this structure is deprecated in v1.34. It is not used by any of the Kubernetes components.
type Preferences struct { type Preferences struct {
// +optional // +optional
Colors bool `json:"colors,omitempty"` Colors bool `json:"colors,omitempty"`
@ -339,11 +341,10 @@ const (
// NewConfig is a convenience function that returns a new Config object with non-nil maps // NewConfig is a convenience function that returns a new Config object with non-nil maps
func NewConfig() *Config { func NewConfig() *Config {
return &Config{ return &Config{
Preferences: *NewPreferences(), Clusters: make(map[string]*Cluster),
Clusters: make(map[string]*Cluster), AuthInfos: make(map[string]*AuthInfo),
AuthInfos: make(map[string]*AuthInfo), Contexts: make(map[string]*Context),
Contexts: make(map[string]*Context), Extensions: make(map[string]runtime.Object),
Extensions: make(map[string]runtime.Object),
} }
} }
@ -370,6 +371,7 @@ func NewAuthInfo() *AuthInfo {
// NewPreferences is a convenience function that returns a new // NewPreferences is a convenience function that returns a new
// Preferences object with non-nil maps // Preferences object with non-nil maps
// Deprecated: this method is deprecated in v1.34. It is not used by any of the Kubernetes components.
func NewPreferences() *Preferences { func NewPreferences() *Preferences {
return &Preferences{Extensions: make(map[string]runtime.Object)} return &Preferences{Extensions: make(map[string]runtime.Object)}
} }

View File

@ -35,7 +35,6 @@ func Example_emptyConfig() {
// clusters: {} // clusters: {}
// contexts: {} // contexts: {}
// current-context: "" // current-context: ""
// preferences: {}
// users: {} // users: {}
} }

View File

@ -37,7 +37,8 @@ type Config struct {
// +optional // +optional
APIVersion string `json:"apiVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty"`
// Preferences holds general information to be use for cli interactions // Preferences holds general information to be use for cli interactions
Preferences Preferences `json:"preferences"` // Deprecated: this field is deprecated in v1.34. It is not used by any of the Kubernetes components.
Preferences Preferences `json:"preferences,omitzero"`
// Clusters is a map of referencable names to cluster configs // Clusters is a map of referencable names to cluster configs
Clusters []NamedCluster `json:"clusters"` Clusters []NamedCluster `json:"clusters"`
// AuthInfos is a map of referencable names to user configs // AuthInfos is a map of referencable names to user configs
@ -51,6 +52,7 @@ type Config struct {
Extensions []NamedExtension `json:"extensions,omitempty"` Extensions []NamedExtension `json:"extensions,omitempty"`
} }
// Deprecated: this structure is deprecated in v1.34. It is not used by any of the Kubernetes components.
type Preferences struct { type Preferences struct {
// +optional // +optional
Colors bool `json:"colors,omitempty"` Colors bool `json:"colors,omitempty"`

View File

@ -309,7 +309,6 @@ contexts:
name: "433e40" name: "433e40"
current-context: any-context-value current-context: any-context-value
kind: Config kind: Config
preferences: {}
users: null users: null
`) `)
if !bytes.Equal(expected, data) { if !bytes.Equal(expected, data) {
@ -757,7 +756,6 @@ func Example_noMergingOnExplicitPaths() {
// name: federal-context // name: federal-context
// current-context: "" // current-context: ""
// kind: Config // kind: Config
// preferences: {}
// users: // users:
// - name: red-user // - name: red-user
// user: // user:
@ -809,7 +807,6 @@ func Example_mergingSomeWithConflict() {
// name: federal-context // name: federal-context
// current-context: federal-context // current-context: federal-context
// kind: Config // kind: Config
// preferences: {}
// users: // users:
// - name: red-user // - name: red-user
// user: // user:
@ -887,7 +884,6 @@ func Example_mergingEverythingNoConflicts() {
// name: shaker-context // name: shaker-context
// current-context: "" // current-context: ""
// kind: Config // kind: Config
// preferences: {}
// users: // users:
// - name: black-user // - name: black-user
// user: // user: