fix: resolve missing restrict resources namespace

This commit is contained in:
2025-03-04 23:55:28 +03:30
parent 75d0557286
commit 346f69100c
4 changed files with 15 additions and 10 deletions

View File

@@ -2,6 +2,7 @@ package crd
import (
"flink-kube-operator/internal/crd/v1alpha1"
"os"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/dynamic"
@@ -12,7 +13,7 @@ import (
)
type Crd struct {
client dynamic.NamespaceableResourceInterface
client dynamic.ResourceInterface
runtimeClient client.Client
}
@@ -32,12 +33,12 @@ func New() *Crd {
panic(err)
}
shema := runtime.NewScheme()
v1alpha1.AddKnownTypes(shema)
scheme := runtime.NewScheme()
v1alpha1.AddKnownTypes(scheme)
// Get FlinkJob resource interface
flinkJobClient := dynamicClient.Resource(v1alpha1.FlinkJobGVR)
flinkJobClient := dynamicClient.Resource(v1alpha1.FlinkJobGVR).Namespace(os.Getenv("NAMESPACE"))
runtimeClient, err := client.New(config.GetConfigOrDie(), client.Options{
Scheme: shema,
Scheme: scheme,
})
if err != nil {
panic(err)