mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-09-05 12:33:20 +00:00
Refactor watch pods to allow reusing watch wrapper (#470)
Currently shared/kubernetes/watch.go:FilteredWatch only watches pods. This PR makes it reusable for other types of resources. This is done in preparation for watching k8s events.
This commit is contained in:
committed by
GitHub
parent
dd53a36d5f
commit
2e75834dd0
18
shared/kubernetes/watchEvent.go
Normal file
18
shared/kubernetes/watchEvent.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package kubernetes
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
||||
type WatchEvent watch.Event
|
||||
|
||||
func (we *WatchEvent) ToPod() (*corev1.Pod, error) {
|
||||
pod, ok := we.Object.(*corev1.Pod)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("Invalid object type on pod event stream")
|
||||
}
|
||||
|
||||
return pod, nil
|
||||
}
|
Reference in New Issue
Block a user