From 5c9563421a75f992d783b462121d607ee7a1bcde Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 9 Apr 2024 16:37:57 +0530 Subject: [PATCH] :sparkles: Added cluster-group --- apps/infra/Taskfile.yml | 3 +- apps/infra/internal/app/gqlgen.yml | 7 + .../app/graph/clustergroup.resolvers.go | 47 + .../internal/app/graph/generated/generated.go | 2550 ++++++++++++++++- .../internal/app/graph/model/models_gen.go | 20 + apps/infra/internal/app/graph/schema.graphqls | 12 + .../internal/app/graph/schema.resolvers.go | 94 +- .../graph/struct-to-graphql/cluster.graphqls | 2 + .../struct-to-graphql/clustergroup.graphqls | 29 + .../struct-to-graphql/common-types.graphqls | 5 + apps/infra/internal/domain/api.go | 8 + apps/infra/internal/domain/cluster-group.go | 156 + apps/infra/internal/domain/clusters.go | 2 +- apps/infra/internal/entities/cluster-group.go | 2 + 14 files changed, 2805 insertions(+), 132 deletions(-) create mode 100644 apps/infra/internal/app/graph/clustergroup.resolvers.go create mode 100644 apps/infra/internal/app/graph/struct-to-graphql/clustergroup.graphqls diff --git a/apps/infra/Taskfile.yml b/apps/infra/Taskfile.yml index 9331d3c96..13c48c9ea 100644 --- a/apps/infra/Taskfile.yml +++ b/apps/infra/Taskfile.yml @@ -22,6 +22,7 @@ tasks: --struct github.com/kloudlite/api/apps/infra/internal/entities.MsvcTemplate --struct github.com/kloudlite/api/apps/infra/internal/entities.Node --struct github.com/kloudlite/api/apps/infra/internal/entities.NodePool + --struct github.com/kloudlite/api/apps/infra/internal/entities.ClusterGroup --struct github.com/kloudlite/api/apps/infra/internal/entities.CloudProviderSecret --struct github.com/kloudlite/api/apps/infra/internal/entities.DomainEntry --struct github.com/kloudlite/api/apps/infra/internal/entities.HelmRelease @@ -35,7 +36,7 @@ tasks: > ./internal/app/_struct-to-graphql/main.go - |+ pushd ./internal/app/_struct-to-graphql - go run main.go --dev --out-dir ../graph/struct-to-graphql --with-pagination Cluster,Node,NodePool,CloudProviderSecret,DomainEntry,PersistentVolumeClaim,ClusterManagedService,HelmRelease,Namespace,VolumeAttachment,PersistentVolume + go run main.go --dev --out-dir ../graph/struct-to-graphql --with-pagination Cluster,Node,NodePool,ClusterGroup,CloudProviderSecret,DomainEntry,PersistentVolumeClaim,ClusterManagedService,HelmRelease,Namespace,VolumeAttachment,PersistentVolume popd - rm -rf ./internal/app/_struct-to-graphql diff --git a/apps/infra/internal/app/gqlgen.yml b/apps/infra/internal/app/gqlgen.yml index 92337554e..c790193f8 100644 --- a/apps/infra/internal/app/gqlgen.yml +++ b/apps/infra/internal/app/gqlgen.yml @@ -74,6 +74,13 @@ models: resolver: true ClusterIn: *cluster-model + ClusterGroup: &cluster-group-model + model: github.com/kloudlite/api/apps/infra/internal/entities.ClusterGroup + fields: + adminKubeconfig: + resolver: true + ClusterGroupIn: *cluster-group-model + BYOKCluster: &byok-cluster-model model: github.com/kloudlite/api/apps/infra/internal/entities.BYOKCluster BYOKClusterIn: *byok-cluster-model diff --git a/apps/infra/internal/app/graph/clustergroup.resolvers.go b/apps/infra/internal/app/graph/clustergroup.resolvers.go new file mode 100644 index 000000000..1c91c5b67 --- /dev/null +++ b/apps/infra/internal/app/graph/clustergroup.resolvers.go @@ -0,0 +1,47 @@ +package graph + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.39 + +import ( + "context" + "time" + + "github.com/kloudlite/api/apps/infra/internal/app/graph/generated" + "github.com/kloudlite/api/apps/infra/internal/entities" + "github.com/kloudlite/api/pkg/errors" + "github.com/kloudlite/api/pkg/repos" +) + +// CreationTime is the resolver for the creationTime field. +func (r *clusterGroupResolver) CreationTime(ctx context.Context, obj *entities.ClusterGroup) (string, error) { + if obj == nil { + return "", errors.Newf("clusterGroup obj is nil") + } + + return obj.CreationTime.Format(time.RFC3339), nil +} + +// ID is the resolver for the id field. +func (r *clusterGroupResolver) ID(ctx context.Context, obj *entities.ClusterGroup) (repos.ID, error) { + if obj == nil { + return "", errors.Newf("clusterGroup obj is nil") + } + + return obj.Id, nil +} + +// UpdateTime is the resolver for the updateTime field. +func (r *clusterGroupResolver) UpdateTime(ctx context.Context, obj *entities.ClusterGroup) (string, error) { + if obj == nil { + return "", errors.Newf("clusterGroup obj is nil") + } + + return obj.UpdateTime.Format(time.RFC3339), nil +} + +// ClusterGroup returns generated.ClusterGroupResolver implementation. +func (r *Resolver) ClusterGroup() generated.ClusterGroupResolver { return &clusterGroupResolver{r} } + +type clusterGroupResolver struct{ *Resolver } diff --git a/apps/infra/internal/app/graph/generated/generated.go b/apps/infra/internal/app/graph/generated/generated.go index b0eeecb62..f516d9381 100644 --- a/apps/infra/internal/app/graph/generated/generated.go +++ b/apps/infra/internal/app/graph/generated/generated.go @@ -49,6 +49,7 @@ type ResolverRoot interface { BYOKCluster() BYOKClusterResolver CloudProviderSecret() CloudProviderSecretResolver Cluster() ClusterResolver + ClusterGroup() ClusterGroupResolver ClusterManagedService() ClusterManagedServiceResolver DomainEntry() DomainEntryResolver Github__com___kloudlite___api___apps___infra___internal___entities__MsvcTemplateEntry() Github__com___kloudlite___api___apps___infra___internal___entities__MsvcTemplateEntryResolver @@ -141,6 +142,7 @@ type ComplexityRoot struct { APIVersion func(childComplexity int) int AccountName func(childComplexity int) int AdminKubeconfig func(childComplexity int) int + ClusterGroupName func(childComplexity int) int CreatedBy func(childComplexity int) int CreationTime func(childComplexity int) int DisplayName func(childComplexity int) int @@ -161,6 +163,31 @@ type ComplexityRoot struct { Node func(childComplexity int) int } + ClusterGroup struct { + AccountName func(childComplexity int) int + ClusterName func(childComplexity int) int + CreatedBy func(childComplexity int) int + CreationTime func(childComplexity int) int + DisplayName func(childComplexity int) int + ID func(childComplexity int) int + LastUpdatedBy func(childComplexity int) int + MarkedForDeletion func(childComplexity int) int + RecordVersion func(childComplexity int) int + SyncStatus func(childComplexity int) int + UpdateTime func(childComplexity int) int + } + + ClusterGroupEdge struct { + Cursor func(childComplexity int) int + Node func(childComplexity int) int + } + + ClusterGroupPaginatedRecords struct { + Edges func(childComplexity int) int + PageInfo func(childComplexity int) int + TotalCount func(childComplexity int) int + } + ClusterManagedService struct { APIVersion func(childComplexity int) int AccountName func(childComplexity int) int @@ -420,6 +447,7 @@ type ComplexityRoot struct { GcpProjectID func(childComplexity int) int MasterNodes func(childComplexity int) int Region func(childComplexity int) int + Vpc func(childComplexity int) int } Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig struct { @@ -440,6 +468,10 @@ type ComplexityRoot struct { Region func(childComplexity int) int } + Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams struct { + Name func(childComplexity int) int + } + Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps struct { AvailabilityZone func(childComplexity int) int KloudliteRelease func(childComplexity int) int @@ -1035,12 +1067,14 @@ type ComplexityRoot struct { Mutation struct { InfraCreateBYOKCluster func(childComplexity int, cluster entities.BYOKCluster) int InfraCreateCluster func(childComplexity int, cluster entities.Cluster) int + InfraCreateClusterGroup func(childComplexity int, cluster entities.ClusterGroup) int InfraCreateClusterManagedService func(childComplexity int, clusterName string, service entities.ClusterManagedService) int InfraCreateDomainEntry func(childComplexity int, domainEntry entities.DomainEntry) int InfraCreateHelmRelease func(childComplexity int, clusterName string, release entities.HelmRelease) int InfraCreateNodePool func(childComplexity int, clusterName string, pool entities.NodePool) int InfraCreateProviderSecret func(childComplexity int, secret entities.CloudProviderSecret) int InfraDeleteCluster func(childComplexity int, name string) int + InfraDeleteClusterGroup func(childComplexity int, name string) int InfraDeleteClusterManagedService func(childComplexity int, clusterName string, serviceName string) int InfraDeleteDomainEntry func(childComplexity int, domainName string) int InfraDeleteHelmRelease func(childComplexity int, clusterName string, releaseName string) int @@ -1048,6 +1082,7 @@ type ComplexityRoot struct { InfraDeleteProviderSecret func(childComplexity int, secretName string) int InfraDeletePv func(childComplexity int, clusterName string, pvName string) int InfraUpdateCluster func(childComplexity int, cluster entities.Cluster) int + InfraUpdateClusterGroup func(childComplexity int, cluster entities.ClusterGroup) int InfraUpdateClusterManagedService func(childComplexity int, clusterName string, service entities.ClusterManagedService) int InfraUpdateDomainEntry func(childComplexity int, domainEntry entities.DomainEntry) int InfraUpdateHelmRelease func(childComplexity int, clusterName string, release entities.HelmRelease) int @@ -1214,6 +1249,7 @@ type ComplexityRoot struct { InfraCheckAwsAccess func(childComplexity int, cloudproviderName string) int InfraCheckNameAvailability func(childComplexity int, resType domain.ResType, clusterName *string, name string) int InfraGetCluster func(childComplexity int, name string) int + InfraGetClusterGroup func(childComplexity int, name string) int InfraGetClusterManagedService func(childComplexity int, clusterName string, name string) int InfraGetDomainEntry func(childComplexity int, domainName string) int InfraGetHelmRelease func(childComplexity int, clusterName string, name string) int @@ -1224,6 +1260,7 @@ type ComplexityRoot struct { InfraGetPv func(childComplexity int, clusterName string, name string) int InfraGetPvc func(childComplexity int, clusterName string, name string) int InfraGetVolumeAttachment func(childComplexity int, clusterName string, name string) int + InfraListClusterGroups func(childComplexity int, search *model.SearchClusterGroup, pagination *repos.CursorPagination) int InfraListClusterManagedServices func(childComplexity int, clusterName string, search *model.SearchClusterManagedService, pagination *repos.CursorPagination) int InfraListClusters func(childComplexity int, search *model.SearchCluster, pagination *repos.CursorPagination) int InfraListDomainEntries func(childComplexity int, search *model.SearchDomainEntry, pagination *repos.CursorPagination) int @@ -1303,6 +1340,13 @@ type ClusterResolver interface { UpdateTime(ctx context.Context, obj *entities.Cluster) (string, error) AdminKubeconfig(ctx context.Context, obj *entities.Cluster) (*model.EncodedValue, error) } +type ClusterGroupResolver interface { + CreationTime(ctx context.Context, obj *entities.ClusterGroup) (string, error) + + ID(ctx context.Context, obj *entities.ClusterGroup) (repos.ID, error) + + UpdateTime(ctx context.Context, obj *entities.ClusterGroup) (string, error) +} type ClusterManagedServiceResolver interface { CreationTime(ctx context.Context, obj *entities.ClusterManagedService) (string, error) @@ -1365,6 +1409,9 @@ type MutationResolver interface { InfraCreateCluster(ctx context.Context, cluster entities.Cluster) (*entities.Cluster, error) InfraUpdateCluster(ctx context.Context, cluster entities.Cluster) (*entities.Cluster, error) InfraDeleteCluster(ctx context.Context, name string) (bool, error) + InfraCreateClusterGroup(ctx context.Context, cluster entities.ClusterGroup) (*entities.ClusterGroup, error) + InfraUpdateClusterGroup(ctx context.Context, cluster entities.ClusterGroup) (*entities.ClusterGroup, error) + InfraDeleteClusterGroup(ctx context.Context, name string) (bool, error) InfraCreateBYOKCluster(ctx context.Context, cluster entities.BYOKCluster) (*entities.BYOKCluster, error) InfraUpgradeHelmKloudliteAgent(ctx context.Context, clusterName string) (bool, error) InfraCreateProviderSecret(ctx context.Context, secret entities.CloudProviderSecret) (*entities.CloudProviderSecret, error) @@ -1435,6 +1482,8 @@ type QueryResolver interface { InfraCheckNameAvailability(ctx context.Context, resType domain.ResType, clusterName *string, name string) (*domain.CheckNameAvailabilityOutput, error) InfraListClusters(ctx context.Context, search *model.SearchCluster, pagination *repos.CursorPagination) (*model.ClusterPaginatedRecords, error) InfraGetCluster(ctx context.Context, name string) (*entities.Cluster, error) + InfraListClusterGroups(ctx context.Context, search *model.SearchClusterGroup, pagination *repos.CursorPagination) (*model.ClusterGroupPaginatedRecords, error) + InfraGetClusterGroup(ctx context.Context, name string) (*entities.ClusterGroup, error) InfraListNodePools(ctx context.Context, clusterName string, search *model.SearchNodepool, pagination *repos.CursorPagination) (*model.NodePoolPaginatedRecords, error) InfraGetNodePool(ctx context.Context, clusterName string, poolName string) (*entities.NodePool, error) InfraListProviderSecrets(ctx context.Context, search *model.SearchProviderSecret, pagination *repos.CursorPagination) (*model.CloudProviderSecretPaginatedRecords, error) @@ -1792,6 +1841,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Cluster.AdminKubeconfig(childComplexity), true + case "Cluster.clusterGroupName": + if e.complexity.Cluster.ClusterGroupName == nil { + break + } + + return e.complexity.Cluster.ClusterGroupName(childComplexity), true + case "Cluster.createdBy": if e.complexity.Cluster.CreatedBy == nil { break @@ -1897,6 +1953,118 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.ClusterEdge.Node(childComplexity), true + case "ClusterGroup.accountName": + if e.complexity.ClusterGroup.AccountName == nil { + break + } + + return e.complexity.ClusterGroup.AccountName(childComplexity), true + + case "ClusterGroup.clusterName": + if e.complexity.ClusterGroup.ClusterName == nil { + break + } + + return e.complexity.ClusterGroup.ClusterName(childComplexity), true + + case "ClusterGroup.createdBy": + if e.complexity.ClusterGroup.CreatedBy == nil { + break + } + + return e.complexity.ClusterGroup.CreatedBy(childComplexity), true + + case "ClusterGroup.creationTime": + if e.complexity.ClusterGroup.CreationTime == nil { + break + } + + return e.complexity.ClusterGroup.CreationTime(childComplexity), true + + case "ClusterGroup.displayName": + if e.complexity.ClusterGroup.DisplayName == nil { + break + } + + return e.complexity.ClusterGroup.DisplayName(childComplexity), true + + case "ClusterGroup.id": + if e.complexity.ClusterGroup.ID == nil { + break + } + + return e.complexity.ClusterGroup.ID(childComplexity), true + + case "ClusterGroup.lastUpdatedBy": + if e.complexity.ClusterGroup.LastUpdatedBy == nil { + break + } + + return e.complexity.ClusterGroup.LastUpdatedBy(childComplexity), true + + case "ClusterGroup.markedForDeletion": + if e.complexity.ClusterGroup.MarkedForDeletion == nil { + break + } + + return e.complexity.ClusterGroup.MarkedForDeletion(childComplexity), true + + case "ClusterGroup.recordVersion": + if e.complexity.ClusterGroup.RecordVersion == nil { + break + } + + return e.complexity.ClusterGroup.RecordVersion(childComplexity), true + + case "ClusterGroup.syncStatus": + if e.complexity.ClusterGroup.SyncStatus == nil { + break + } + + return e.complexity.ClusterGroup.SyncStatus(childComplexity), true + + case "ClusterGroup.updateTime": + if e.complexity.ClusterGroup.UpdateTime == nil { + break + } + + return e.complexity.ClusterGroup.UpdateTime(childComplexity), true + + case "ClusterGroupEdge.cursor": + if e.complexity.ClusterGroupEdge.Cursor == nil { + break + } + + return e.complexity.ClusterGroupEdge.Cursor(childComplexity), true + + case "ClusterGroupEdge.node": + if e.complexity.ClusterGroupEdge.Node == nil { + break + } + + return e.complexity.ClusterGroupEdge.Node(childComplexity), true + + case "ClusterGroupPaginatedRecords.edges": + if e.complexity.ClusterGroupPaginatedRecords.Edges == nil { + break + } + + return e.complexity.ClusterGroupPaginatedRecords.Edges(childComplexity), true + + case "ClusterGroupPaginatedRecords.pageInfo": + if e.complexity.ClusterGroupPaginatedRecords.PageInfo == nil { + break + } + + return e.complexity.ClusterGroupPaginatedRecords.PageInfo(childComplexity), true + + case "ClusterGroupPaginatedRecords.totalCount": + if e.complexity.ClusterGroupPaginatedRecords.TotalCount == nil { + break + } + + return e.complexity.ClusterGroupPaginatedRecords.TotalCount(childComplexity), true + case "ClusterManagedService.apiVersion": if e.complexity.ClusterManagedService.APIVersion == nil { break @@ -3052,6 +3220,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig.Region(childComplexity), true + case "Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig.vpc": + if e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig.Vpc == nil { + break + } + + return e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig.Vpc(childComplexity), true + case "Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig.nodes": if e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig.Nodes == nil { break @@ -3136,6 +3311,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GCPNodePoolConfig.Region(childComplexity), true + case "Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams.name": + if e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams.Name == nil { + break + } + + return e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams.Name(childComplexity), true + case "Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps.availabilityZone": if e.complexity.Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps.AvailabilityZone == nil { break @@ -5624,6 +5806,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.InfraCreateCluster(childComplexity, args["cluster"].(entities.Cluster)), true + case "Mutation.infra_createClusterGroup": + if e.complexity.Mutation.InfraCreateClusterGroup == nil { + break + } + + args, err := ec.field_Mutation_infra_createClusterGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.InfraCreateClusterGroup(childComplexity, args["cluster"].(entities.ClusterGroup)), true + case "Mutation.infra_createClusterManagedService": if e.complexity.Mutation.InfraCreateClusterManagedService == nil { break @@ -5696,6 +5890,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.InfraDeleteCluster(childComplexity, args["name"].(string)), true + case "Mutation.infra_deleteClusterGroup": + if e.complexity.Mutation.InfraDeleteClusterGroup == nil { + break + } + + args, err := ec.field_Mutation_infra_deleteClusterGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.InfraDeleteClusterGroup(childComplexity, args["name"].(string)), true + case "Mutation.infra_deleteClusterManagedService": if e.complexity.Mutation.InfraDeleteClusterManagedService == nil { break @@ -5780,6 +5986,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Mutation.InfraUpdateCluster(childComplexity, args["cluster"].(entities.Cluster)), true + case "Mutation.infra_updateClusterGroup": + if e.complexity.Mutation.InfraUpdateClusterGroup == nil { + break + } + + args, err := ec.field_Mutation_infra_updateClusterGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Mutation.InfraUpdateClusterGroup(childComplexity, args["cluster"].(entities.ClusterGroup)), true + case "Mutation.infra_updateClusterManagedService": if e.complexity.Mutation.InfraUpdateClusterManagedService == nil { break @@ -6630,6 +6848,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.InfraGetCluster(childComplexity, args["name"].(string)), true + case "Query.infra_getClusterGroup": + if e.complexity.Query.InfraGetClusterGroup == nil { + break + } + + args, err := ec.field_Query_infra_getClusterGroup_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.InfraGetClusterGroup(childComplexity, args["name"].(string)), true + case "Query.infra_getClusterManagedService": if e.complexity.Query.InfraGetClusterManagedService == nil { break @@ -6750,6 +6980,18 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Query.InfraGetVolumeAttachment(childComplexity, args["clusterName"].(string), args["name"].(string)), true + case "Query.infra_listClusterGroups": + if e.complexity.Query.InfraListClusterGroups == nil { + break + } + + args, err := ec.field_Query_infra_listClusterGroups_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Query.InfraListClusterGroups(childComplexity, args["search"].(*model.SearchClusterGroup), args["pagination"].(*repos.CursorPagination)), true + case "Query.infra_listClusterManagedServices": if e.complexity.Query.InfraListClusterManagedServices == nil { break @@ -7048,6 +7290,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { inputUnmarshalMap := graphql.BuildUnmarshalerMap( ec.unmarshalInputBYOKClusterIn, ec.unmarshalInputCloudProviderSecretIn, + ec.unmarshalInputClusterGroupIn, ec.unmarshalInputClusterIn, ec.unmarshalInputClusterManagedServiceIn, ec.unmarshalInputCursorPaginationIn, @@ -7141,6 +7384,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { ec.unmarshalInputNodePoolIn, ec.unmarshalInputPersistentVolumeIn, ec.unmarshalInputSearchCluster, + ec.unmarshalInputSearchClusterGroup, ec.unmarshalInputSearchClusterManagedService, ec.unmarshalInputSearchDomainEntry, ec.unmarshalInputSearchHelmRelease, @@ -7273,6 +7517,10 @@ input SearchCluster { text: MatchFilterIn } +input SearchClusterGroup { + text: MatchFilterIn +} + input SearchClusterManagedService { isReady: MatchFilterIn text: MatchFilterIn @@ -7326,6 +7574,10 @@ type Query { infra_listClusters(search: SearchCluster, pagination: CursorPaginationIn): ClusterPaginatedRecords @isLoggedInAndVerified @hasAccount infra_getCluster(name: String!): Cluster @isLoggedInAndVerified @hasAccount + # cluster groups + infra_listClusterGroups(search: SearchClusterGroup, pagination: CursorPaginationIn): ClusterGroupPaginatedRecords @isLoggedInAndVerified @hasAccount + infra_getClusterGroup(name: String!): ClusterGroup @isLoggedInAndVerified @hasAccount + # get node pools infra_listNodePools(clusterName: String!, search: SearchNodepool, pagination: CursorPaginationIn): NodePoolPaginatedRecords @isLoggedInAndVerified @hasAccount infra_getNodePool(clusterName: String!, poolName: String!): NodePool @isLoggedInAndVerified @hasAccount @@ -7369,6 +7621,10 @@ type Mutation { infra_updateCluster(cluster: ClusterIn!): Cluster @isLoggedInAndVerified @hasAccount infra_deleteCluster(name: String!): Boolean! @isLoggedInAndVerified @hasAccount # infra_resyncCluster(name: String!): Boolean! @isLoggedInAndVerified @hasAccount + + infra_createClusterGroup(cluster: ClusterGroupIn!): ClusterGroup @isLoggedInAndVerified @hasAccount + infra_updateClusterGroup(cluster: ClusterGroupIn!): ClusterGroup @isLoggedInAndVerified @hasAccount + infra_deleteClusterGroup(name: String!): Boolean! @isLoggedInAndVerified @hasAccount infra_createBYOKCluster(cluster: BYOKClusterIn!): BYOKCluster @isLoggedInAndVerified @hasAccount @@ -7466,6 +7722,7 @@ input CloudProviderSecretIn { {Name: "../struct-to-graphql/cluster.graphqls", Input: `type Cluster @shareable { accountName: String! apiVersion: String + clusterGroupName: String createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! creationTime: Date! displayName: String! @@ -7494,12 +7751,43 @@ type ClusterPaginatedRecords @shareable { input ClusterIn { apiVersion: String + clusterGroupName: String displayName: String! kind: String metadata: MetadataIn! spec: Github__com___kloudlite___operator___apis___clusters___v1__ClusterSpecIn! } +`, BuiltIn: false}, + {Name: "../struct-to-graphql/clustergroup.graphqls", Input: `type ClusterGroup @shareable { + accountName: String! + clusterName: String! + createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + creationTime: Date! + displayName: String! + id: ID! + lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + markedForDeletion: Boolean + recordVersion: Int! + syncStatus: Github__com___kloudlite___api___pkg___types__SyncStatus! + updateTime: Date! +} + +type ClusterGroupEdge @shareable { + cursor: String! + node: ClusterGroup! +} + +type ClusterGroupPaginatedRecords @shareable { + edges: [ClusterGroupEdge!]! + pageInfo: PageInfo! + totalCount: Int! +} + +input ClusterGroupIn { + displayName: String! +} + `, BuiltIn: false}, {Name: "../struct-to-graphql/clustermanagedservice.graphqls", Input: `type ClusterManagedService @shareable { accountName: String! @@ -7724,6 +8012,7 @@ type Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig gcpProjectID: String! masterNodes: Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig region: String! + vpc: Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams } type Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig @shareable { @@ -7744,6 +8033,10 @@ type Github__com___kloudlite___operator___apis___clusters___v1__GCPNodePoolConfi region: String! } +type Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams @shareable { + name: String! +} + type Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps @shareable { availabilityZone: String! kloudliteRelease: String! @@ -9422,6 +9715,21 @@ func (ec *executionContext) field_Mutation_infra_createBYOKCluster_args(ctx cont return args, nil } +func (ec *executionContext) field_Mutation_infra_createClusterGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 entities.ClusterGroup + if tmp, ok := rawArgs["cluster"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cluster")) + arg0, err = ec.unmarshalNClusterGroupIn2githubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, tmp) + if err != nil { + return nil, err + } + } + args["cluster"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_infra_createClusterManagedService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -9539,6 +9847,21 @@ func (ec *executionContext) field_Mutation_infra_createProviderSecret_args(ctx c return args, nil } +func (ec *executionContext) field_Mutation_infra_deleteClusterGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_infra_deleteClusterManagedService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -9680,6 +10003,21 @@ func (ec *executionContext) field_Mutation_infra_deleteProviderSecret_args(ctx c return args, nil } +func (ec *executionContext) field_Mutation_infra_updateClusterGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 entities.ClusterGroup + if tmp, ok := rawArgs["cluster"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("cluster")) + arg0, err = ec.unmarshalNClusterGroupIn2githubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, tmp) + if err != nil { + return nil, err + } + } + args["cluster"] = arg0 + return args, nil +} + func (ec *executionContext) field_Mutation_infra_updateClusterManagedService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -9875,6 +10213,21 @@ func (ec *executionContext) field_Query_infra_checkNameAvailability_args(ctx con return args, nil } +func (ec *executionContext) field_Query_infra_getClusterGroup_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + func (ec *executionContext) field_Query_infra_getClusterManagedService_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -10112,6 +10465,30 @@ func (ec *executionContext) field_Query_infra_getVolumeAttachment_args(ctx conte return args, nil } +func (ec *executionContext) field_Query_infra_listClusterGroups_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *model.SearchClusterGroup + if tmp, ok := rawArgs["search"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("search")) + arg0, err = ec.unmarshalOSearchClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐSearchClusterGroup(ctx, tmp) + if err != nil { + return nil, err + } + } + args["search"] = arg0 + var arg1 *repos.CursorPagination + if tmp, ok := rawArgs["pagination"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("pagination")) + arg1, err = ec.unmarshalOCursorPaginationIn2ᚖgithubᚗcomᚋkloudliteᚋapiᚋpkgᚋreposᚐCursorPagination(ctx, tmp) + if err != nil { + return nil, err + } + } + args["pagination"] = arg1 + return args, nil +} + func (ec *executionContext) field_Query_infra_listClusterManagedServices_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -12188,6 +12565,47 @@ func (ec *executionContext) fieldContext_Cluster_apiVersion(ctx context.Context, return fc, nil } +func (ec *executionContext) _Cluster_clusterGroupName(ctx context.Context, field graphql.CollectedField, obj *entities.Cluster) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Cluster_clusterGroupName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ClusterGroupName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Cluster_clusterGroupName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Cluster", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Cluster_createdBy(ctx context.Context, field graphql.CollectedField, obj *entities.Cluster) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Cluster_createdBy(ctx, field) if err != nil { @@ -12979,6 +13397,8 @@ func (ec *executionContext) fieldContext_ClusterEdge_node(ctx context.Context, f return ec.fieldContext_Cluster_accountName(ctx, field) case "apiVersion": return ec.fieldContext_Cluster_apiVersion(ctx, field) + case "clusterGroupName": + return ec.fieldContext_Cluster_clusterGroupName(ctx, field) case "createdBy": return ec.fieldContext_Cluster_createdBy(ctx, field) case "creationTime": @@ -13014,6 +13434,777 @@ func (ec *executionContext) fieldContext_ClusterEdge_node(ctx context.Context, f return fc, nil } +func (ec *executionContext) _ClusterGroup_accountName(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_accountName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.AccountName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_accountName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_clusterName(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_clusterName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.ClusterName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_clusterName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_createdBy(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_createdBy(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.CreatedBy, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(common.CreatedOrUpdatedBy) + fc.Result = res + return ec.marshalNGithub__com___kloudlite___api___common__CreatedOrUpdatedBy2githubᚗcomᚋkloudliteᚋapiᚋcommonᚐCreatedOrUpdatedBy(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_createdBy(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "userEmail": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userEmail(ctx, field) + case "userId": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userId(ctx, field) + case "userName": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userName(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Github__com___kloudlite___api___common__CreatedOrUpdatedBy", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_creationTime(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_creationTime(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ClusterGroup().CreationTime(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNDate2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_creationTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Date does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_displayName(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_displayName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DisplayName, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_displayName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_id(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_id(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ClusterGroup().ID(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(repos.ID) + fc.Result = res + return ec.marshalNID2githubᚗcomᚋkloudliteᚋapiᚋpkgᚋreposᚐID(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type ID does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_lastUpdatedBy(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_lastUpdatedBy(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.LastUpdatedBy, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(common.CreatedOrUpdatedBy) + fc.Result = res + return ec.marshalNGithub__com___kloudlite___api___common__CreatedOrUpdatedBy2githubᚗcomᚋkloudliteᚋapiᚋcommonᚐCreatedOrUpdatedBy(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_lastUpdatedBy(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "userEmail": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userEmail(ctx, field) + case "userId": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userId(ctx, field) + case "userName": + return ec.fieldContext_Github__com___kloudlite___api___common__CreatedOrUpdatedBy_userName(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Github__com___kloudlite___api___common__CreatedOrUpdatedBy", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_markedForDeletion(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_markedForDeletion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MarkedForDeletion, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*bool) + fc.Result = res + return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_markedForDeletion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_recordVersion(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_recordVersion(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.RecordVersion, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_recordVersion(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_syncStatus(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_syncStatus(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SyncStatus, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(types.SyncStatus) + fc.Result = res + return ec.marshalNGithub__com___kloudlite___api___pkg___types__SyncStatus2githubᚗcomᚋkloudliteᚋapiᚋpkgᚋtypesᚐSyncStatus(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_syncStatus(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "action": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_action(ctx, field) + case "error": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_error(ctx, field) + case "lastSyncedAt": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_lastSyncedAt(ctx, field) + case "recordVersion": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_recordVersion(ctx, field) + case "state": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_state(ctx, field) + case "syncScheduledAt": + return ec.fieldContext_Github__com___kloudlite___api___pkg___types__SyncStatus_syncScheduledAt(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Github__com___kloudlite___api___pkg___types__SyncStatus", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroup_updateTime(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterGroup) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroup_updateTime(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.ClusterGroup().UpdateTime(rctx, obj) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNDate2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroup_updateTime(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroup", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Date does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroupEdge_cursor(ctx context.Context, field graphql.CollectedField, obj *model.ClusterGroupEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroupEdge_cursor(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Cursor, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroupEdge_cursor(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroupEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroupEdge_node(ctx context.Context, field graphql.CollectedField, obj *model.ClusterGroupEdge) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroupEdge_node(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Node, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*entities.ClusterGroup) + fc.Result = res + return ec.marshalNClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroupEdge_node(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroupEdge", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "accountName": + return ec.fieldContext_ClusterGroup_accountName(ctx, field) + case "clusterName": + return ec.fieldContext_ClusterGroup_clusterName(ctx, field) + case "createdBy": + return ec.fieldContext_ClusterGroup_createdBy(ctx, field) + case "creationTime": + return ec.fieldContext_ClusterGroup_creationTime(ctx, field) + case "displayName": + return ec.fieldContext_ClusterGroup_displayName(ctx, field) + case "id": + return ec.fieldContext_ClusterGroup_id(ctx, field) + case "lastUpdatedBy": + return ec.fieldContext_ClusterGroup_lastUpdatedBy(ctx, field) + case "markedForDeletion": + return ec.fieldContext_ClusterGroup_markedForDeletion(ctx, field) + case "recordVersion": + return ec.fieldContext_ClusterGroup_recordVersion(ctx, field) + case "syncStatus": + return ec.fieldContext_ClusterGroup_syncStatus(ctx, field) + case "updateTime": + return ec.fieldContext_ClusterGroup_updateTime(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ClusterGroup", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroupPaginatedRecords_edges(ctx context.Context, field graphql.CollectedField, obj *model.ClusterGroupPaginatedRecords) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroupPaginatedRecords_edges(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Edges, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]*model.ClusterGroupEdge) + fc.Result = res + return ec.marshalNClusterGroupEdge2ᚕᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupEdgeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroupPaginatedRecords_edges(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroupPaginatedRecords", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "cursor": + return ec.fieldContext_ClusterGroupEdge_cursor(ctx, field) + case "node": + return ec.fieldContext_ClusterGroupEdge_node(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ClusterGroupEdge", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroupPaginatedRecords_pageInfo(ctx context.Context, field graphql.CollectedField, obj *model.ClusterGroupPaginatedRecords) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroupPaginatedRecords_pageInfo(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PageInfo, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*model.PageInfo) + fc.Result = res + return ec.marshalNPageInfo2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐPageInfo(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroupPaginatedRecords_pageInfo(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroupPaginatedRecords", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "endCursor": + return ec.fieldContext_PageInfo_endCursor(ctx, field) + case "hasNextPage": + return ec.fieldContext_PageInfo_hasNextPage(ctx, field) + case "hasPreviousPage": + return ec.fieldContext_PageInfo_hasPreviousPage(ctx, field) + case "startCursor": + return ec.fieldContext_PageInfo_startCursor(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type PageInfo", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _ClusterGroupPaginatedRecords_totalCount(ctx context.Context, field graphql.CollectedField, obj *model.ClusterGroupPaginatedRecords) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ClusterGroupPaginatedRecords_totalCount(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.TotalCount, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(int) + fc.Result = res + return ec.marshalNInt2int(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ClusterGroupPaginatedRecords_totalCount(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ClusterGroupPaginatedRecords", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Int does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _ClusterManagedService_accountName(ctx context.Context, field graphql.CollectedField, obj *entities.ClusterManagedService) (ret graphql.Marshaler) { fc, err := ec.fieldContext_ClusterManagedService_accountName(ctx, field) if err != nil { @@ -20104,6 +21295,8 @@ func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___ap return ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_masterNodes(ctx, field) case "region": return ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_region(ctx, field) + case "vpc": + return ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_vpc(ctx, field) } return nil, fmt.Errorf("no field named %q was found under type Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig", field.Name) }, @@ -20533,6 +21726,51 @@ func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___ap return fc, nil } +func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_vpc(ctx context.Context, field graphql.CollectedField, obj *model.GithubComKloudliteOperatorApisClustersV1GCPClusterConfig) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_vpc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Vpc, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.GithubComKloudliteOperatorApisClustersV1GcpVPCParams) + fc.Result = res + return ec.marshalOGithub__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐGithubComKloudliteOperatorApisClustersV1GcpVPCParams(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_vpc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams_name(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams", field.Name) + }, + } + return fc, nil +} + func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig_nodes(ctx context.Context, field graphql.CollectedField, obj *model.GithubComKloudliteOperatorApisClustersV1GCPMasterNodesConfig) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig_nodes(ctx, field) if err != nil { @@ -21061,6 +22299,50 @@ func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___ap return fc, nil } +func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams_name(ctx context.Context, field graphql.CollectedField, obj *model.GithubComKloudliteOperatorApisClustersV1GcpVPCParams) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps_availabilityZone(ctx context.Context, field graphql.CollectedField, obj *model.GithubComKloudliteOperatorApisClustersV1MasterNodeProps) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps_availabilityZone(ctx, field) if err != nil { @@ -36808,24 +38090,333 @@ func (ec *executionContext) _Mutation_infra_createCluster(ctx context.Context, f if tmp == nil { return nil, nil } - if data, ok := tmp.(*entities.Cluster); ok { + if data, ok := tmp.(*entities.Cluster); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.Cluster`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*entities.Cluster) + fc.Result = res + return ec.marshalOCluster2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐCluster(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_infra_createCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "accountName": + return ec.fieldContext_Cluster_accountName(ctx, field) + case "apiVersion": + return ec.fieldContext_Cluster_apiVersion(ctx, field) + case "clusterGroupName": + return ec.fieldContext_Cluster_clusterGroupName(ctx, field) + case "createdBy": + return ec.fieldContext_Cluster_createdBy(ctx, field) + case "creationTime": + return ec.fieldContext_Cluster_creationTime(ctx, field) + case "displayName": + return ec.fieldContext_Cluster_displayName(ctx, field) + case "id": + return ec.fieldContext_Cluster_id(ctx, field) + case "kind": + return ec.fieldContext_Cluster_kind(ctx, field) + case "lastUpdatedBy": + return ec.fieldContext_Cluster_lastUpdatedBy(ctx, field) + case "markedForDeletion": + return ec.fieldContext_Cluster_markedForDeletion(ctx, field) + case "metadata": + return ec.fieldContext_Cluster_metadata(ctx, field) + case "recordVersion": + return ec.fieldContext_Cluster_recordVersion(ctx, field) + case "spec": + return ec.fieldContext_Cluster_spec(ctx, field) + case "status": + return ec.fieldContext_Cluster_status(ctx, field) + case "syncStatus": + return ec.fieldContext_Cluster_syncStatus(ctx, field) + case "updateTime": + return ec.fieldContext_Cluster_updateTime(ctx, field) + case "adminKubeconfig": + return ec.fieldContext_Cluster_adminKubeconfig(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Cluster", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_infra_createCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_infra_updateCluster(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_infra_updateCluster(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().InfraUpdateCluster(rctx, fc.Args["cluster"].(entities.Cluster)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedInAndVerified == nil { + return nil, errors.New("directive isLoggedInAndVerified is not implemented") + } + return ec.directives.IsLoggedInAndVerified(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.HasAccount == nil { + return nil, errors.New("directive hasAccount is not implemented") + } + return ec.directives.HasAccount(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*entities.Cluster); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.Cluster`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*entities.Cluster) + fc.Result = res + return ec.marshalOCluster2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐCluster(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_infra_updateCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "accountName": + return ec.fieldContext_Cluster_accountName(ctx, field) + case "apiVersion": + return ec.fieldContext_Cluster_apiVersion(ctx, field) + case "clusterGroupName": + return ec.fieldContext_Cluster_clusterGroupName(ctx, field) + case "createdBy": + return ec.fieldContext_Cluster_createdBy(ctx, field) + case "creationTime": + return ec.fieldContext_Cluster_creationTime(ctx, field) + case "displayName": + return ec.fieldContext_Cluster_displayName(ctx, field) + case "id": + return ec.fieldContext_Cluster_id(ctx, field) + case "kind": + return ec.fieldContext_Cluster_kind(ctx, field) + case "lastUpdatedBy": + return ec.fieldContext_Cluster_lastUpdatedBy(ctx, field) + case "markedForDeletion": + return ec.fieldContext_Cluster_markedForDeletion(ctx, field) + case "metadata": + return ec.fieldContext_Cluster_metadata(ctx, field) + case "recordVersion": + return ec.fieldContext_Cluster_recordVersion(ctx, field) + case "spec": + return ec.fieldContext_Cluster_spec(ctx, field) + case "status": + return ec.fieldContext_Cluster_status(ctx, field) + case "syncStatus": + return ec.fieldContext_Cluster_syncStatus(ctx, field) + case "updateTime": + return ec.fieldContext_Cluster_updateTime(ctx, field) + case "adminKubeconfig": + return ec.fieldContext_Cluster_adminKubeconfig(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Cluster", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_infra_updateCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_infra_deleteCluster(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_infra_deleteCluster(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().InfraDeleteCluster(rctx, fc.Args["name"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedInAndVerified == nil { + return nil, errors.New("directive isLoggedInAndVerified is not implemented") + } + return ec.directives.IsLoggedInAndVerified(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.HasAccount == nil { + return nil, errors.New("directive hasAccount is not implemented") + } + return ec.directives.HasAccount(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(bool); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.Cluster`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be bool`, tmp) }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*entities.Cluster) + res := resTmp.(bool) fc.Result = res - return ec.marshalOCluster2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐCluster(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_infra_createCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_infra_deleteCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Mutation", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Mutation_infra_deleteCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Mutation_infra_createClusterGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_infra_createClusterGroup(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Mutation().InfraCreateClusterGroup(rctx, fc.Args["cluster"].(entities.ClusterGroup)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedInAndVerified == nil { + return nil, errors.New("directive isLoggedInAndVerified is not implemented") + } + return ec.directives.IsLoggedInAndVerified(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.HasAccount == nil { + return nil, errors.New("directive hasAccount is not implemented") + } + return ec.directives.HasAccount(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*entities.ClusterGroup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.ClusterGroup`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*entities.ClusterGroup) + fc.Result = res + return ec.marshalOClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Mutation_infra_createClusterGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -36834,39 +38425,29 @@ func (ec *executionContext) fieldContext_Mutation_infra_createCluster(ctx contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "accountName": - return ec.fieldContext_Cluster_accountName(ctx, field) - case "apiVersion": - return ec.fieldContext_Cluster_apiVersion(ctx, field) + return ec.fieldContext_ClusterGroup_accountName(ctx, field) + case "clusterName": + return ec.fieldContext_ClusterGroup_clusterName(ctx, field) case "createdBy": - return ec.fieldContext_Cluster_createdBy(ctx, field) + return ec.fieldContext_ClusterGroup_createdBy(ctx, field) case "creationTime": - return ec.fieldContext_Cluster_creationTime(ctx, field) + return ec.fieldContext_ClusterGroup_creationTime(ctx, field) case "displayName": - return ec.fieldContext_Cluster_displayName(ctx, field) + return ec.fieldContext_ClusterGroup_displayName(ctx, field) case "id": - return ec.fieldContext_Cluster_id(ctx, field) - case "kind": - return ec.fieldContext_Cluster_kind(ctx, field) + return ec.fieldContext_ClusterGroup_id(ctx, field) case "lastUpdatedBy": - return ec.fieldContext_Cluster_lastUpdatedBy(ctx, field) + return ec.fieldContext_ClusterGroup_lastUpdatedBy(ctx, field) case "markedForDeletion": - return ec.fieldContext_Cluster_markedForDeletion(ctx, field) - case "metadata": - return ec.fieldContext_Cluster_metadata(ctx, field) + return ec.fieldContext_ClusterGroup_markedForDeletion(ctx, field) case "recordVersion": - return ec.fieldContext_Cluster_recordVersion(ctx, field) - case "spec": - return ec.fieldContext_Cluster_spec(ctx, field) - case "status": - return ec.fieldContext_Cluster_status(ctx, field) + return ec.fieldContext_ClusterGroup_recordVersion(ctx, field) case "syncStatus": - return ec.fieldContext_Cluster_syncStatus(ctx, field) + return ec.fieldContext_ClusterGroup_syncStatus(ctx, field) case "updateTime": - return ec.fieldContext_Cluster_updateTime(ctx, field) - case "adminKubeconfig": - return ec.fieldContext_Cluster_adminKubeconfig(ctx, field) + return ec.fieldContext_ClusterGroup_updateTime(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Cluster", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ClusterGroup", field.Name) }, } defer func() { @@ -36876,15 +38457,15 @@ func (ec *executionContext) fieldContext_Mutation_infra_createCluster(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_infra_createCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_infra_createClusterGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_infra_updateCluster(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_infra_updateCluster(ctx, field) +func (ec *executionContext) _Mutation_infra_updateClusterGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_infra_updateClusterGroup(ctx, field) if err != nil { return graphql.Null } @@ -36898,7 +38479,7 @@ func (ec *executionContext) _Mutation_infra_updateCluster(ctx context.Context, f resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().InfraUpdateCluster(rctx, fc.Args["cluster"].(entities.Cluster)) + return ec.resolvers.Mutation().InfraUpdateClusterGroup(rctx, fc.Args["cluster"].(entities.ClusterGroup)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.IsLoggedInAndVerified == nil { @@ -36920,10 +38501,10 @@ func (ec *executionContext) _Mutation_infra_updateCluster(ctx context.Context, f if tmp == nil { return nil, nil } - if data, ok := tmp.(*entities.Cluster); ok { + if data, ok := tmp.(*entities.ClusterGroup); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.Cluster`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.ClusterGroup`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -36932,12 +38513,12 @@ func (ec *executionContext) _Mutation_infra_updateCluster(ctx context.Context, f if resTmp == nil { return graphql.Null } - res := resTmp.(*entities.Cluster) + res := resTmp.(*entities.ClusterGroup) fc.Result = res - return ec.marshalOCluster2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐCluster(ctx, field.Selections, res) + return ec.marshalOClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_infra_updateCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_infra_updateClusterGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -36946,39 +38527,29 @@ func (ec *executionContext) fieldContext_Mutation_infra_updateCluster(ctx contex Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { case "accountName": - return ec.fieldContext_Cluster_accountName(ctx, field) - case "apiVersion": - return ec.fieldContext_Cluster_apiVersion(ctx, field) + return ec.fieldContext_ClusterGroup_accountName(ctx, field) + case "clusterName": + return ec.fieldContext_ClusterGroup_clusterName(ctx, field) case "createdBy": - return ec.fieldContext_Cluster_createdBy(ctx, field) + return ec.fieldContext_ClusterGroup_createdBy(ctx, field) case "creationTime": - return ec.fieldContext_Cluster_creationTime(ctx, field) + return ec.fieldContext_ClusterGroup_creationTime(ctx, field) case "displayName": - return ec.fieldContext_Cluster_displayName(ctx, field) + return ec.fieldContext_ClusterGroup_displayName(ctx, field) case "id": - return ec.fieldContext_Cluster_id(ctx, field) - case "kind": - return ec.fieldContext_Cluster_kind(ctx, field) + return ec.fieldContext_ClusterGroup_id(ctx, field) case "lastUpdatedBy": - return ec.fieldContext_Cluster_lastUpdatedBy(ctx, field) + return ec.fieldContext_ClusterGroup_lastUpdatedBy(ctx, field) case "markedForDeletion": - return ec.fieldContext_Cluster_markedForDeletion(ctx, field) - case "metadata": - return ec.fieldContext_Cluster_metadata(ctx, field) + return ec.fieldContext_ClusterGroup_markedForDeletion(ctx, field) case "recordVersion": - return ec.fieldContext_Cluster_recordVersion(ctx, field) - case "spec": - return ec.fieldContext_Cluster_spec(ctx, field) - case "status": - return ec.fieldContext_Cluster_status(ctx, field) + return ec.fieldContext_ClusterGroup_recordVersion(ctx, field) case "syncStatus": - return ec.fieldContext_Cluster_syncStatus(ctx, field) + return ec.fieldContext_ClusterGroup_syncStatus(ctx, field) case "updateTime": - return ec.fieldContext_Cluster_updateTime(ctx, field) - case "adminKubeconfig": - return ec.fieldContext_Cluster_adminKubeconfig(ctx, field) + return ec.fieldContext_ClusterGroup_updateTime(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Cluster", field.Name) + return nil, fmt.Errorf("no field named %q was found under type ClusterGroup", field.Name) }, } defer func() { @@ -36988,15 +38559,15 @@ func (ec *executionContext) fieldContext_Mutation_infra_updateCluster(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_infra_updateCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_infra_updateClusterGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } return fc, nil } -func (ec *executionContext) _Mutation_infra_deleteCluster(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Mutation_infra_deleteCluster(ctx, field) +func (ec *executionContext) _Mutation_infra_deleteClusterGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Mutation_infra_deleteClusterGroup(ctx, field) if err != nil { return graphql.Null } @@ -37010,7 +38581,7 @@ func (ec *executionContext) _Mutation_infra_deleteCluster(ctx context.Context, f resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Mutation().InfraDeleteCluster(rctx, fc.Args["name"].(string)) + return ec.resolvers.Mutation().InfraDeleteClusterGroup(rctx, fc.Args["name"].(string)) } directive1 := func(ctx context.Context) (interface{}, error) { if ec.directives.IsLoggedInAndVerified == nil { @@ -37052,7 +38623,7 @@ func (ec *executionContext) _Mutation_infra_deleteCluster(ctx context.Context, f return ec.marshalNBoolean2bool(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Mutation_infra_deleteCluster(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Mutation_infra_deleteClusterGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Mutation", Field: field, @@ -37069,7 +38640,7 @@ func (ec *executionContext) fieldContext_Mutation_infra_deleteCluster(ctx contex } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Mutation_infra_deleteCluster_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Mutation_infra_deleteClusterGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return fc, err } @@ -44266,6 +45837,8 @@ func (ec *executionContext) fieldContext_Query_infra_getCluster(ctx context.Cont return ec.fieldContext_Cluster_accountName(ctx, field) case "apiVersion": return ec.fieldContext_Cluster_apiVersion(ctx, field) + case "clusterGroupName": + return ec.fieldContext_Cluster_clusterGroupName(ctx, field) case "createdBy": return ec.fieldContext_Cluster_createdBy(ctx, field) case "creationTime": @@ -44312,6 +45885,194 @@ func (ec *executionContext) fieldContext_Query_infra_getCluster(ctx context.Cont return fc, nil } +func (ec *executionContext) _Query_infra_listClusterGroups(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_infra_listClusterGroups(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InfraListClusterGroups(rctx, fc.Args["search"].(*model.SearchClusterGroup), fc.Args["pagination"].(*repos.CursorPagination)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedInAndVerified == nil { + return nil, errors.New("directive isLoggedInAndVerified is not implemented") + } + return ec.directives.IsLoggedInAndVerified(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.HasAccount == nil { + return nil, errors.New("directive hasAccount is not implemented") + } + return ec.directives.HasAccount(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*model.ClusterGroupPaginatedRecords); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/app/graph/model.ClusterGroupPaginatedRecords`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*model.ClusterGroupPaginatedRecords) + fc.Result = res + return ec.marshalOClusterGroupPaginatedRecords2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupPaginatedRecords(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_infra_listClusterGroups(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "edges": + return ec.fieldContext_ClusterGroupPaginatedRecords_edges(ctx, field) + case "pageInfo": + return ec.fieldContext_ClusterGroupPaginatedRecords_pageInfo(ctx, field) + case "totalCount": + return ec.fieldContext_ClusterGroupPaginatedRecords_totalCount(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ClusterGroupPaginatedRecords", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_infra_listClusterGroups_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + +func (ec *executionContext) _Query_infra_getClusterGroup(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_infra_getClusterGroup(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Query().InfraGetClusterGroup(rctx, fc.Args["name"].(string)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + if ec.directives.IsLoggedInAndVerified == nil { + return nil, errors.New("directive isLoggedInAndVerified is not implemented") + } + return ec.directives.IsLoggedInAndVerified(ctx, nil, directive0) + } + directive2 := func(ctx context.Context) (interface{}, error) { + if ec.directives.HasAccount == nil { + return nil, errors.New("directive hasAccount is not implemented") + } + return ec.directives.HasAccount(ctx, nil, directive1) + } + + tmp, err := directive2(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.(*entities.ClusterGroup); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be *github.com/kloudlite/api/apps/infra/internal/entities.ClusterGroup`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*entities.ClusterGroup) + fc.Result = res + return ec.marshalOClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Query_infra_getClusterGroup(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Query", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "accountName": + return ec.fieldContext_ClusterGroup_accountName(ctx, field) + case "clusterName": + return ec.fieldContext_ClusterGroup_clusterName(ctx, field) + case "createdBy": + return ec.fieldContext_ClusterGroup_createdBy(ctx, field) + case "creationTime": + return ec.fieldContext_ClusterGroup_creationTime(ctx, field) + case "displayName": + return ec.fieldContext_ClusterGroup_displayName(ctx, field) + case "id": + return ec.fieldContext_ClusterGroup_id(ctx, field) + case "lastUpdatedBy": + return ec.fieldContext_ClusterGroup_lastUpdatedBy(ctx, field) + case "markedForDeletion": + return ec.fieldContext_ClusterGroup_markedForDeletion(ctx, field) + case "recordVersion": + return ec.fieldContext_ClusterGroup_recordVersion(ctx, field) + case "syncStatus": + return ec.fieldContext_ClusterGroup_syncStatus(ctx, field) + case "updateTime": + return ec.fieldContext_ClusterGroup_updateTime(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ClusterGroup", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query_infra_getClusterGroup_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return fc, err + } + return fc, nil +} + func (ec *executionContext) _Query_infra_listNodePools(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Query_infra_listNodePools(ctx, field) if err != nil { @@ -49415,6 +51176,35 @@ func (ec *executionContext) unmarshalInputCloudProviderSecretIn(ctx context.Cont return it, nil } +func (ec *executionContext) unmarshalInputClusterGroupIn(ctx context.Context, obj interface{}) (entities.ClusterGroup, error) { + var it entities.ClusterGroup + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"displayName"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "displayName": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("displayName")) + data, err := ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + it.DisplayName = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputClusterIn(ctx context.Context, obj interface{}) (entities.Cluster, error) { var it entities.Cluster asMap := map[string]interface{}{} @@ -49422,7 +51212,7 @@ func (ec *executionContext) unmarshalInputClusterIn(ctx context.Context, obj int asMap[k] = v } - fieldsInOrder := [...]string{"apiVersion", "displayName", "kind", "metadata", "spec"} + fieldsInOrder := [...]string{"apiVersion", "clusterGroupName", "displayName", "kind", "metadata", "spec"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -49438,6 +51228,15 @@ func (ec *executionContext) unmarshalInputClusterIn(ctx context.Context, obj int return it, err } it.APIVersion = data + case "clusterGroupName": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("clusterGroupName")) + data, err := ec.unmarshalOString2ᚖstring(ctx, v) + if err != nil { + return it, err + } + it.ClusterGroupName = data case "displayName": var err error @@ -54626,6 +56425,35 @@ func (ec *executionContext) unmarshalInputSearchCluster(ctx context.Context, obj return it, nil } +func (ec *executionContext) unmarshalInputSearchClusterGroup(ctx context.Context, obj interface{}) (model.SearchClusterGroup, error) { + var it model.SearchClusterGroup + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"text"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "text": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("text")) + data, err := ec.unmarshalOMatchFilterIn2ᚖgithubᚗcomᚋkloudliteᚋapiᚋpkgᚋreposᚐMatchFilter(ctx, v) + if err != nil { + return it, err + } + it.Text = data + } + } + + return it, nil +} + func (ec *executionContext) unmarshalInputSearchClusterManagedService(ctx context.Context, obj interface{}) (model.SearchClusterManagedService, error) { var it model.SearchClusterManagedService asMap := map[string]interface{}{} @@ -55686,6 +57514,8 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, } case "apiVersion": out.Values[i] = ec._Cluster_apiVersion(ctx, field, obj) + case "clusterGroupName": + out.Values[i] = ec._Cluster_clusterGroupName(ctx, field, obj) case "createdBy": out.Values[i] = ec._Cluster_createdBy(ctx, field, obj) if out.Values[i] == graphql.Null { @@ -55768,26 +57598,272 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "kind": - out.Values[i] = ec._Cluster_kind(ctx, field, obj) - case "lastUpdatedBy": - out.Values[i] = ec._Cluster_lastUpdatedBy(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "markedForDeletion": - out.Values[i] = ec._Cluster_markedForDeletion(ctx, field, obj) - case "metadata": - out.Values[i] = ec._Cluster_metadata(ctx, field, obj) - if out.Values[i] == graphql.Null { - atomic.AddUint32(&out.Invalids, 1) - } - case "recordVersion": - out.Values[i] = ec._Cluster_recordVersion(ctx, field, obj) + case "kind": + out.Values[i] = ec._Cluster_kind(ctx, field, obj) + case "lastUpdatedBy": + out.Values[i] = ec._Cluster_lastUpdatedBy(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "markedForDeletion": + out.Values[i] = ec._Cluster_markedForDeletion(ctx, field, obj) + case "metadata": + out.Values[i] = ec._Cluster_metadata(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "recordVersion": + out.Values[i] = ec._Cluster_recordVersion(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "spec": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Cluster_spec(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "status": + out.Values[i] = ec._Cluster_status(ctx, field, obj) + case "syncStatus": + out.Values[i] = ec._Cluster_syncStatus(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "updateTime": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Cluster_updateTime(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "adminKubeconfig": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Cluster_adminKubeconfig(ctx, field, obj) + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var clusterEdgeImplementors = []string{"ClusterEdge"} + +func (ec *executionContext) _ClusterEdge(ctx context.Context, sel ast.SelectionSet, obj *model.ClusterEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, clusterEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ClusterEdge") + case "cursor": + out.Values[i] = ec._ClusterEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._ClusterEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + +var clusterGroupImplementors = []string{"ClusterGroup"} + +func (ec *executionContext) _ClusterGroup(ctx context.Context, sel ast.SelectionSet, obj *entities.ClusterGroup) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, clusterGroupImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ClusterGroup") + case "accountName": + out.Values[i] = ec._ClusterGroup_accountName(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "clusterName": + out.Values[i] = ec._ClusterGroup_clusterName(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "createdBy": + out.Values[i] = ec._ClusterGroup_createdBy(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "creationTime": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._ClusterGroup_creationTime(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&fs.Invalids, 1) + } + return res + } + + if field.Deferrable != nil { + dfs, ok := deferred[field.Deferrable.Label] + di := 0 + if ok { + dfs.AddField(field) + di = len(dfs.Values) - 1 + } else { + dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) + deferred[field.Deferrable.Label] = dfs + } + dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { + return innerFunc(ctx, dfs) + }) + + // don't run the out.Concurrently() call below + out.Values[i] = graphql.Null + continue + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + case "displayName": + out.Values[i] = ec._ClusterGroup_displayName(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } - case "spec": + case "id": field := field innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { @@ -55796,7 +57872,7 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Cluster_spec(ctx, field, obj) + res = ec._ClusterGroup_id(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -55823,10 +57899,20 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "status": - out.Values[i] = ec._Cluster_status(ctx, field, obj) + case "lastUpdatedBy": + out.Values[i] = ec._ClusterGroup_lastUpdatedBy(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } + case "markedForDeletion": + out.Values[i] = ec._ClusterGroup_markedForDeletion(ctx, field, obj) + case "recordVersion": + out.Values[i] = ec._ClusterGroup_recordVersion(ctx, field, obj) + if out.Values[i] == graphql.Null { + atomic.AddUint32(&out.Invalids, 1) + } case "syncStatus": - out.Values[i] = ec._Cluster_syncStatus(ctx, field, obj) + out.Values[i] = ec._ClusterGroup_syncStatus(ctx, field, obj) if out.Values[i] == graphql.Null { atomic.AddUint32(&out.Invalids, 1) } @@ -55839,7 +57925,7 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Cluster_updateTime(ctx, field, obj) + res = ec._ClusterGroup_updateTime(ctx, field, obj) if res == graphql.Null { atomic.AddUint32(&fs.Invalids, 1) } @@ -55866,39 +57952,50 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, } out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) - case "adminKubeconfig": - field := field + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } - innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._Cluster_adminKubeconfig(ctx, field, obj) - return res - } + atomic.AddInt32(&ec.deferred, int32(len(deferred))) - if field.Deferrable != nil { - dfs, ok := deferred[field.Deferrable.Label] - di := 0 - if ok { - dfs.AddField(field) - di = len(dfs.Values) - 1 - } else { - dfs = graphql.NewFieldSet([]graphql.CollectedField{field}) - deferred[field.Deferrable.Label] = dfs - } - dfs.Concurrently(di, func(ctx context.Context) graphql.Marshaler { - return innerFunc(ctx, dfs) - }) + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } - // don't run the out.Concurrently() call below - out.Values[i] = graphql.Null - continue - } + return out +} - out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) +var clusterGroupEdgeImplementors = []string{"ClusterGroupEdge"} + +func (ec *executionContext) _ClusterGroupEdge(ctx context.Context, sel ast.SelectionSet, obj *model.ClusterGroupEdge) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, clusterGroupEdgeImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ClusterGroupEdge") + case "cursor": + out.Values[i] = ec._ClusterGroupEdge_cursor(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "node": + out.Values[i] = ec._ClusterGroupEdge_node(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -55922,24 +58019,29 @@ func (ec *executionContext) _Cluster(ctx context.Context, sel ast.SelectionSet, return out } -var clusterEdgeImplementors = []string{"ClusterEdge"} +var clusterGroupPaginatedRecordsImplementors = []string{"ClusterGroupPaginatedRecords"} -func (ec *executionContext) _ClusterEdge(ctx context.Context, sel ast.SelectionSet, obj *model.ClusterEdge) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, clusterEdgeImplementors) +func (ec *executionContext) _ClusterGroupPaginatedRecords(ctx context.Context, sel ast.SelectionSet, obj *model.ClusterGroupPaginatedRecords) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, clusterGroupPaginatedRecordsImplementors) out := graphql.NewFieldSet(fields) deferred := make(map[string]*graphql.FieldSet) for i, field := range fields { switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("ClusterEdge") - case "cursor": - out.Values[i] = ec._ClusterEdge_cursor(ctx, field, obj) + out.Values[i] = graphql.MarshalString("ClusterGroupPaginatedRecords") + case "edges": + out.Values[i] = ec._ClusterGroupPaginatedRecords_edges(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } - case "node": - out.Values[i] = ec._ClusterEdge_node(ctx, field, obj) + case "pageInfo": + out.Values[i] = ec._ClusterGroupPaginatedRecords_pageInfo(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + case "totalCount": + out.Values[i] = ec._ClusterGroupPaginatedRecords_totalCount(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } @@ -58094,6 +60196,8 @@ func (ec *executionContext) _Github__com___kloudlite___operator___apis___cluster if out.Values[i] == graphql.Null { out.Invalids++ } + case "vpc": + out.Values[i] = ec._Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig_vpc(ctx, field, obj) default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -58239,6 +60343,45 @@ func (ec *executionContext) _Github__com___kloudlite___operator___apis___cluster return out } +var github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParamsImplementors = []string{"Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams"} + +func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams(ctx context.Context, sel ast.SelectionSet, obj *model.GithubComKloudliteOperatorApisClustersV1GcpVPCParams) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParamsImplementors) + + out := graphql.NewFieldSet(fields) + deferred := make(map[string]*graphql.FieldSet) + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams") + case "name": + out.Values[i] = ec._Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams_name(ctx, field, obj) + if out.Values[i] == graphql.Null { + out.Invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch(ctx) + if out.Invalids > 0 { + return graphql.Null + } + + atomic.AddInt32(&ec.deferred, int32(len(deferred))) + + for label, dfs := range deferred { + ec.processDeferredGroup(graphql.DeferredGroup{ + Label: label, + Path: graphql.GetPath(ctx), + FieldSet: dfs, + Context: ctx, + }) + } + + return out +} + var github__com___kloudlite___operator___apis___clusters___v1__MasterNodePropsImplementors = []string{"Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps"} func (ec *executionContext) _Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps(ctx context.Context, sel ast.SelectionSet, obj *model.GithubComKloudliteOperatorApisClustersV1MasterNodeProps) graphql.Marshaler { @@ -62492,6 +64635,21 @@ func (ec *executionContext) _Mutation(ctx context.Context, sel ast.SelectionSet) if out.Values[i] == graphql.Null { out.Invalids++ } + case "infra_createClusterGroup": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_infra_createClusterGroup(ctx, field) + }) + case "infra_updateClusterGroup": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_infra_updateClusterGroup(ctx, field) + }) + case "infra_deleteClusterGroup": + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Mutation_infra_deleteClusterGroup(ctx, field) + }) + if out.Values[i] == graphql.Null { + out.Invalids++ + } case "infra_createBYOKCluster": out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { return ec._Mutation_infra_createBYOKCluster(ctx, field) @@ -64377,6 +66535,44 @@ func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) gr func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "infra_listClusterGroups": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_infra_listClusterGroups(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) + case "infra_getClusterGroup": + field := field + + innerFunc := func(ctx context.Context, fs *graphql.FieldSet) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query_infra_getClusterGroup(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, + func(ctx context.Context) graphql.Marshaler { return innerFunc(ctx, out) }) + } + out.Concurrently(i, func(ctx context.Context) graphql.Marshaler { return rrm(innerCtx) }) case "infra_listNodePools": field := field @@ -65744,6 +67940,75 @@ func (ec *executionContext) marshalNClusterEdge2ᚖgithubᚗcomᚋkloudliteᚋap return ec._ClusterEdge(ctx, sel, v) } +func (ec *executionContext) marshalNClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx context.Context, sel ast.SelectionSet, v *entities.ClusterGroup) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ClusterGroup(ctx, sel, v) +} + +func (ec *executionContext) marshalNClusterGroupEdge2ᚕᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupEdgeᚄ(ctx context.Context, sel ast.SelectionSet, v []*model.ClusterGroupEdge) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + ctx := graphql.WithFieldContext(ctx, fc) + f := func(i int) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = nil + } + }() + if !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalNClusterGroupEdge2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupEdge(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalNClusterGroupEdge2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupEdge(ctx context.Context, sel ast.SelectionSet, v *model.ClusterGroupEdge) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._ClusterGroupEdge(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNClusterGroupIn2githubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx context.Context, v interface{}) (entities.ClusterGroup, error) { + res, err := ec.unmarshalInputClusterGroupIn(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalNClusterIn2githubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐCluster(ctx context.Context, v interface{}) (entities.Cluster, error) { res, err := ec.unmarshalInputClusterIn(ctx, v) return res, graphql.ErrorOnPath(ctx, err) @@ -67746,7 +70011,7 @@ func (ec *executionContext) marshalNfederation__Scope2ᚕᚕstringᚄ(ctx contex return ret } -func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (any, error) { +func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v interface{}) (interface{}, error) { if v == nil { return nil, nil } @@ -67754,7 +70019,7 @@ func (ec *executionContext) unmarshalOAny2interface(ctx context.Context, v inter return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v any) graphql.Marshaler { +func (ec *executionContext) marshalOAny2interface(ctx context.Context, sel ast.SelectionSet, v interface{}) graphql.Marshaler { if v == nil { return graphql.Null } @@ -67854,6 +70119,20 @@ func (ec *executionContext) marshalOCluster2ᚖgithubᚗcomᚋkloudliteᚋapiᚋ return ec._Cluster(ctx, sel, v) } +func (ec *executionContext) marshalOClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterGroup(ctx context.Context, sel ast.SelectionSet, v *entities.ClusterGroup) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ClusterGroup(ctx, sel, v) +} + +func (ec *executionContext) marshalOClusterGroupPaginatedRecords2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐClusterGroupPaginatedRecords(ctx context.Context, sel ast.SelectionSet, v *model.ClusterGroupPaginatedRecords) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ClusterGroupPaginatedRecords(ctx, sel, v) +} + func (ec *executionContext) marshalOClusterManagedService2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋentitiesᚐClusterManagedService(ctx context.Context, sel ast.SelectionSet, v *entities.ClusterManagedService) graphql.Marshaler { if v == nil { return graphql.Null @@ -68177,6 +70456,13 @@ func (ec *executionContext) unmarshalOGithub__com___kloudlite___operator___apis_ return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) marshalOGithub__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐGithubComKloudliteOperatorApisClustersV1GcpVPCParams(ctx context.Context, sel ast.SelectionSet, v *model.GithubComKloudliteOperatorApisClustersV1GcpVPCParams) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams(ctx, sel, v) +} + func (ec *executionContext) marshalOGithub__com___kloudlite___operator___apis___common____types__MinMaxFloat2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐGithubComKloudliteOperatorApisCommonTypesMinMaxFloat(ctx context.Context, sel ast.SelectionSet, v *model.GithubComKloudliteOperatorApisCommonTypesMinMaxFloat) graphql.Marshaler { if v == nil { return graphql.Null @@ -70002,6 +72288,14 @@ func (ec *executionContext) unmarshalOSearchCluster2ᚖgithubᚗcomᚋkloudlite return &res, graphql.ErrorOnPath(ctx, err) } +func (ec *executionContext) unmarshalOSearchClusterGroup2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐSearchClusterGroup(ctx context.Context, v interface{}) (*model.SearchClusterGroup, error) { + if v == nil { + return nil, nil + } + res, err := ec.unmarshalInputSearchClusterGroup(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) +} + func (ec *executionContext) unmarshalOSearchClusterManagedService2ᚖgithubᚗcomᚋkloudliteᚋapiᚋappsᚋinfraᚋinternalᚋappᚋgraphᚋmodelᚐSearchClusterManagedService(ctx context.Context, v interface{}) (*model.SearchClusterManagedService, error) { if v == nil { return nil, nil diff --git a/apps/infra/internal/app/graph/model/models_gen.go b/apps/infra/internal/app/graph/model/models_gen.go index ba1205b86..6367abe3b 100644 --- a/apps/infra/internal/app/graph/model/models_gen.go +++ b/apps/infra/internal/app/graph/model/models_gen.go @@ -34,6 +34,17 @@ type ClusterEdge struct { Node *entities.Cluster `json:"node"` } +type ClusterGroupEdge struct { + Cursor string `json:"cursor"` + Node *entities.ClusterGroup `json:"node"` +} + +type ClusterGroupPaginatedRecords struct { + Edges []*ClusterGroupEdge `json:"edges"` + PageInfo *PageInfo `json:"pageInfo"` + TotalCount int `json:"totalCount"` +} + type ClusterManagedServiceEdge struct { Cursor string `json:"cursor"` Node *entities.ClusterManagedService `json:"node"` @@ -294,6 +305,7 @@ type GithubComKloudliteOperatorApisClustersV1GCPClusterConfig struct { GcpProjectID string `json:"gcpProjectID"` MasterNodes *GithubComKloudliteOperatorApisClustersV1GCPMasterNodesConfig `json:"masterNodes,omitempty"` Region string `json:"region"` + Vpc *GithubComKloudliteOperatorApisClustersV1GcpVPCParams `json:"vpc,omitempty"` } type GithubComKloudliteOperatorApisClustersV1GCPClusterConfigIn struct { @@ -325,6 +337,10 @@ type GithubComKloudliteOperatorApisClustersV1GCPNodePoolConfigIn struct { PoolType GithubComKloudliteOperatorApisClustersV1GCPPoolType `json:"poolType"` } +type GithubComKloudliteOperatorApisClustersV1GcpVPCParams struct { + Name string `json:"name"` +} + type GithubComKloudliteOperatorApisClustersV1MasterNodeProps struct { AvailabilityZone string `json:"availabilityZone"` KloudliteRelease string `json:"kloudliteRelease"` @@ -1397,6 +1413,10 @@ type SearchCluster struct { Text *repos.MatchFilter `json:"text,omitempty"` } +type SearchClusterGroup struct { + Text *repos.MatchFilter `json:"text,omitempty"` +} + type SearchClusterManagedService struct { IsReady *repos.MatchFilter `json:"isReady,omitempty"` Text *repos.MatchFilter `json:"text,omitempty"` diff --git a/apps/infra/internal/app/graph/schema.graphqls b/apps/infra/internal/app/graph/schema.graphqls index a769046c0..48e254873 100644 --- a/apps/infra/internal/app/graph/schema.graphqls +++ b/apps/infra/internal/app/graph/schema.graphqls @@ -23,6 +23,10 @@ input SearchCluster { text: MatchFilterIn } +input SearchClusterGroup { + text: MatchFilterIn +} + input SearchClusterManagedService { isReady: MatchFilterIn text: MatchFilterIn @@ -76,6 +80,10 @@ type Query { infra_listClusters(search: SearchCluster, pagination: CursorPaginationIn): ClusterPaginatedRecords @isLoggedInAndVerified @hasAccount infra_getCluster(name: String!): Cluster @isLoggedInAndVerified @hasAccount + # cluster groups + infra_listClusterGroups(search: SearchClusterGroup, pagination: CursorPaginationIn): ClusterGroupPaginatedRecords @isLoggedInAndVerified @hasAccount + infra_getClusterGroup(name: String!): ClusterGroup @isLoggedInAndVerified @hasAccount + # get node pools infra_listNodePools(clusterName: String!, search: SearchNodepool, pagination: CursorPaginationIn): NodePoolPaginatedRecords @isLoggedInAndVerified @hasAccount infra_getNodePool(clusterName: String!, poolName: String!): NodePool @isLoggedInAndVerified @hasAccount @@ -119,6 +127,10 @@ type Mutation { infra_updateCluster(cluster: ClusterIn!): Cluster @isLoggedInAndVerified @hasAccount infra_deleteCluster(name: String!): Boolean! @isLoggedInAndVerified @hasAccount # infra_resyncCluster(name: String!): Boolean! @isLoggedInAndVerified @hasAccount + + infra_createClusterGroup(cluster: ClusterGroupIn!): ClusterGroup @isLoggedInAndVerified @hasAccount + infra_updateClusterGroup(cluster: ClusterGroupIn!): ClusterGroup @isLoggedInAndVerified @hasAccount + infra_deleteClusterGroup(name: String!): Boolean! @isLoggedInAndVerified @hasAccount infra_createBYOKCluster(cluster: BYOKClusterIn!): BYOKCluster @isLoggedInAndVerified @hasAccount diff --git a/apps/infra/internal/app/graph/schema.resolvers.go b/apps/infra/internal/app/graph/schema.resolvers.go index c735a5572..70f5b9aba 100644 --- a/apps/infra/internal/app/graph/schema.resolvers.go +++ b/apps/infra/internal/app/graph/schema.resolvers.go @@ -7,11 +7,14 @@ package graph import ( "context" "encoding/base64" + + "github.com/kloudlite/api/common/fields" + "github.com/kloudlite/api/pkg/errors" + "github.com/kloudlite/api/apps/infra/internal/app/graph/generated" "github.com/kloudlite/api/apps/infra/internal/app/graph/model" "github.com/kloudlite/api/apps/infra/internal/domain" "github.com/kloudlite/api/apps/infra/internal/entities" - "github.com/kloudlite/api/pkg/errors" fn "github.com/kloudlite/api/pkg/functions" "github.com/kloudlite/api/pkg/repos" ) @@ -68,6 +71,37 @@ func (r *mutationResolver) InfraDeleteCluster(ctx context.Context, name string) return true, nil } +// InfraCreateClusterGroup is the resolver for the infra_createClusterGroup field. +func (r *mutationResolver) InfraCreateClusterGroup(ctx context.Context, clusterGroup entities.ClusterGroup) (*entities.ClusterGroup, error) { + ictx, err := toInfraContext(ctx) + if err != nil { + return nil, errors.NewE(err) + } + return r.Domain.CreateClusterGroup(ictx, clusterGroup) +} + +// InfraUpdateClusterGroup is the resolver for the infra_updateClusterGroup field. +func (r *mutationResolver) InfraUpdateClusterGroup(ctx context.Context, clusterGroup entities.ClusterGroup) (*entities.ClusterGroup, error) { + ictx, err := toInfraContext(ctx) + if err != nil { + return nil, errors.NewE(err) + } + + return r.Domain.UpdateClusterGroup(ictx, clusterGroup) +} + +// InfraDeleteClusterGroup is the resolver for the infra_deleteClusterGroup field. +func (r *mutationResolver) InfraDeleteClusterGroup(ctx context.Context, name string) (bool, error) { + ictx, err := toInfraContext(ctx) + if err != nil { + return false, errors.NewE(err) + } + if err := r.Domain.DeleteClusterGroup(ictx, name); err != nil { + return false, errors.NewE(err) + } + return true, nil +} + // InfraCreateBYOKCluster is the resolver for the infra_createBYOKCluster field. func (r *mutationResolver) InfraCreateBYOKCluster(ctx context.Context, cluster entities.BYOKCluster) (*entities.BYOKCluster, error) { ictx, err := toInfraContext(ctx) @@ -297,7 +331,7 @@ func (r *queryResolver) InfraListClusters(ctx context.Context, search *model.Sea } if search.Text != nil { - filter["metadata.name"] = *search.Text + filter[fields.MetadataName] = *search.Text } } @@ -338,6 +372,62 @@ func (r *queryResolver) InfraGetCluster(ctx context.Context, name string) (*enti return r.Domain.GetCluster(ictx, name) } +// InfraListClusterGroups is the resolver for the infra_listClusterGroups field. +func (r *queryResolver) InfraListClusterGroups(ctx context.Context, search *model.SearchClusterGroup, pagination *repos.CursorPagination) (*model.ClusterGroupPaginatedRecords, error) { + ictx, err := toInfraContext(ctx) + if err != nil { + return nil, errors.NewE(err) + } + + if pagination == nil { + pagination = &repos.DefaultCursorPagination + } + + filter := map[string]repos.MatchFilter{} + + if search != nil { + if search.Text != nil { + filter[fields.MetadataName] = *search.Text + } + } + + pClusters, err := r.Domain.ListClustersGroup(ictx, filter, *pagination) + if err != nil { + return nil, errors.NewE(err) + } + + ce := make([]*model.ClusterGroupEdge, len(pClusters.Edges)) + for i := range pClusters.Edges { + ce[i] = &model.ClusterGroupEdge{ + Node: pClusters.Edges[i].Node, + Cursor: pClusters.Edges[i].Cursor, + } + } + + m := model.ClusterGroupPaginatedRecords{ + Edges: ce, + PageInfo: &model.PageInfo{ + EndCursor: &pClusters.PageInfo.EndCursor, + HasNextPage: pClusters.PageInfo.HasNextPage, + HasPreviousPage: pClusters.PageInfo.HasPrevPage, + StartCursor: &pClusters.PageInfo.StartCursor, + }, + TotalCount: int(pClusters.TotalCount), + } + + return &m, nil +} + +// InfraGetClusterGroup is the resolver for the infra_getClusterGroup field. +func (r *queryResolver) InfraGetClusterGroup(ctx context.Context, name string) (*entities.ClusterGroup, error) { + ictx, err := toInfraContext(ctx) + if err != nil { + return nil, errors.NewE(err) + } + + return r.Domain.GetClusterGroup(ictx, name) +} + // InfraListNodePools is the resolver for the infra_listNodePools field. func (r *queryResolver) InfraListNodePools(ctx context.Context, clusterName string, search *model.SearchNodepool, pagination *repos.CursorPagination) (*model.NodePoolPaginatedRecords, error) { ictx, err := toInfraContext(ctx) diff --git a/apps/infra/internal/app/graph/struct-to-graphql/cluster.graphqls b/apps/infra/internal/app/graph/struct-to-graphql/cluster.graphqls index d3148514c..dc51a082b 100644 --- a/apps/infra/internal/app/graph/struct-to-graphql/cluster.graphqls +++ b/apps/infra/internal/app/graph/struct-to-graphql/cluster.graphqls @@ -1,6 +1,7 @@ type Cluster @shareable { accountName: String! apiVersion: String + clusterGroupName: String createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! creationTime: Date! displayName: String! @@ -29,6 +30,7 @@ type ClusterPaginatedRecords @shareable { input ClusterIn { apiVersion: String + clusterGroupName: String displayName: String! kind: String metadata: MetadataIn! diff --git a/apps/infra/internal/app/graph/struct-to-graphql/clustergroup.graphqls b/apps/infra/internal/app/graph/struct-to-graphql/clustergroup.graphqls new file mode 100644 index 000000000..c5cee3ad9 --- /dev/null +++ b/apps/infra/internal/app/graph/struct-to-graphql/clustergroup.graphqls @@ -0,0 +1,29 @@ +type ClusterGroup @shareable { + accountName: String! + clusterName: String! + createdBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + creationTime: Date! + displayName: String! + id: ID! + lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! + markedForDeletion: Boolean + recordVersion: Int! + syncStatus: Github__com___kloudlite___api___pkg___types__SyncStatus! + updateTime: Date! +} + +type ClusterGroupEdge @shareable { + cursor: String! + node: ClusterGroup! +} + +type ClusterGroupPaginatedRecords @shareable { + edges: [ClusterGroupEdge!]! + pageInfo: PageInfo! + totalCount: Int! +} + +input ClusterGroupIn { + displayName: String! +} + diff --git a/apps/infra/internal/app/graph/struct-to-graphql/common-types.graphqls b/apps/infra/internal/app/graph/struct-to-graphql/common-types.graphqls index 164339be4..f6d047406 100644 --- a/apps/infra/internal/app/graph/struct-to-graphql/common-types.graphqls +++ b/apps/infra/internal/app/graph/struct-to-graphql/common-types.graphqls @@ -182,6 +182,7 @@ type Github__com___kloudlite___operator___apis___clusters___v1__GCPClusterConfig gcpProjectID: String! masterNodes: Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig region: String! + vpc: Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams } type Github__com___kloudlite___operator___apis___clusters___v1__GCPMasterNodesConfig @shareable { @@ -202,6 +203,10 @@ type Github__com___kloudlite___operator___apis___clusters___v1__GCPNodePoolConfi region: String! } +type Github__com___kloudlite___operator___apis___clusters___v1__GcpVPCParams @shareable { + name: String! +} + type Github__com___kloudlite___operator___apis___clusters___v1__MasterNodeProps @shareable { availabilityZone: String! kloudliteRelease: String! diff --git a/apps/infra/internal/domain/api.go b/apps/infra/internal/domain/api.go index 92eaf621e..ece450106 100644 --- a/apps/infra/internal/domain/api.go +++ b/apps/infra/internal/domain/api.go @@ -40,6 +40,7 @@ type ResourceType string const ( ResourceTypeClusterManagedService ResourceType = "cluster_managed_service" ResourceTypeCluster ResourceType = "cluster" + ResourceTypeClusterGroup ResourceType = "cluster_group" ResourceTypeDomainEntries ResourceType = "domain_entries" ResourceTypeHelmRelease ResourceType = "helm_release" ResourceTypeNodePool ResourceType = "nodepool" @@ -52,6 +53,13 @@ const ( type Domain interface { CheckNameAvailability(ctx InfraContext, typeArg ResType, clusterName *string, name string) (*CheckNameAvailabilityOutput, error) + CreateClusterGroup(ctx InfraContext, cluster entities.ClusterGroup) (*entities.ClusterGroup, error) + UpdateClusterGroup(ctx InfraContext, cluster entities.ClusterGroup) (*entities.ClusterGroup, error) + DeleteClusterGroup(ctx InfraContext, name string) error + + ListClustersGroup(ctx InfraContext, search map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.ClusterGroup], error) + GetClusterGroup(ctx InfraContext, name string) (*entities.ClusterGroup, error) + CreateCluster(ctx InfraContext, cluster entities.Cluster) (*entities.Cluster, error) UpdateCluster(ctx InfraContext, cluster entities.Cluster) (*entities.Cluster, error) DeleteCluster(ctx InfraContext, name string) error diff --git a/apps/infra/internal/domain/cluster-group.go b/apps/infra/internal/domain/cluster-group.go index 4188b5afd..3d54d6b98 100644 --- a/apps/infra/internal/domain/cluster-group.go +++ b/apps/infra/internal/domain/cluster-group.go @@ -1 +1,157 @@ package domain + +import ( + iamT "github.com/kloudlite/api/apps/iam/types" + "github.com/kloudlite/api/apps/infra/internal/entities" + fc "github.com/kloudlite/api/apps/infra/internal/entities/field-constants" + "github.com/kloudlite/api/common" + "github.com/kloudlite/api/common/fields" + "github.com/kloudlite/api/pkg/errors" + "github.com/kloudlite/api/pkg/repos" + t "github.com/kloudlite/api/pkg/types" +) + +// TODO: needs to chain cluster in cluster group + +func (d *domain) CreateClusterGroup(ctx InfraContext, cg entities.ClusterGroup) (*entities.ClusterGroup, error) { + if err := d.canPerformActionInAccount(ctx, iamT.CreateCluster); err != nil { + return nil, errors.NewE(err) + } + // TODO: validate name + + existing, err := d.clusterRepo.FindOne(ctx, repos.Filter{ + fields.MetadataName: cg.Name, + fields.AccountName: ctx.AccountName, + }) + if err != nil { + return nil, errors.NewE(err) + } + + if existing != nil { + return nil, ErrClusterAlreadyExists{ClusterName: cg.Name, AccountName: ctx.AccountName} + } + + cg.AccountName = ctx.AccountName + + cg.IncrementRecordVersion() + cg.CreatedBy = common.CreatedOrUpdatedBy{ + UserId: ctx.UserId, + UserName: ctx.UserName, + UserEmail: ctx.UserEmail, + } + cg.LastUpdatedBy = cg.CreatedBy + + cg.SyncStatus = t.GenSyncStatus(t.SyncActionApply, 0) + + ncg, err := d.clusterGroupRepo.Create(ctx, &cg) + if err != nil { + if d.clusterRepo.ErrAlreadyExists(err) { + return nil, errors.Newf("cluster group with name %q already exists in account %q", cg.Name, cg.AccountName) + } + return nil, errors.NewE(err) + } + + d.resourceEventPublisher.PublishInfraEvent(ctx, ResourceTypeClusterGroup, ncg.Name, PublishAdd) + + return ncg, nil +} + +func (d *domain) UpdateClusterGroup(ctx InfraContext, cgIn entities.ClusterGroup) (*entities.ClusterGroup, error) { + if err := d.canPerformActionInAccount(ctx, iamT.UpdateCluster); err != nil { + return nil, errors.NewE(err) + } + + ucg, err := d.clusterGroupRepo.Patch( + ctx, + repos.Filter{ + fields.AccountName: ctx.AccountName, + fields.MetadataName: cgIn.Name, + }, + common.PatchForUpdate(ctx, &cgIn), + ) + if err != nil { + return nil, errors.NewE(err) + } + + d.resourceEventPublisher.PublishInfraEvent(ctx, ResourceTypeClusterGroup, ucg.Name, PublishUpdate) + return ucg, nil +} + +func (d *domain) DeleteClusterGroup(ctx InfraContext, name string) error { + if err := d.canPerformActionInAccount(ctx, iamT.DeleteCluster); err != nil { + return errors.NewE(err) + } + + filter := repos.Filter{ + fields.AccountName: ctx.AccountName, + fc.ClusterClusterGroupName: name, + } + + cCount, err := d.clusterRepo.Count(ctx, filter) + if err != nil { + return errors.NewE(err) + } + if cCount != 0 { + return errors.Newf("delete clusters first, aborting cluster group deletion") + } + + ucg, err := d.clusterGroupRepo.Patch( + ctx, + repos.Filter{ + fields.AccountName: ctx.AccountName, + fields.MetadataName: name, + }, + common.PatchForMarkDeletion(), + ) + if err != nil { + return errors.NewE(err) + } + + d.resourceEventPublisher.PublishInfraEvent(ctx, ResourceTypeClusterGroup, ucg.Name, PublishUpdate) + return nil +} + +func (d *domain) ListClustersGroup(ctx InfraContext, mf map[string]repos.MatchFilter, pagination repos.CursorPagination) (*repos.PaginatedRecord[*entities.ClusterGroup], error) { + if err := d.canPerformActionInAccount(ctx, iamT.ListClusters); err != nil { + return nil, errors.NewE(err) + } + + f := repos.Filter{ + fields.AccountName: ctx.AccountName, + } + + pr, err := d.clusterGroupRepo.FindPaginated(ctx, d.clusterGroupRepo.MergeMatchFilters(f, mf), pagination) + if err != nil { + return nil, errors.NewE(err) + } + + return pr, nil +} + +func (d *domain) GetClusterGroup(ctx InfraContext, name string) (*entities.ClusterGroup, error) { + if err := d.canPerformActionInAccount(ctx, iamT.GetCluster); err != nil { + return nil, errors.NewE(err) + } + + c, err := d.findClusterGroup(ctx, name) + if err != nil { + return nil, errors.NewE(err) + } + + return c, nil +} + +func (d *domain) findClusterGroup(ctx InfraContext, cgName string) (*entities.ClusterGroup, error) { + cg, err := d.clusterGroupRepo.FindOne(ctx, repos.Filter{ + fields.AccountName: ctx.AccountName, + fields.MetadataName: cgName, + }) + if err != nil { + return nil, errors.NewE(err) + } + + if cg == nil { + return nil, ErrClusterNotFound + } + return cg, nil +} diff --git a/apps/infra/internal/domain/clusters.go b/apps/infra/internal/domain/clusters.go index 6100c0d9b..120a3075a 100644 --- a/apps/infra/internal/domain/clusters.go +++ b/apps/infra/internal/domain/clusters.go @@ -427,7 +427,7 @@ func (d *domain) ListClusters(ctx InfraContext, mf map[string]repos.MatchFilter, fields.MetadataNamespace: accNs, } - pr, err := d.clusterRepo.FindPaginated(ctx, d.secretRepo.MergeMatchFilters(f, mf), pagination) + pr, err := d.clusterRepo.FindPaginated(ctx, d.clusterRepo.MergeMatchFilters(f, mf), pagination) if err != nil { return nil, errors.NewE(err) } diff --git a/apps/infra/internal/entities/cluster-group.go b/apps/infra/internal/entities/cluster-group.go index 0d154cbc5..0f3834a3e 100644 --- a/apps/infra/internal/entities/cluster-group.go +++ b/apps/infra/internal/entities/cluster-group.go @@ -8,6 +8,7 @@ import ( "github.com/kloudlite/api/pkg/repos" t "github.com/kloudlite/api/pkg/types" "github.com/kloudlite/operator/pkg/operator" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -38,6 +39,7 @@ type ClusterGroup struct { repos.BaseEntity `json:",inline" graphql:"noinput"` common.ResourceMetadata `json:",inline"` + metav1.ObjectMeta `json:"metadata"` // Peers []Peer `json:"peers" graphql:"noinput"`