From b78e4596aa63349e34860658f107398bd8010b5b Mon Sep 17 00:00:00 2001 From: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com> Date: Tue, 17 Oct 2023 19:41:35 +0000 Subject: [PATCH] change to int instead of bigint Signed-off-by: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com> --- .../20231017005257_add_origin_weight.sql | 2 +- go.sum | 8 ++ internal/ent/generated/gql_mutation_input.go | 4 +- internal/ent/generated/gql_where_input.go | 16 ++-- internal/ent/generated/migrate/schema.go | 2 +- internal/ent/generated/mutation.go | 18 ++-- internal/ent/generated/origin.go | 4 +- internal/ent/generated/origin/origin.go | 2 +- internal/ent/generated/origin/where.go | 18 ++-- internal/ent/generated/origin_create.go | 6 +- internal/ent/generated/origin_update.go | 20 ++-- internal/ent/generated/runtime.go | 2 +- internal/ent/schema/origin.go | 6 +- internal/graphapi/gen_server.go | 93 ++++++++++++++++--- internal/graphapi/loadbalancer.resolvers.go | 7 +- internal/graphapi/origin.resolvers.go | 3 +- internal/graphapi/pool.resolvers.go | 5 +- internal/graphapi/port.resolvers.go | 5 +- internal/graphapi/provider.resolvers.go | 3 +- 19 files changed, 147 insertions(+), 77 deletions(-) diff --git a/db/migrations/20231017005257_add_origin_weight.sql b/db/migrations/20231017005257_add_origin_weight.sql index 4f2e20532..6bbfef024 100644 --- a/db/migrations/20231017005257_add_origin_weight.sql +++ b/db/migrations/20231017005257_add_origin_weight.sql @@ -1,6 +1,6 @@ -- +goose Up -- modify "origins" table -ALTER TABLE "origins" ADD COLUMN "weight" bigint NOT NULL DEFAULT 100; +ALTER TABLE "origins" ADD COLUMN "weight" int NOT NULL DEFAULT 100; -- +goose Down -- reverse: modify "origins" table diff --git a/go.sum b/go.sum index a4fbe7157..2d91bae55 100644 --- a/go.sum +++ b/go.sum @@ -108,6 +108,7 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7 github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/cpuguy83/dockercfg v0.3.1 h1:/FpZ+JaygUR/lZP2NlFI2DVfrOEMAIKP5wWEJdoYe9E= github.com/cpuguy83/dockercfg v0.3.1/go.mod h1:sugsbF4//dDlL/i+S+rtpIWp+5h0BHJHfjj5/jFyUJc= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= @@ -474,6 +475,8 @@ github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncj github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= +github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/sebdah/goldie/v2 v2.5.3 h1:9ES/mNN+HNUbNWpVAlrzuZ7jE+Nrczbj8uFRjM7624Y= @@ -542,6 +545,9 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU= github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/urfave/cli v1.22.12 h1:igJgVw1JdKH+trcLWLeLwZjU9fEfPesQ+9/e4MQ44S8= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= +github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= @@ -557,6 +563,8 @@ github.com/vmihailenco/tagparser v0.1.2 h1:gnjoVuB/kljJ5wICEEOpx98oXMWPLj22G67Vb github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= github.com/wundergraph/graphql-go-tools v1.66.4 h1:yRvXYi0jjTghi5zimTluqHXAmyS7JVlGzTlxY6aL0sI= github.com/wundergraph/graphql-go-tools v1.66.4/go.mod h1:obaEJWub7088qodhKbSGHyhRVnHlBP5M9HigN/oalLE= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= diff --git a/internal/ent/generated/gql_mutation_input.go b/internal/ent/generated/gql_mutation_input.go index 3638dc365..ede04cd8c 100644 --- a/internal/ent/generated/gql_mutation_input.go +++ b/internal/ent/generated/gql_mutation_input.go @@ -86,7 +86,7 @@ func (c *LoadBalancerUpdateOne) SetInput(i UpdateLoadBalancerInput) *LoadBalance // CreateLoadBalancerOriginInput represents a mutation input for creating loadbalancerorigins. type CreateLoadBalancerOriginInput struct { Name string - Weight *int + Weight *int32 Target string PortNumber int Active *bool @@ -116,7 +116,7 @@ func (c *OriginCreate) SetInput(i CreateLoadBalancerOriginInput) *OriginCreate { // UpdateLoadBalancerOriginInput represents a mutation input for updating loadbalancerorigins. type UpdateLoadBalancerOriginInput struct { Name *string - Weight *int + Weight *int32 Target *string PortNumber *int Active *bool diff --git a/internal/ent/generated/gql_where_input.go b/internal/ent/generated/gql_where_input.go index 830eb433c..631c26348 100644 --- a/internal/ent/generated/gql_where_input.go +++ b/internal/ent/generated/gql_where_input.go @@ -373,14 +373,14 @@ type LoadBalancerOriginWhereInput struct { NameContainsFold *string `json:"nameContainsFold,omitempty"` // "weight" field predicates. - Weight *int `json:"weight,omitempty"` - WeightNEQ *int `json:"weightNEQ,omitempty"` - WeightIn []int `json:"weightIn,omitempty"` - WeightNotIn []int `json:"weightNotIn,omitempty"` - WeightGT *int `json:"weightGT,omitempty"` - WeightGTE *int `json:"weightGTE,omitempty"` - WeightLT *int `json:"weightLT,omitempty"` - WeightLTE *int `json:"weightLTE,omitempty"` + Weight *int32 `json:"weight,omitempty"` + WeightNEQ *int32 `json:"weightNEQ,omitempty"` + WeightIn []int32 `json:"weightIn,omitempty"` + WeightNotIn []int32 `json:"weightNotIn,omitempty"` + WeightGT *int32 `json:"weightGT,omitempty"` + WeightGTE *int32 `json:"weightGTE,omitempty"` + WeightLT *int32 `json:"weightLT,omitempty"` + WeightLTE *int32 `json:"weightLTE,omitempty"` // "target" field predicates. Target *string `json:"target,omitempty"` diff --git a/internal/ent/generated/migrate/schema.go b/internal/ent/generated/migrate/schema.go index ae057bba4..3af7f748a 100644 --- a/internal/ent/generated/migrate/schema.go +++ b/internal/ent/generated/migrate/schema.go @@ -79,7 +79,7 @@ var ( {Name: "created_at", Type: field.TypeTime}, {Name: "updated_at", Type: field.TypeTime}, {Name: "name", Type: field.TypeString}, - {Name: "weight", Type: field.TypeInt, Default: 100}, + {Name: "weight", Type: field.TypeInt32, Default: 100}, {Name: "target", Type: field.TypeString}, {Name: "port_number", Type: field.TypeInt}, {Name: "active", Type: field.TypeBool, Default: true}, diff --git a/internal/ent/generated/mutation.go b/internal/ent/generated/mutation.go index 562339201..404173fcf 100644 --- a/internal/ent/generated/mutation.go +++ b/internal/ent/generated/mutation.go @@ -800,8 +800,8 @@ type OriginMutation struct { created_at *time.Time updated_at *time.Time name *string - weight *int - addweight *int + weight *int32 + addweight *int32 target *string port_number *int addport_number *int @@ -1027,13 +1027,13 @@ func (m *OriginMutation) ResetName() { } // SetWeight sets the "weight" field. -func (m *OriginMutation) SetWeight(i int) { +func (m *OriginMutation) SetWeight(i int32) { m.weight = &i m.addweight = nil } // Weight returns the value of the "weight" field in the mutation. -func (m *OriginMutation) Weight() (r int, exists bool) { +func (m *OriginMutation) Weight() (r int32, exists bool) { v := m.weight if v == nil { return @@ -1044,7 +1044,7 @@ func (m *OriginMutation) Weight() (r int, exists bool) { // OldWeight returns the old "weight" field's value of the Origin entity. // If the Origin object wasn't provided to the builder, the object is fetched from the database. // An error is returned if the mutation operation is not UpdateOne, or the database query fails. -func (m *OriginMutation) OldWeight(ctx context.Context) (v int, err error) { +func (m *OriginMutation) OldWeight(ctx context.Context) (v int32, err error) { if !m.op.Is(OpUpdateOne) { return v, errors.New("OldWeight is only allowed on UpdateOne operations") } @@ -1059,7 +1059,7 @@ func (m *OriginMutation) OldWeight(ctx context.Context) (v int, err error) { } // AddWeight adds i to the "weight" field. -func (m *OriginMutation) AddWeight(i int) { +func (m *OriginMutation) AddWeight(i int32) { if m.addweight != nil { *m.addweight += i } else { @@ -1068,7 +1068,7 @@ func (m *OriginMutation) AddWeight(i int) { } // AddedWeight returns the value that was added to the "weight" field in this mutation. -func (m *OriginMutation) AddedWeight() (r int, exists bool) { +func (m *OriginMutation) AddedWeight() (r int32, exists bool) { v := m.addweight if v == nil { return @@ -1412,7 +1412,7 @@ func (m *OriginMutation) SetField(name string, value ent.Value) error { m.SetName(v) return nil case origin.FieldWeight: - v, ok := value.(int) + v, ok := value.(int32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } @@ -1482,7 +1482,7 @@ func (m *OriginMutation) AddedField(name string) (ent.Value, bool) { func (m *OriginMutation) AddField(name string, value ent.Value) error { switch name { case origin.FieldWeight: - v, ok := value.(int) + v, ok := value.(int32) if !ok { return fmt.Errorf("unexpected type %T for field %s", value, name) } diff --git a/internal/ent/generated/origin.go b/internal/ent/generated/origin.go index 641c3ae64..f22c9bedd 100644 --- a/internal/ent/generated/origin.go +++ b/internal/ent/generated/origin.go @@ -40,7 +40,7 @@ type Origin struct { // Name holds the value of the "name" field. Name string `json:"name,omitempty"` // Weight holds the value of the "weight" field. - Weight int `json:"weight,omitempty"` + Weight int32 `json:"weight,omitempty"` // Target holds the value of the "target" field. Target string `json:"target,omitempty"` // PortNumber holds the value of the "port_number" field. @@ -137,7 +137,7 @@ func (o *Origin) assignValues(columns []string, values []any) error { if value, ok := values[i].(*sql.NullInt64); !ok { return fmt.Errorf("unexpected type %T for field weight", values[i]) } else if value.Valid { - o.Weight = int(value.Int64) + o.Weight = int32(value.Int64) } case origin.FieldTarget: if value, ok := values[i].(*sql.NullString); !ok { diff --git a/internal/ent/generated/origin/origin.go b/internal/ent/generated/origin/origin.go index 48a10b826..e62502948 100644 --- a/internal/ent/generated/origin/origin.go +++ b/internal/ent/generated/origin/origin.go @@ -91,7 +91,7 @@ var ( // NameValidator is a validator for the "name" field. It is called by the builders before save. NameValidator func(string) error // DefaultWeight holds the default value on creation for the "weight" field. - DefaultWeight int + DefaultWeight int32 // TargetValidator is a validator for the "target" field. It is called by the builders before save. TargetValidator func(string) error // PortNumberValidator is a validator for the "port_number" field. It is called by the builders before save. diff --git a/internal/ent/generated/origin/where.go b/internal/ent/generated/origin/where.go index 578a9d3d2..2bc8efc51 100644 --- a/internal/ent/generated/origin/where.go +++ b/internal/ent/generated/origin/where.go @@ -86,7 +86,7 @@ func Name(v string) predicate.Origin { } // Weight applies equality check predicate on the "weight" field. It's identical to WeightEQ. -func Weight(v int) predicate.Origin { +func Weight(v int32) predicate.Origin { return predicate.Origin(sql.FieldEQ(FieldWeight, v)) } @@ -256,42 +256,42 @@ func NameContainsFold(v string) predicate.Origin { } // WeightEQ applies the EQ predicate on the "weight" field. -func WeightEQ(v int) predicate.Origin { +func WeightEQ(v int32) predicate.Origin { return predicate.Origin(sql.FieldEQ(FieldWeight, v)) } // WeightNEQ applies the NEQ predicate on the "weight" field. -func WeightNEQ(v int) predicate.Origin { +func WeightNEQ(v int32) predicate.Origin { return predicate.Origin(sql.FieldNEQ(FieldWeight, v)) } // WeightIn applies the In predicate on the "weight" field. -func WeightIn(vs ...int) predicate.Origin { +func WeightIn(vs ...int32) predicate.Origin { return predicate.Origin(sql.FieldIn(FieldWeight, vs...)) } // WeightNotIn applies the NotIn predicate on the "weight" field. -func WeightNotIn(vs ...int) predicate.Origin { +func WeightNotIn(vs ...int32) predicate.Origin { return predicate.Origin(sql.FieldNotIn(FieldWeight, vs...)) } // WeightGT applies the GT predicate on the "weight" field. -func WeightGT(v int) predicate.Origin { +func WeightGT(v int32) predicate.Origin { return predicate.Origin(sql.FieldGT(FieldWeight, v)) } // WeightGTE applies the GTE predicate on the "weight" field. -func WeightGTE(v int) predicate.Origin { +func WeightGTE(v int32) predicate.Origin { return predicate.Origin(sql.FieldGTE(FieldWeight, v)) } // WeightLT applies the LT predicate on the "weight" field. -func WeightLT(v int) predicate.Origin { +func WeightLT(v int32) predicate.Origin { return predicate.Origin(sql.FieldLT(FieldWeight, v)) } // WeightLTE applies the LTE predicate on the "weight" field. -func WeightLTE(v int) predicate.Origin { +func WeightLTE(v int32) predicate.Origin { return predicate.Origin(sql.FieldLTE(FieldWeight, v)) } diff --git a/internal/ent/generated/origin_create.go b/internal/ent/generated/origin_create.go index 5e7e97110..24b7dd441 100644 --- a/internal/ent/generated/origin_create.go +++ b/internal/ent/generated/origin_create.go @@ -71,13 +71,13 @@ func (oc *OriginCreate) SetName(s string) *OriginCreate { } // SetWeight sets the "weight" field. -func (oc *OriginCreate) SetWeight(i int) *OriginCreate { +func (oc *OriginCreate) SetWeight(i int32) *OriginCreate { oc.mutation.SetWeight(i) return oc } // SetNillableWeight sets the "weight" field if the given value is not nil. -func (oc *OriginCreate) SetNillableWeight(i *int) *OriginCreate { +func (oc *OriginCreate) SetNillableWeight(i *int32) *OriginCreate { if i != nil { oc.SetWeight(*i) } @@ -289,7 +289,7 @@ func (oc *OriginCreate) createSpec() (*Origin, *sqlgraph.CreateSpec) { _node.Name = value } if value, ok := oc.mutation.Weight(); ok { - _spec.SetField(origin.FieldWeight, field.TypeInt, value) + _spec.SetField(origin.FieldWeight, field.TypeInt32, value) _node.Weight = value } if value, ok := oc.mutation.Target(); ok { diff --git a/internal/ent/generated/origin_update.go b/internal/ent/generated/origin_update.go index ae26903df..bdddf0551 100644 --- a/internal/ent/generated/origin_update.go +++ b/internal/ent/generated/origin_update.go @@ -48,14 +48,14 @@ func (ou *OriginUpdate) SetName(s string) *OriginUpdate { } // SetWeight sets the "weight" field. -func (ou *OriginUpdate) SetWeight(i int) *OriginUpdate { +func (ou *OriginUpdate) SetWeight(i int32) *OriginUpdate { ou.mutation.ResetWeight() ou.mutation.SetWeight(i) return ou } // SetNillableWeight sets the "weight" field if the given value is not nil. -func (ou *OriginUpdate) SetNillableWeight(i *int) *OriginUpdate { +func (ou *OriginUpdate) SetNillableWeight(i *int32) *OriginUpdate { if i != nil { ou.SetWeight(*i) } @@ -63,7 +63,7 @@ func (ou *OriginUpdate) SetNillableWeight(i *int) *OriginUpdate { } // AddWeight adds i to the "weight" field. -func (ou *OriginUpdate) AddWeight(i int) *OriginUpdate { +func (ou *OriginUpdate) AddWeight(i int32) *OriginUpdate { ou.mutation.AddWeight(i) return ou } @@ -184,10 +184,10 @@ func (ou *OriginUpdate) sqlSave(ctx context.Context) (n int, err error) { _spec.SetField(origin.FieldName, field.TypeString, value) } if value, ok := ou.mutation.Weight(); ok { - _spec.SetField(origin.FieldWeight, field.TypeInt, value) + _spec.SetField(origin.FieldWeight, field.TypeInt32, value) } if value, ok := ou.mutation.AddedWeight(); ok { - _spec.AddField(origin.FieldWeight, field.TypeInt, value) + _spec.AddField(origin.FieldWeight, field.TypeInt32, value) } if value, ok := ou.mutation.Target(); ok { _spec.SetField(origin.FieldTarget, field.TypeString, value) @@ -228,14 +228,14 @@ func (ouo *OriginUpdateOne) SetName(s string) *OriginUpdateOne { } // SetWeight sets the "weight" field. -func (ouo *OriginUpdateOne) SetWeight(i int) *OriginUpdateOne { +func (ouo *OriginUpdateOne) SetWeight(i int32) *OriginUpdateOne { ouo.mutation.ResetWeight() ouo.mutation.SetWeight(i) return ouo } // SetNillableWeight sets the "weight" field if the given value is not nil. -func (ouo *OriginUpdateOne) SetNillableWeight(i *int) *OriginUpdateOne { +func (ouo *OriginUpdateOne) SetNillableWeight(i *int32) *OriginUpdateOne { if i != nil { ouo.SetWeight(*i) } @@ -243,7 +243,7 @@ func (ouo *OriginUpdateOne) SetNillableWeight(i *int) *OriginUpdateOne { } // AddWeight adds i to the "weight" field. -func (ouo *OriginUpdateOne) AddWeight(i int) *OriginUpdateOne { +func (ouo *OriginUpdateOne) AddWeight(i int32) *OriginUpdateOne { ouo.mutation.AddWeight(i) return ouo } @@ -394,10 +394,10 @@ func (ouo *OriginUpdateOne) sqlSave(ctx context.Context) (_node *Origin, err err _spec.SetField(origin.FieldName, field.TypeString, value) } if value, ok := ouo.mutation.Weight(); ok { - _spec.SetField(origin.FieldWeight, field.TypeInt, value) + _spec.SetField(origin.FieldWeight, field.TypeInt32, value) } if value, ok := ouo.mutation.AddedWeight(); ok { - _spec.AddField(origin.FieldWeight, field.TypeInt, value) + _spec.AddField(origin.FieldWeight, field.TypeInt32, value) } if value, ok := ouo.mutation.Target(); ok { _spec.SetField(origin.FieldTarget, field.TypeString, value) diff --git a/internal/ent/generated/runtime.go b/internal/ent/generated/runtime.go index 1150af4c1..461f5059f 100644 --- a/internal/ent/generated/runtime.go +++ b/internal/ent/generated/runtime.go @@ -89,7 +89,7 @@ func init() { // originDescWeight is the schema descriptor for weight field. originDescWeight := originFields[2].Descriptor() // origin.DefaultWeight holds the default value on creation for the weight field. - origin.DefaultWeight = originDescWeight.Default.(int) + origin.DefaultWeight = originDescWeight.Default.(int32) // originDescTarget is the schema descriptor for target field. originDescTarget := originFields[3].Descriptor() // origin.TargetValidator is a validator for the "target" field. It is called by the builders before save. diff --git a/internal/ent/schema/origin.go b/internal/ent/schema/origin.go index fdd791138..1c56e388a 100644 --- a/internal/ent/schema/origin.go +++ b/internal/ent/schema/origin.go @@ -15,9 +15,7 @@ import ( "go.infratographer.com/load-balancer-api/x/pubsubinfo" ) -var ( - defaultOriginWeight = 100 -) +var defaultOriginWeight int32 = 100 // Origin holds the schema definition for the Origin entity. type Origin struct { @@ -44,7 +42,7 @@ func (Origin) Fields() []ent.Field { Annotations( entgql.OrderField("name"), ), - field.Int("weight"). + field.Int32("weight"). Default(defaultOriginWeight). Annotations( entgql.OrderField("weight"), diff --git a/internal/graphapi/gen_server.go b/internal/graphapi/gen_server.go index bb9a23900..a9a6bbd4e 100644 --- a/internal/graphapi/gen_server.go +++ b/internal/graphapi/gen_server.go @@ -5194,9 +5194,9 @@ func (ec *executionContext) _LoadBalancerOrigin_weight(ctx context.Context, fiel } return graphql.Null } - res := resTmp.(int) + res := resTmp.(int32) fc.Result = res - return ec.marshalNInt2int(ctx, field.Selections, res) + return ec.marshalNInt2int32(ctx, field.Selections, res) } func (ec *executionContext) fieldContext_LoadBalancerOrigin_weight(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { @@ -12114,7 +12114,7 @@ func (ec *executionContext) unmarshalInputCreateLoadBalancerOriginInput(ctx cont var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weight")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12782,7 +12782,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weight")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12791,7 +12791,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightNEQ")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12800,7 +12800,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕint32ᚄ(ctx, v) if err != nil { return it, err } @@ -12809,7 +12809,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightNotIn")) - data, err := ec.unmarshalOInt2ᚕintᚄ(ctx, v) + data, err := ec.unmarshalOInt2ᚕint32ᚄ(ctx, v) if err != nil { return it, err } @@ -12818,7 +12818,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightGT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12827,7 +12827,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightGTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12836,7 +12836,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightLT")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -12845,7 +12845,7 @@ func (ec *executionContext) unmarshalInputLoadBalancerOriginWhereInput(ctx conte var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weightLTE")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -15044,7 +15044,7 @@ func (ec *executionContext) unmarshalInputUpdateLoadBalancerOriginInput(ctx cont var err error ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("weight")) - data, err := ec.unmarshalOInt2ᚖint(ctx, v) + data, err := ec.unmarshalOInt2ᚖint32(ctx, v) if err != nil { return it, err } @@ -18405,6 +18405,21 @@ func (ec *executionContext) marshalNInt2int(ctx context.Context, sel ast.Selecti return res } +func (ec *executionContext) unmarshalNInt2int32(ctx context.Context, v interface{}) (int32, error) { + res, err := graphql.UnmarshalInt32(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNInt2int32(ctx context.Context, sel ast.SelectionSet, v int32) graphql.Marshaler { + res := graphql.MarshalInt32(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + func (ec *executionContext) marshalNLoadBalancer2goᚗinfratographerᚗcomᚋloadᚑbalancerᚑapiᚋinternalᚋentᚋgeneratedᚐLoadBalancer(ctx context.Context, sel ast.SelectionSet, v generated.LoadBalancer) graphql.Marshaler { return ec._LoadBalancer(ctx, sel, &v) } @@ -19403,6 +19418,44 @@ func (ec *executionContext) marshalOID2ᚖgoᚗinfratographerᚗcomᚋxᚋgidx return v } +func (ec *executionContext) unmarshalOInt2ᚕint32ᚄ(ctx context.Context, v interface{}) ([]int32, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]int32, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNInt2int32(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOInt2ᚕint32ᚄ(ctx context.Context, sel ast.SelectionSet, v []int32) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNInt2int32(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + func (ec *executionContext) unmarshalOInt2ᚕintᚄ(ctx context.Context, v interface{}) ([]int, error) { if v == nil { return nil, nil @@ -19457,6 +19510,22 @@ func (ec *executionContext) marshalOInt2ᚖint(ctx context.Context, sel ast.Sele return res } +func (ec *executionContext) unmarshalOInt2ᚖint32(ctx context.Context, v interface{}) (*int32, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalInt32(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOInt2ᚖint32(ctx context.Context, sel ast.SelectionSet, v *int32) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalInt32(*v) + return res +} + func (ec *executionContext) marshalOLoadBalancer2ᚖgoᚗinfratographerᚗcomᚋloadᚑbalancerᚑapiᚋinternalᚋentᚋgeneratedᚐLoadBalancer(ctx context.Context, sel ast.SelectionSet, v *generated.LoadBalancer) graphql.Marshaler { if v == nil { return graphql.Null diff --git a/internal/graphapi/loadbalancer.resolvers.go b/internal/graphapi/loadbalancer.resolvers.go index 7362ec994..64a073a79 100644 --- a/internal/graphapi/loadbalancer.resolvers.go +++ b/internal/graphapi/loadbalancer.resolvers.go @@ -8,13 +8,12 @@ import ( "context" "database/sql" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/events" - "go.infratographer.com/x/gidx" - "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/ent/generated/port" "go.infratographer.com/load-balancer-api/internal/ent/generated/predicate" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/events" + "go.infratographer.com/x/gidx" ) // LoadBalancerCreate is the resolver for the loadBalancerCreate field. diff --git a/internal/graphapi/origin.resolvers.go b/internal/graphapi/origin.resolvers.go index 4088c69a6..650f063da 100644 --- a/internal/graphapi/origin.resolvers.go +++ b/internal/graphapi/origin.resolvers.go @@ -7,10 +7,9 @@ package graphapi import ( "context" + "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/permissions-api/pkg/permissions" "go.infratographer.com/x/gidx" - - "go.infratographer.com/load-balancer-api/internal/ent/generated" ) // LoadBalancerOriginCreate is the resolver for the loadBalancerOriginCreate field. diff --git a/internal/graphapi/pool.resolvers.go b/internal/graphapi/pool.resolvers.go index 6e9df7680..890308bfa 100644 --- a/internal/graphapi/pool.resolvers.go +++ b/internal/graphapi/pool.resolvers.go @@ -8,14 +8,13 @@ import ( "context" "database/sql" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/gidx" - "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/ent/generated/loadbalancer" "go.infratographer.com/load-balancer-api/internal/ent/generated/origin" "go.infratographer.com/load-balancer-api/internal/ent/generated/port" "go.infratographer.com/load-balancer-api/internal/ent/generated/predicate" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/gidx" ) // LoadBalancerPoolCreate is the resolver for the LoadBalancerPoolCreate field. diff --git a/internal/graphapi/port.resolvers.go b/internal/graphapi/port.resolvers.go index e973aea36..28fe4ddef 100644 --- a/internal/graphapi/port.resolvers.go +++ b/internal/graphapi/port.resolvers.go @@ -8,11 +8,10 @@ import ( "context" "strings" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/gidx" - "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/ent/generated/pool" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/gidx" ) // LoadBalancerPortCreate is the resolver for the loadBalancerPortCreate field. diff --git a/internal/graphapi/provider.resolvers.go b/internal/graphapi/provider.resolvers.go index f6365ed0f..5f98234b9 100644 --- a/internal/graphapi/provider.resolvers.go +++ b/internal/graphapi/provider.resolvers.go @@ -7,10 +7,9 @@ package graphapi import ( "context" + "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/permissions-api/pkg/permissions" "go.infratographer.com/x/gidx" - - "go.infratographer.com/load-balancer-api/internal/ent/generated" ) // LoadBalancerProviderCreate is the resolver for the loadBalancerProviderCreate field.