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