From 0f8b1cebbdd695b0f3f9e75013181708976e92ed Mon Sep 17 00:00:00 2001 From: Abdhesh Nayak Date: Tue, 5 Mar 2024 17:24:33 +0530 Subject: [PATCH] :art: Remove omitempty from app_type(hpa.enabled) --- .../internal/app/graph/generated/generated.go | 103 ++++++++++++++++-- .../internal/app/graph/model/models_gen.go | 20 ++-- .../internal/app/graph/secret.resolvers.go | 6 + .../struct-to-graphql/common-types.graphqls | 4 +- .../graph/struct-to-graphql/secret.graphqls | 1 + go.mod | 2 +- go.sum | 18 +-- 7 files changed, 118 insertions(+), 36 deletions(-) diff --git a/apps/console/internal/app/graph/generated/generated.go b/apps/console/internal/app/graph/generated/generated.go index 09dd23976..d8aead6b6 100644 --- a/apps/console/internal/app/graph/generated/generated.go +++ b/apps/console/internal/app/graph/generated/generated.go @@ -794,6 +794,7 @@ type ComplexityRoot struct { EnvironmentName func(childComplexity int) int ID func(childComplexity int) int Immutable func(childComplexity int) int + IsReadyOnly func(childComplexity int) int Kind func(childComplexity int) int LastUpdatedBy func(childComplexity int) int MarkedForDeletion func(childComplexity int) int @@ -1019,6 +1020,8 @@ type SecretResolver interface { ID(ctx context.Context, obj *entities.Secret) (string, error) + IsReadyOnly(ctx context.Context, obj *entities.Secret) (bool, error) + StringData(ctx context.Context, obj *entities.Secret) (map[string]interface{}, error) Type(ctx context.Context, obj *entities.Secret) (*model.K8sIoAPICoreV1SecretType, error) @@ -4764,6 +4767,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Secret.Immutable(childComplexity), true + case "Secret.isReadyOnly": + if e.complexity.Secret.IsReadyOnly == nil { + break + } + + return e.complexity.Secret.IsReadyOnly(childComplexity), true + case "Secret.kind": if e.complexity.Secret.Kind == nil { break @@ -5383,7 +5393,7 @@ type Github__com___kloudlite___operator___apis___crds___v1__EnvironmentSpec @sha } type Github__com___kloudlite___operator___apis___crds___v1__HPA @shareable { - enabled: Boolean + enabled: Boolean! maxReplicas: Int minReplicas: Int thresholdCpu: Int @@ -5652,7 +5662,7 @@ input Github__com___kloudlite___operator___apis___crds___v1__EnvironmentSpecIn { } input Github__com___kloudlite___operator___apis___crds___v1__HPAIn { - enabled: Boolean + enabled: Boolean! maxReplicas: Int minReplicas: Int thresholdCpu: Int @@ -6305,6 +6315,7 @@ scalar Date environmentName: String! id: String! immutable: Boolean + isReadyOnly: Boolean! kind: String lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! markedForDeletion: Boolean @@ -16531,11 +16542,14 @@ func (ec *executionContext) _Github__com___kloudlite___operator___apis___crds___ return graphql.Null } if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } return graphql.Null } - res := resTmp.(*bool) + res := resTmp.(bool) fc.Result = res - return ec.marshalOBoolean2ᚖbool(ctx, field.Selections, res) + return ec.marshalNBoolean2bool(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_Github__com___kloudlite___operator___apis___crds___v1__HPA_enabled(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -24950,6 +24964,8 @@ func (ec *executionContext) fieldContext_Mutation_core_createSecret(ctx context. return ec.fieldContext_Secret_id(ctx, field) case "immutable": return ec.fieldContext_Secret_immutable(ctx, field) + case "isReadyOnly": + return ec.fieldContext_Secret_isReadyOnly(ctx, field) case "kind": return ec.fieldContext_Secret_kind(ctx, field) case "lastUpdatedBy": @@ -25068,6 +25084,8 @@ func (ec *executionContext) fieldContext_Mutation_core_updateSecret(ctx context. return ec.fieldContext_Secret_id(ctx, field) case "immutable": return ec.fieldContext_Secret_immutable(ctx, field) + case "isReadyOnly": + return ec.fieldContext_Secret_isReadyOnly(ctx, field) case "kind": return ec.fieldContext_Secret_kind(ctx, field) case "lastUpdatedBy": @@ -30964,6 +30982,8 @@ func (ec *executionContext) fieldContext_Query_core_getSecret(ctx context.Contex return ec.fieldContext_Secret_id(ctx, field) case "immutable": return ec.fieldContext_Secret_immutable(ctx, field) + case "isReadyOnly": + return ec.fieldContext_Secret_isReadyOnly(ctx, field) case "kind": return ec.fieldContext_Secret_kind(ctx, field) case "lastUpdatedBy": @@ -34194,6 +34214,50 @@ func (ec *executionContext) fieldContext_Secret_immutable(ctx context.Context, f return fc, nil } +func (ec *executionContext) _Secret_isReadyOnly(ctx context.Context, field graphql.CollectedField, obj *entities.Secret) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Secret_isReadyOnly(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.Secret().IsReadyOnly(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.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Secret_isReadyOnly(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Secret", + 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") + }, + } + return fc, nil +} + func (ec *executionContext) _Secret_kind(ctx context.Context, field graphql.CollectedField, obj *entities.Secret) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Secret_kind(ctx, field) if err != nil { @@ -34758,6 +34822,8 @@ func (ec *executionContext) fieldContext_SecretEdge_node(ctx context.Context, fi return ec.fieldContext_Secret_id(ctx, field) case "immutable": return ec.fieldContext_Secret_immutable(ctx, field) + case "isReadyOnly": + return ec.fieldContext_Secret_isReadyOnly(ctx, field) case "kind": return ec.fieldContext_Secret_kind(ctx, field) case "lastUpdatedBy": @@ -38163,7 +38229,7 @@ func (ec *executionContext) unmarshalInputGithub__com___kloudlite___operator___a var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("enabled")) - it.Enabled, err = ec.unmarshalOBoolean2ᚖbool(ctx, v) + it.Enabled, err = ec.unmarshalNBoolean2bool(ctx, v) if err != nil { return it, err } @@ -42222,6 +42288,9 @@ func (ec *executionContext) _Github__com___kloudlite___operator___apis___crds___ out.Values[i] = ec._Github__com___kloudlite___operator___apis___crds___v1__HPA_enabled(ctx, field, obj) + if out.Values[i] == graphql.Null { + invalids++ + } case "maxReplicas": out.Values[i] = ec._Github__com___kloudlite___operator___apis___crds___v1__HPA_maxReplicas(ctx, field, obj) @@ -46026,6 +46095,26 @@ func (ec *executionContext) _Secret(ctx context.Context, sel ast.SelectionSet, o out.Values[i] = ec._Secret_immutable(ctx, field, obj) + case "isReadyOnly": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Secret_isReadyOnly(ctx, field, obj) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res + } + + out.Concurrently(i, func() graphql.Marshaler { + return innerFunc(ctx) + + }) case "kind": out.Values[i] = ec._Secret_kind(ctx, field, obj) @@ -48363,7 +48452,7 @@ func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel a return res } -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 } @@ -48371,7 +48460,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 } diff --git a/apps/console/internal/app/graph/model/models_gen.go b/apps/console/internal/app/graph/model/models_gen.go index 0e48402b8..b82721027 100644 --- a/apps/console/internal/app/graph/model/models_gen.go +++ b/apps/console/internal/app/graph/model/models_gen.go @@ -259,19 +259,19 @@ type GithubComKloudliteOperatorApisCrdsV1EnvironmentSpecIn struct { } type GithubComKloudliteOperatorApisCrdsV1Hpa struct { - Enabled *bool `json:"enabled,omitempty"` - MaxReplicas *int `json:"maxReplicas,omitempty"` - MinReplicas *int `json:"minReplicas,omitempty"` - ThresholdCPU *int `json:"thresholdCpu,omitempty"` - ThresholdMemory *int `json:"thresholdMemory,omitempty"` + Enabled bool `json:"enabled"` + MaxReplicas *int `json:"maxReplicas,omitempty"` + MinReplicas *int `json:"minReplicas,omitempty"` + ThresholdCPU *int `json:"thresholdCpu,omitempty"` + ThresholdMemory *int `json:"thresholdMemory,omitempty"` } type GithubComKloudliteOperatorApisCrdsV1HPAIn struct { - Enabled *bool `json:"enabled,omitempty"` - MaxReplicas *int `json:"maxReplicas,omitempty"` - MinReplicas *int `json:"minReplicas,omitempty"` - ThresholdCPU *int `json:"thresholdCpu,omitempty"` - ThresholdMemory *int `json:"thresholdMemory,omitempty"` + Enabled bool `json:"enabled"` + MaxReplicas *int `json:"maxReplicas,omitempty"` + MinReplicas *int `json:"minReplicas,omitempty"` + ThresholdCPU *int `json:"thresholdCpu,omitempty"` + ThresholdMemory *int `json:"thresholdMemory,omitempty"` } type GithubComKloudliteOperatorApisCrdsV1HTTPGetProbe struct { diff --git a/apps/console/internal/app/graph/secret.resolvers.go b/apps/console/internal/app/graph/secret.resolvers.go index c45b97278..412a49030 100644 --- a/apps/console/internal/app/graph/secret.resolvers.go +++ b/apps/console/internal/app/graph/secret.resolvers.go @@ -6,6 +6,7 @@ package graph import ( "context" + "fmt" "github.com/kloudlite/api/pkg/errors" "time" @@ -45,6 +46,11 @@ func (r *secretResolver) ID(ctx context.Context, obj *entities.Secret) (string, return string(obj.Id), nil } +// IsReadyOnly is the resolver for the isReadyOnly field. +func (r *secretResolver) IsReadyOnly(ctx context.Context, obj *entities.Secret) (bool, error) { + panic(fmt.Errorf("not implemented: IsReadyOnly - isReadyOnly")) +} + // StringData is the resolver for the stringData field. func (r *secretResolver) StringData(ctx context.Context, obj *entities.Secret) (map[string]interface{}, error) { var m map[string]any diff --git a/apps/console/internal/app/graph/struct-to-graphql/common-types.graphqls b/apps/console/internal/app/graph/struct-to-graphql/common-types.graphqls index 152aa9ed3..0225dd957 100644 --- a/apps/console/internal/app/graph/struct-to-graphql/common-types.graphqls +++ b/apps/console/internal/app/graph/struct-to-graphql/common-types.graphqls @@ -110,7 +110,7 @@ type Github__com___kloudlite___operator___apis___crds___v1__EnvironmentSpec @sha } type Github__com___kloudlite___operator___apis___crds___v1__HPA @shareable { - enabled: Boolean + enabled: Boolean! maxReplicas: Int minReplicas: Int thresholdCpu: Int @@ -379,7 +379,7 @@ input Github__com___kloudlite___operator___apis___crds___v1__EnvironmentSpecIn { } input Github__com___kloudlite___operator___apis___crds___v1__HPAIn { - enabled: Boolean + enabled: Boolean! maxReplicas: Int minReplicas: Int thresholdCpu: Int diff --git a/apps/console/internal/app/graph/struct-to-graphql/secret.graphqls b/apps/console/internal/app/graph/struct-to-graphql/secret.graphqls index 644c32df7..c7ad397e8 100644 --- a/apps/console/internal/app/graph/struct-to-graphql/secret.graphqls +++ b/apps/console/internal/app/graph/struct-to-graphql/secret.graphqls @@ -8,6 +8,7 @@ type Secret @shareable { environmentName: String! id: String! immutable: Boolean + isReadyOnly: Boolean! kind: String lastUpdatedBy: Github__com___kloudlite___api___common__CreatedOrUpdatedBy! markedForDeletion: Boolean diff --git a/go.mod b/go.mod index 5ce609aad..6ee49df15 100644 --- a/go.mod +++ b/go.mod @@ -42,7 +42,7 @@ require ( require ( github.com/kloudlite/container-registry-authorizer v0.0.0-20231021122509-161dc30fde55 - github.com/kloudlite/operator v1.0.4-0.20240304120205-71b62093a405 + github.com/kloudlite/operator v1.0.4-0.20240305112630-9048b76e9997 github.com/nats-io/nats.go v1.31.0 github.com/onsi/ginkgo/v2 v2.12.0 github.com/onsi/gomega v1.27.10 diff --git a/go.sum b/go.sum index c5d321255..a7dfde213 100644 --- a/go.sum +++ b/go.sum @@ -162,22 +162,8 @@ github.com/klauspost/compress v1.17.0 h1:Rnbp4K9EjcDuVuHtd0dgA4qNuv9yKDYKK1ulpJw github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/kloudlite/container-registry-authorizer v0.0.0-20231021122509-161dc30fde55 h1:YnZh3TL6AG4EfoInx1/L5zcPHd2QxgLKseJB1KtHjdQ= github.com/kloudlite/container-registry-authorizer v0.0.0-20231021122509-161dc30fde55/go.mod h1:GZj3wZmIw/qCciclRhgQTgmGiqe8wxoVzMXQjbOfnbc= -github.com/kloudlite/operator v0.0.0-20240116073010-358659b6c673 h1:t3e61wr+c2jUzsNmAJx1aPsev5L+yL1rOtIj1KNZ9g0= -github.com/kloudlite/operator v0.0.0-20240116073010-358659b6c673/go.mod h1:eD8xKzwOVtajAglELcEHn2XL4H22ERBLT2uaisA6SzQ= -github.com/kloudlite/operator v0.0.0-20240124071634-f1e66969c02c h1:oo6k+eLZ8EULnjLtO0iGTLrw9pcBfWhqYnB8dGBaSvE= -github.com/kloudlite/operator v0.0.0-20240124071634-f1e66969c02c/go.mod h1:eD8xKzwOVtajAglELcEHn2XL4H22ERBLT2uaisA6SzQ= -github.com/kloudlite/operator v0.0.0-20240125192852-5c63464fe989 h1:mHshQnMCWiqpHwYn87ARpYRVyN57q0ksOKCM4wXmeHc= -github.com/kloudlite/operator v0.0.0-20240125192852-5c63464fe989/go.mod h1:eD8xKzwOVtajAglELcEHn2XL4H22ERBLT2uaisA6SzQ= -github.com/kloudlite/operator v1.0.3-0.20240214140630-cabaf59fe3d4 h1:bpYACb4+ayPc9FQ4kjBLJP6O6uxIW3kLF2tJQXHAnG8= -github.com/kloudlite/operator v1.0.3-0.20240214140630-cabaf59fe3d4/go.mod h1:eD8xKzwOVtajAglELcEHn2XL4H22ERBLT2uaisA6SzQ= -github.com/kloudlite/operator v1.0.4-0.20240222110024-40f5cdf20fd5 h1:4MpUX5eGryD03gMG4XuzdvfsTjSSUtJhTI4OR+vE2q0= -github.com/kloudlite/operator v1.0.4-0.20240222110024-40f5cdf20fd5/go.mod h1:kMXogvCB4qSG56WlJ5lhyL6JVeVLJ+IyyE18g/1FF1I= -github.com/kloudlite/operator v1.0.4-0.20240301102315-eaaca2bf5858 h1:9xwI6Kg3nyUfbElzjb/XMM7PM1O5aVlde+4Ftcs7ZtM= -github.com/kloudlite/operator v1.0.4-0.20240301102315-eaaca2bf5858/go.mod h1:kMXogvCB4qSG56WlJ5lhyL6JVeVLJ+IyyE18g/1FF1I= -github.com/kloudlite/operator v1.0.4-0.20240302150206-a2acd5f489a9 h1:53uXx3WcoxUDr+niHvABk/0Wgo6i5AvjG93Mhs5RCjw= -github.com/kloudlite/operator v1.0.4-0.20240302150206-a2acd5f489a9/go.mod h1:kMXogvCB4qSG56WlJ5lhyL6JVeVLJ+IyyE18g/1FF1I= -github.com/kloudlite/operator v1.0.4-0.20240304120205-71b62093a405 h1:JOLs3M3kx3xRjQkCpEIkh2I+qfUd2HRVYZ1g7saw3Nk= -github.com/kloudlite/operator v1.0.4-0.20240304120205-71b62093a405/go.mod h1:kMXogvCB4qSG56WlJ5lhyL6JVeVLJ+IyyE18g/1FF1I= +github.com/kloudlite/operator v1.0.4-0.20240305112630-9048b76e9997 h1:O2+MX8Fah90KzFLly7gf25CD1Euob3WIz14mBHWLjCM= +github.com/kloudlite/operator v1.0.4-0.20240305112630-9048b76e9997/go.mod h1:kMXogvCB4qSG56WlJ5lhyL6JVeVLJ+IyyE18g/1FF1I= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=