diff --git a/apps/infra/internal/app/graph/generated/generated.go b/apps/infra/internal/app/graph/generated/generated.go index a817e42bf..c560cf602 100644 --- a/apps/infra/internal/app/graph/generated/generated.go +++ b/apps/infra/internal/app/graph/generated/generated.go @@ -7967,6 +7967,7 @@ input SearchCluster { isReady: MatchFilterIn region: MatchFilterIn text: MatchFilterIn + allClusters: MatchFilterIn } input SearchGlobalVPNs { @@ -58897,7 +58898,7 @@ func (ec *executionContext) unmarshalInputSearchCluster(ctx context.Context, obj asMap[k] = v } - fieldsInOrder := [...]string{"cloudProviderName", "isReady", "region", "text"} + fieldsInOrder := [...]string{"cloudProviderName", "isReady", "region", "text", "allClusters"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -58932,6 +58933,13 @@ func (ec *executionContext) unmarshalInputSearchCluster(ctx context.Context, obj return it, err } it.Text = data + case "allClusters": + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("allClusters")) + data, err := ec.unmarshalOMatchFilterIn2ᚖgithubᚗcomᚋkloudliteᚋapiᚋpkgᚋreposᚐMatchFilter(ctx, v) + if err != nil { + return it, err + } + it.AllClusters = data } } diff --git a/apps/infra/internal/app/graph/model/models_gen.go b/apps/infra/internal/app/graph/model/models_gen.go index cfad554f2..0bddb7e7a 100644 --- a/apps/infra/internal/app/graph/model/models_gen.go +++ b/apps/infra/internal/app/graph/model/models_gen.go @@ -1452,6 +1452,7 @@ type SearchCluster struct { IsReady *repos.MatchFilter `json:"isReady,omitempty"` Region *repos.MatchFilter `json:"region,omitempty"` Text *repos.MatchFilter `json:"text,omitempty"` + AllClusters *repos.MatchFilter `json:"allClusters,omitempty"` } type SearchDomainEntry struct { diff --git a/apps/infra/internal/app/graph/schema.graphqls b/apps/infra/internal/app/graph/schema.graphqls index 49ba7eff6..663ba3898 100644 --- a/apps/infra/internal/app/graph/schema.graphqls +++ b/apps/infra/internal/app/graph/schema.graphqls @@ -24,6 +24,7 @@ input SearchCluster { isReady: MatchFilterIn region: MatchFilterIn text: MatchFilterIn + allClusters: MatchFilterIn } input SearchGlobalVPNs { diff --git a/apps/infra/internal/app/graph/schema.resolvers.go b/apps/infra/internal/app/graph/schema.resolvers.go index 7e1cdb407..382751dbe 100644 --- a/apps/infra/internal/app/graph/schema.resolvers.go +++ b/apps/infra/internal/app/graph/schema.resolvers.go @@ -8,6 +8,7 @@ import ( "context" "encoding/base64" "fmt" + fc "github.com/kloudlite/api/apps/infra/internal/entities/field-constants" "github.com/kloudlite/api/pkg/errors" "github.com/kloudlite/api/apps/infra/internal/app/graph/generated" @@ -382,6 +383,16 @@ func (r *queryResolver) InfraListClusters(ctx context.Context, search *model.Sea if search.Text != nil { filter[fields.MetadataName] = *search.Text } + + if search.AllClusters == nil { + filter[fc.ClusterOwnedBy] = repos.MatchFilter{ + MatchType: repos.MatchTypeArray, + Array: []any{ + ictx.UserId, + nil, + }, + } + } } pClusters, err := r.Domain.ListClusters(ictx, filter, *pagination) @@ -421,6 +432,16 @@ func (r *queryResolver) InfraListBYOKClusters(ctx context.Context, search *model } } + if search == nil || search.AllClusters == nil { + filter[fc.ClusterOwnedBy] = repos.MatchFilter{ + MatchType: repos.MatchTypeArray, + Array: []any{ + ictx.UserId, + nil, + }, + } + } + globalVPNs, err := r.Domain.ListBYOKCluster(ictx, filter, *pagination) if err != nil { return nil, errors.NewE(err) diff --git a/apps/infra/internal/domain/byok-clusters.go b/apps/infra/internal/domain/byok-clusters.go index e6fcf2fb6..06c9651e8 100644 --- a/apps/infra/internal/domain/byok-clusters.go +++ b/apps/infra/internal/domain/byok-clusters.go @@ -158,10 +158,10 @@ func (d *domain) ListBYOKCluster(ctx InfraContext, search map[string]repos.Match f := repos.Filter{ fields.AccountName: ctx.AccountName, - "$or": []map[string]any{ - {fc.BYOKClusterOwnedBy: ctx.UserId}, - {fc.BYOKClusterOwnedBy: nil}, - }, + // "$or": []map[string]any{ + // {fc.BYOKClusterOwnedBy: ctx.UserId}, + // {fc.BYOKClusterOwnedBy: nil}, + // }, } pRecords, err := d.byokClusterRepo.FindPaginated(ctx, d.byokClusterRepo.MergeMatchFilters(f, search), pagination) diff --git a/apps/infra/internal/domain/clusters.go b/apps/infra/internal/domain/clusters.go index 16faad548..b3fc41cda 100644 --- a/apps/infra/internal/domain/clusters.go +++ b/apps/infra/internal/domain/clusters.go @@ -903,10 +903,10 @@ func (d *domain) ListClusters(ctx InfraContext, mf map[string]repos.MatchFilter, f := repos.Filter{ fields.AccountName: ctx.AccountName, fields.MetadataNamespace: accNs, - "$or": []map[string]any{ - {fc.ClusterOwnedBy: ctx.UserId}, - {fc.ClusterOwnedBy: nil}, - }, + // "$or": []map[string]any{ + // {fc.ClusterOwnedBy: ctx.UserId}, + // {fc.ClusterOwnedBy: nil}, + // }, } pr, err := d.clusterRepo.FindPaginated(ctx, d.clusterRepo.MergeMatchFilters(f, mf), pagination)