|
|
@ -83,34 +83,12 @@ type Client struct {
|
|
|
|
Namespace string
|
|
|
|
Namespace string
|
|
|
|
|
|
|
|
|
|
|
|
kubeClient *kubernetes.Clientset
|
|
|
|
kubeClient *kubernetes.Clientset
|
|
|
|
|
|
|
|
|
|
|
|
// context used to cancel the running task
|
|
|
|
|
|
|
|
ctx context.Context
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var addToScheme sync.Once
|
|
|
|
var addToScheme sync.Once
|
|
|
|
|
|
|
|
|
|
|
|
type Option func(*Client)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func WithContext(ctx context.Context) Option {
|
|
|
|
|
|
|
|
return func(c *Client) {
|
|
|
|
|
|
|
|
c.ctx = ctx
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// New creates a new Client.
|
|
|
|
// New creates a new Client.
|
|
|
|
func New(getter genericclioptions.RESTClientGetter, opts ...Option) *Client {
|
|
|
|
func New(getter genericclioptions.RESTClientGetter) *Client {
|
|
|
|
|
|
|
|
|
|
|
|
client := &Client{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for _, opt := range opts {
|
|
|
|
|
|
|
|
opt(client)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if client.ctx == nil {
|
|
|
|
|
|
|
|
client.ctx = context.TODO()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if getter == nil {
|
|
|
|
if getter == nil {
|
|
|
|
getter = genericclioptions.NewConfigFlags(true)
|
|
|
|
getter = genericclioptions.NewConfigFlags(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -126,10 +104,10 @@ func New(getter genericclioptions.RESTClientGetter, opts ...Option) *Client {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
client.Factory = cmdutil.NewFactory(getter)
|
|
|
|
return &Client{
|
|
|
|
client.Log = nopLogger
|
|
|
|
Factory: cmdutil.NewFactory(getter),
|
|
|
|
|
|
|
|
Log: nopLogger,
|
|
|
|
return client
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var nopLogger = func(_ string, _ ...interface{}) {}
|
|
|
|
var nopLogger = func(_ string, _ ...interface{}) {}
|
|
|
@ -372,7 +350,6 @@ func (c *Client) WaitForDelete(resources ResourceList, timeout time.Duration) er
|
|
|
|
w := waiter{
|
|
|
|
w := waiter{
|
|
|
|
log: c.Log,
|
|
|
|
log: c.Log,
|
|
|
|
timeout: timeout,
|
|
|
|
timeout: timeout,
|
|
|
|
ctx: c.ctx,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return w.waitForDeletedResources(resources)
|
|
|
|
return w.waitForDeletedResources(resources)
|
|
|
|
}
|
|
|
|
}
|
|
|
|