mirror of
https://github.com/kubeshark/kubeshark.git
synced 2026-04-19 00:49:30 +00:00
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.
19 lines
320 B
Go
19 lines
320 B
Go
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
|
|
}
|