mirror of
https://github.com/fluxcd/flux2.git
synced 2026-04-30 07:08:51 +00:00
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:
parent
d1970185b9
commit
c18d0b9217
22 changed files with 534 additions and 67 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue