ArjunDandagi
ArjunDandagi

Reputation: 310

what does "preferences: {}" in ~/.kube/config do?

I searched on the net but couldn't find a single use case of having this empty key in config file. I tried to comment it and kubectl worked perfectly fine.

so my question is, what on earth it is solving? :)

Upvotes: 2

Views: 456

Answers (1)

Leo Melin
Leo Melin

Reputation: 234

Interesting question. Looking at the source code here https://github.com/kubernetes/client-go/blob/d412730e5f0160f6dc0a83459c14b05df8ea56fb/tools/clientcmd/api/v1/types.go it seems that preferences is used for ”holding general information to be use for cli interactions”. It can hold two config parameters: colors(boolean) and extensions(array of extension descriptor objects). There was also this comment here: https://github.com/kubernetes/client-go/blob/228dada99554f2e0f7ef07e24f2a4a88c0e448bb/tools/clientcmd/config.go saying: ” Preferences and CurrentContext should always be set in the default destination file. Since we can't distinguish between empty and missing values (no nil strings), we're forced have separate handling for them.”

So, as I understand, preferences is there because it is required not be nil and technically it’s impossible to distinguish empty and missing values. Does this answer your question?

Upvotes: 2

Related Questions