diff --git a/pkg/controller/recommendation/recommendation_rule_controller.go b/pkg/controller/recommendation/recommendation_rule_controller.go index d6f5dd596..feccea912 100644 --- a/pkg/controller/recommendation/recommendation_rule_controller.go +++ b/pkg/controller/recommendation/recommendation_rule_controller.go @@ -3,10 +3,6 @@ package recommendation import ( "context" "fmt" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/apimachinery/pkg/runtime/schema" - "k8s.io/client-go/dynamic/dynamicinformer" - "k8s.io/client-go/tools/cache" "sort" "strconv" "strings" @@ -19,12 +15,16 @@ import ( "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" unstructuredv1 "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/discovery" "k8s.io/client-go/dynamic" + "k8s.io/client-go/dynamic/dynamicinformer" "k8s.io/client-go/kubernetes" "k8s.io/client-go/scale" + "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/record" "k8s.io/client-go/util/retry" "k8s.io/klog/v2" @@ -34,7 +34,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/predicate" analysisv1alph1 "github.com/gocrane/api/analysis/v1alpha1" - "github.com/gocrane/crane/pkg/known" "github.com/gocrane/crane/pkg/metrics" "github.com/gocrane/crane/pkg/oom" diff --git a/pkg/controller/recommendation/recommendation_rule_controller_test.go b/pkg/controller/recommendation/recommendation_rule_controller_test.go index ba436ba66..f96536fcd 100644 --- a/pkg/controller/recommendation/recommendation_rule_controller_test.go +++ b/pkg/controller/recommendation/recommendation_rule_controller_test.go @@ -1,11 +1,12 @@ package recommendation import ( + "reflect" + "testing" + analysisv1alph1 "github.com/gocrane/api/analysis/v1alpha1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "reflect" - "testing" ) func TestRecommendationIndex_GetRecommendation(t *testing.T) { @@ -69,14 +70,15 @@ func TestRecommendationIndex_GetRecommendation(t *testing.T) { TargetRef: corev1.ObjectReference{ Namespace: "test-namespace", Kind: "Deployment", - Name: "test-deployment-name", + Name: "test-deployment-bar", APIVersion: "app/v1", }, + Type: analysisv1alph1.AnalysisTypeResource, }, }, args: args{ id: ObjectIdentity{ - Name: "test-deployment-name", + Name: "test-deployment-bar", Namespace: "test-namespace", APIVersion: "app/v1", Kind: "Deployment",