@@ -35,6 +35,7 @@ import (
3535 "k8s.io/apimachinery/pkg/util/wait"
3636
3737 v1 "github.com/api7/api7-ingress-controller/api/dashboard/v1"
38+ "github.com/api7/api7-ingress-controller/internal/controller/config"
3839 "github.com/api7/api7-ingress-controller/pkg/dashboard/cache"
3940 "github.com/api7/gopkg/pkg/log"
4041)
@@ -510,13 +511,24 @@ func (c *cluster) getResource(ctx context.Context, url, resource string) (*getRe
510511 return & res , nil
511512}
512513
514+ func addQueryParam (urlStr , key , value string ) string {
515+ parsedUrl , err := url .Parse (urlStr )
516+ if err != nil {
517+ return urlStr
518+ }
519+ query := parsedUrl .Query ()
520+ query .Add (key , value )
521+ parsedUrl .RawQuery = query .Encode ()
522+ return parsedUrl .String ()
523+ }
524+
513525func (c * cluster ) listResource (ctx context.Context , url , resource string ) (listResponse , error ) {
514526 log .Debugw ("list resource in cluster" ,
515527 zap .String ("cluster_name" , c .name ),
516528 zap .String ("name" , resource ),
517529 zap .String ("url" , url ),
518530 )
519-
531+ url = addQueryParam ( url , fmt . Sprintf ( "labels[%s]" , "controller_name" ), config . ControllerConfig . ControllerName )
520532 req , err := http .NewRequestWithContext (ctx , http .MethodGet , url , nil )
521533 if err != nil {
522534 return listResponse {}, err
0 commit comments