kube/client: add to global client-go scheme in init func

Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
pull/13224/head
Dr. Stefan Schimanski 4 months ago
parent a958f3a9b6
commit b9bdeca93b
No known key found for this signature in database
GPG Key ID: 4C68E0F19F95EC33

@ -85,23 +85,22 @@ type Client struct {
kubeClient *kubernetes.Clientset
}
var addToScheme sync.Once
func init() {
// Add CRDs to the scheme. They are missing by default.
if err := apiextv1.AddToScheme(scheme.Scheme); err != nil {
// This should never happen.
panic(err)
}
if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil {
panic(err)
}
}
// New creates a new Client.
func New(getter genericclioptions.RESTClientGetter) *Client {
if getter == nil {
getter = genericclioptions.NewConfigFlags(true)
}
// Add CRDs to the scheme. They are missing by default.
addToScheme.Do(func() {
if err := apiextv1.AddToScheme(scheme.Scheme); err != nil {
// This should never happen.
panic(err)
}
if err := apiextv1beta1.AddToScheme(scheme.Scheme); err != nil {
panic(err)
}
})
return &Client{
Factory: cmdutil.NewFactory(getter),
Log: nopLogger,

Loading…
Cancel
Save