fix: resolve missing restrict resources namespace
This commit is contained in:
@@ -21,23 +21,28 @@ func (crd Crd) watchFlinkJobs() rxgo.Observable {
|
||||
|
||||
go func() {
|
||||
pkg.Logger.Debug("[crd] starting watch")
|
||||
watcher, err := crd.client.Namespace(os.Getenv("NAMESPACE")).Watch(context.Background(), metaV1.ListOptions{})
|
||||
watcher, err := crd.client.Watch(context.Background(), metaV1.ListOptions{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer watcher.Stop()
|
||||
namespace := os.Getenv("NAMESPACE")
|
||||
pkg.Logger.Debug("[crd] [watch]", zap.String("namespace", namespace))
|
||||
for event := range watcher.ResultChan() {
|
||||
unstructuredJob := event.Object.(*unstructured.Unstructured)
|
||||
unstructuredMap, _, err := unstructured.NestedMap(unstructuredJob.Object)
|
||||
if err != nil {
|
||||
pkg.Logger.Error("cannot create unstructured map", zap.Error(err))
|
||||
pkg.Logger.Error("[crd] [watch]cannot create unstructured map", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
job := &v1alpha1.FlinkJob{}
|
||||
|
||||
err = runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredMap, job)
|
||||
if err != nil {
|
||||
pkg.Logger.Error("cannot convert unstructured to structured", zap.Error(err))
|
||||
pkg.Logger.Error("[crd] [watch]cannot convert unstructured to structured", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
if job.Namespace != namespace {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user