diff --git a/internal/graphapi/origin.resolvers.go b/internal/graphapi/origin.resolvers.go index e4a77a005..e1a36c39f 100644 --- a/internal/graphapi/origin.resolvers.go +++ b/internal/graphapi/origin.resolvers.go @@ -17,12 +17,12 @@ import ( func (r *mutationResolver) LoadBalancerOriginCreate(ctx context.Context, input generated.CreateLoadBalancerOriginInput) (*LoadBalancerOriginCreatePayload, error) { logger := r.logger.With("poolID", input.PoolID) - if err := permissions.CheckAccess(ctx, input.PoolID, actionLoadBalancerPoolUpdate); err != nil { + // check gidx format + if _, err := gidx.Parse(input.PoolID.String()); err != nil { return nil, err } - // check gidx format - if _, err := gidx.Parse(input.PoolID.String()); err != nil { + if err := permissions.CheckAccess(ctx, input.PoolID, actionLoadBalancerPoolUpdate); err != nil { return nil, err } diff --git a/internal/graphapi/pool.resolvers.go b/internal/graphapi/pool.resolvers.go index f6c08add2..5373db0c9 100644 --- a/internal/graphapi/pool.resolvers.go +++ b/internal/graphapi/pool.resolvers.go @@ -18,6 +18,8 @@ import ( // LoadBalancerPoolCreate is the resolver for the LoadBalancerPoolCreate field. func (r *mutationResolver) LoadBalancerPoolCreate(ctx context.Context, input generated.CreateLoadBalancerPoolInput) (*LoadBalancerPoolCreatePayload, error) { + logger := r.logger.With("ownerID", input.OwnerID) + // check gidx owner format if _, err := gidx.Parse(input.OwnerID.String()); err != nil { return nil, err @@ -33,7 +35,7 @@ func (r *mutationResolver) LoadBalancerPoolCreate(ctx context.Context, input gen return nil, err } - r.logger.Errorw("failed to create loadbalancer pool", "error", err) + logger.Errorw("failed to create loadbalancer pool", "error", err) return nil, ErrInternalServerError } @@ -42,7 +44,7 @@ func (r *mutationResolver) LoadBalancerPoolCreate(ctx context.Context, input gen // LoadBalancerPoolUpdate is the resolver for the LoadBalancerPoolUpdate field. func (r *mutationResolver) LoadBalancerPoolUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerPoolInput) (*LoadBalancerPoolUpdatePayload, error) { - logger := r.logger.With("loadbalancerPoolID", id.String()) + logger := r.logger.With("loadbalancerPoolID", id) // check gidx format if _, err := gidx.Parse(id.String()); err != nil { @@ -78,7 +80,7 @@ func (r *mutationResolver) LoadBalancerPoolUpdate(ctx context.Context, id gidx.P // LoadBalancerPoolDelete is the resolver for the loadBalancerPoolDelete field. func (r *mutationResolver) LoadBalancerPoolDelete(ctx context.Context, id gidx.PrefixedID) (*LoadBalancerPoolDeletePayload, error) { - logger := r.logger.With("loadbalancerPoolID", id.String()) + logger := r.logger.With("loadbalancerPoolID", id) // check gidx format if _, err := gidx.Parse(id.String()); err != nil { @@ -106,8 +108,6 @@ func (r *mutationResolver) LoadBalancerPoolDelete(ctx context.Context, id gidx.P defer tx.Rollback() - // todo: cleanup pool assigments - // cleanup origins associated with pool origins, err := tx.Origin.Query().Where(predicate.Origin(origin.PoolIDEQ(id))).All(ctx) if err != nil { diff --git a/internal/graphapi/port.resolvers.go b/internal/graphapi/port.resolvers.go index 6438261ad..022d6b46f 100644 --- a/internal/graphapi/port.resolvers.go +++ b/internal/graphapi/port.resolvers.go @@ -16,6 +16,8 @@ import ( // LoadBalancerPortCreate is the resolver for the loadBalancerPortCreate field. func (r *mutationResolver) LoadBalancerPortCreate(ctx context.Context, input generated.CreateLoadBalancerPortInput) (*LoadBalancerPortCreatePayload, error) { + logger := r.logger.With("loadbalancerID", input.LoadBalancerID, "loadbalancerPools", input.PoolIDs) + // check gidx lb id format if _, err := gidx.Parse(input.LoadBalancerID.String()); err != nil { return nil, err @@ -40,7 +42,7 @@ func (r *mutationResolver) LoadBalancerPortCreate(ctx context.Context, input gen case generated.IsValidationError(err): return nil, err default: - r.logger.Errorw("failed to create loadbalancer port", "error", err) + logger.Errorw("failed to create loadbalancer port", "error", err) return nil, ErrInternalServerError } } @@ -50,7 +52,7 @@ func (r *mutationResolver) LoadBalancerPortCreate(ctx context.Context, input gen // LoadBalancerPortUpdate is the resolver for the loadBalancerPortUpdate field. func (r *mutationResolver) LoadBalancerPortUpdate(ctx context.Context, id gidx.PrefixedID, input generated.UpdateLoadBalancerPortInput) (*LoadBalancerPortUpdatePayload, error) { - logger := r.logger.With("loadbalancerPortID", id.String()) + logger := r.logger.With("loadbalancerPortID", id) // check gidx format if _, err := gidx.Parse(id.String()); err != nil {