From 687fec775c93b894fb590bd8552f0367ac6de317 Mon Sep 17 00:00:00 2001 From: Stephen Hwang <126002920+sthwang-metal@users.noreply.github.com> Date: Wed, 6 Dec 2023 16:27:12 +0000 Subject: [PATCH] make port name optional --- internal/ent/generated/port/port.go | 2 -- internal/ent/generated/port_create.go | 5 ----- internal/ent/generated/port_update.go | 10 ---------- internal/ent/generated/runtime.go | 4 ---- internal/ent/schema/port.go | 1 - internal/graphapi/loadbalancer.resolvers.go | 10 ++++------ internal/graphapi/origin.resolvers.go | 8 +++----- internal/graphapi/pool.resolvers.go | 10 ++++------ internal/graphapi/port.resolvers.go | 8 +++----- 9 files changed, 14 insertions(+), 44 deletions(-) diff --git a/internal/ent/generated/port/port.go b/internal/ent/generated/port/port.go index e66051d84..01c1f3bf0 100644 --- a/internal/ent/generated/port/port.go +++ b/internal/ent/generated/port/port.go @@ -94,8 +94,6 @@ var ( UpdateDefaultUpdatedAt func() time.Time // NumberValidator is a validator for the "number" field. It is called by the builders before save. NumberValidator func(int) error - // NameValidator is a validator for the "name" field. It is called by the builders before save. - NameValidator func(string) error // LoadBalancerIDValidator is a validator for the "load_balancer_id" field. It is called by the builders before save. LoadBalancerIDValidator func(string) error // DefaultID holds the default value on creation for the "id" field. diff --git a/internal/ent/generated/port_create.go b/internal/ent/generated/port_create.go index 70b7276f8..148089e05 100644 --- a/internal/ent/generated/port_create.go +++ b/internal/ent/generated/port_create.go @@ -185,11 +185,6 @@ func (pc *PortCreate) check() error { if _, ok := pc.mutation.Name(); !ok { return &ValidationError{Name: "name", err: errors.New(`generated: missing required field "Port.name"`)} } - if v, ok := pc.mutation.Name(); ok { - if err := port.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Port.name": %w`, err)} - } - } if _, ok := pc.mutation.LoadBalancerID(); !ok { return &ValidationError{Name: "load_balancer_id", err: errors.New(`generated: missing required field "Port.load_balancer_id"`)} } diff --git a/internal/ent/generated/port_update.go b/internal/ent/generated/port_update.go index eaafe3f94..2c1de4074 100644 --- a/internal/ent/generated/port_update.go +++ b/internal/ent/generated/port_update.go @@ -146,11 +146,6 @@ func (pu *PortUpdate) check() error { return &ValidationError{Name: "number", err: fmt.Errorf(`generated: validator failed for field "Port.number": %w`, err)} } } - if v, ok := pu.mutation.Name(); ok { - if err := port.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Port.name": %w`, err)} - } - } if _, ok := pu.mutation.LoadBalancerID(); pu.mutation.LoadBalancerCleared() && !ok { return errors.New(`generated: clearing a required unique edge "Port.load_balancer"`) } @@ -362,11 +357,6 @@ func (puo *PortUpdateOne) check() error { return &ValidationError{Name: "number", err: fmt.Errorf(`generated: validator failed for field "Port.number": %w`, err)} } } - if v, ok := puo.mutation.Name(); ok { - if err := port.NameValidator(v); err != nil { - return &ValidationError{Name: "name", err: fmt.Errorf(`generated: validator failed for field "Port.name": %w`, err)} - } - } if _, ok := puo.mutation.LoadBalancerID(); puo.mutation.LoadBalancerCleared() && !ok { return errors.New(`generated: clearing a required unique edge "Port.load_balancer"`) } diff --git a/internal/ent/generated/runtime.go b/internal/ent/generated/runtime.go index 461f5059f..40b521c21 100644 --- a/internal/ent/generated/runtime.go +++ b/internal/ent/generated/runtime.go @@ -199,10 +199,6 @@ func init() { return nil } }() - // portDescName is the schema descriptor for name field. - portDescName := portFields[2].Descriptor() - // port.NameValidator is a validator for the "name" field. It is called by the builders before save. - port.NameValidator = portDescName.Validators[0].(func(string) error) // portDescLoadBalancerID is the schema descriptor for load_balancer_id field. portDescLoadBalancerID := portFields[3].Descriptor() // port.LoadBalancerIDValidator is a validator for the "load_balancer_id" field. It is called by the builders before save. diff --git a/internal/ent/schema/port.go b/internal/ent/schema/port.go index 414909019..47fe46f3c 100644 --- a/internal/ent/schema/port.go +++ b/internal/ent/schema/port.go @@ -48,7 +48,6 @@ func (Port) Fields() []ent.Field { entgql.OrderField("number"), ), field.String("name"). - NotEmpty(). Annotations( entgql.OrderField("name"), ), diff --git a/internal/graphapi/loadbalancer.resolvers.go b/internal/graphapi/loadbalancer.resolvers.go index 57e8cfc02..cf49665d6 100644 --- a/internal/graphapi/loadbalancer.resolvers.go +++ b/internal/graphapi/loadbalancer.resolvers.go @@ -8,17 +8,15 @@ 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/pkg/metadata" - "go.infratographer.com/load-balancer-api/internal/config" "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/port" "go.infratographer.com/load-balancer-api/internal/ent/generated/predicate" + "go.infratographer.com/load-balancer-api/pkg/metadata" + "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 f8c8f61eb..d0b11f09e 100644 --- a/internal/graphapi/origin.resolvers.go +++ b/internal/graphapi/origin.resolvers.go @@ -7,15 +7,13 @@ package graphapi import ( "context" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/gidx" - - "go.infratographer.com/load-balancer-api/pkg/metadata" - "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/ent/generated/origin" "go.infratographer.com/load-balancer-api/internal/ent/generated/pool" "go.infratographer.com/load-balancer-api/internal/ent/generated/port" + "go.infratographer.com/load-balancer-api/pkg/metadata" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/gidx" ) // LoadBalancerOriginCreate is the resolver for the loadBalancerOriginCreate field. diff --git a/internal/graphapi/pool.resolvers.go b/internal/graphapi/pool.resolvers.go index cbe279f22..11150e0a7 100644 --- a/internal/graphapi/pool.resolvers.go +++ b/internal/graphapi/pool.resolvers.go @@ -8,18 +8,16 @@ import ( "context" "database/sql" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/gidx" - "golang.org/x/exp/slices" - - "go.infratographer.com/load-balancer-api/pkg/metadata" - "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/pool" "go.infratographer.com/load-balancer-api/internal/ent/generated/port" "go.infratographer.com/load-balancer-api/internal/ent/generated/predicate" + "go.infratographer.com/load-balancer-api/pkg/metadata" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/gidx" + "golang.org/x/exp/slices" ) // LoadBalancerPoolCreate is the resolver for the LoadBalancerPoolCreate field. diff --git a/internal/graphapi/port.resolvers.go b/internal/graphapi/port.resolvers.go index 4d3133df7..1ed4b3951 100644 --- a/internal/graphapi/port.resolvers.go +++ b/internal/graphapi/port.resolvers.go @@ -8,13 +8,11 @@ import ( "context" "strings" - "go.infratographer.com/permissions-api/pkg/permissions" - "go.infratographer.com/x/gidx" - - "go.infratographer.com/load-balancer-api/pkg/metadata" - "go.infratographer.com/load-balancer-api/internal/ent/generated" "go.infratographer.com/load-balancer-api/internal/ent/generated/pool" + "go.infratographer.com/load-balancer-api/pkg/metadata" + "go.infratographer.com/permissions-api/pkg/permissions" + "go.infratographer.com/x/gidx" ) // LoadBalancerPortCreate is the resolver for the loadBalancerPortCreate field.