Adds a watch flag to the get command
The new flag fetch and display the request ressource and then continue watching the ressource until timeout or cancellation. A single ressource/ressource type is supported. Signed-off-by: Soule BA <soule@weave.works>
This commit is contained in:
@@ -134,7 +134,7 @@ func KubeConfig(kubeConfigPath string, kubeContext string) (*rest.Config, error)
|
||||
// KubeManger creates a Kubernetes client.Client. This interface exists to
|
||||
// facilitate unit testing and provide a fake client.
|
||||
type KubeManager interface {
|
||||
NewClient(string, string) (client.Client, error)
|
||||
NewClient(string, string) (client.WithWatch, error)
|
||||
}
|
||||
|
||||
type defaultKubeManager struct{}
|
||||
@@ -144,14 +144,14 @@ func DefaultKubeManager() KubeManager {
|
||||
return manager
|
||||
}
|
||||
|
||||
func (m defaultKubeManager) NewClient(kubeConfigPath string, kubeContext string) (client.Client, error) {
|
||||
func (m defaultKubeManager) NewClient(kubeConfigPath string, kubeContext string) (client.WithWatch, error) {
|
||||
cfg, err := KubeConfig(kubeConfigPath, kubeContext)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("kubernetes client initialization failed: %w", err)
|
||||
}
|
||||
|
||||
scheme := NewScheme()
|
||||
kubeClient, err := client.New(cfg, client.Options{
|
||||
kubeClient, err := client.NewWithWatch(cfg, client.Options{
|
||||
Scheme: scheme,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -179,7 +179,7 @@ func NewScheme() *apiruntime.Scheme {
|
||||
return scheme
|
||||
}
|
||||
|
||||
func KubeClient(kubeConfigPath string, kubeContext string) (client.Client, error) {
|
||||
func KubeClient(kubeConfigPath string, kubeContext string) (client.WithWatch, error) {
|
||||
m := DefaultKubeManager()
|
||||
kubeClient, err := m.NewClient(kubeConfigPath, kubeContext)
|
||||
return kubeClient, err
|
||||
|
||||
Reference in New Issue
Block a user