From 65e9b19b2d6aaf089f309771fcd8d6abd86cf66c Mon Sep 17 00:00:00 2001 From: Mathias Petermann Date: Tue, 26 Mar 2024 08:27:23 +0100 Subject: [PATCH] Fix linting issues Signed-off-by: Mathias Petermann --- pkg/schema/type.go | 2 +- pkg/validations/validate.go | 25 ++++++++++++------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/pkg/schema/type.go b/pkg/schema/type.go index a9777cb0..c670030c 100644 --- a/pkg/schema/type.go +++ b/pkg/schema/type.go @@ -630,7 +630,7 @@ func (t *DocumentType) GetValidationMap() map[string]interface{} { } // GetValidationMap provides the OpenAPI validation for the type -func (t MapType) GetValidationMap() map[string]interface{} { +func (m MapType) GetValidationMap() map[string]interface{} { panic("Not implemented because MapType doesn't support validations") } diff --git a/pkg/validations/validate.go b/pkg/validations/validate.go index 8099c058..27bafb44 100644 --- a/pkg/validations/validate.go +++ b/pkg/validations/validate.go @@ -57,31 +57,30 @@ type validationKwargs struct { oneOf starlark.Sequence } -// VaklidationMap returns a map of the validationKwargs and their values. -func (n NodeValidation) ValidationMap() map[string]interface{} { - v := n.kwargs +// ValidationMap returns a map of the validationKwargs and their values. +func (v NodeValidation) ValidationMap() map[string]interface{} { validations := make(map[string]interface{}) - if v.minLength != nil { - value, _ := v.minLength.Int64() + if v.kwargs.minLength != nil { + value, _ := v.kwargs.minLength.Int64() validations["minLength"] = value } - if v.maxLength != nil { - value, _ := v.maxLength.Int64() + if v.kwargs.maxLength != nil { + value, _ := v.kwargs.maxLength.Int64() validations["maxLength"] = value } - if v.min != nil { - value, _ := strconv.Atoi(v.min.String()) + if v.kwargs.min != nil { + value, _ := strconv.Atoi(v.kwargs.min.String()) validations["min"] = value } - if v.max != nil { - value, _ := strconv.Atoi(v.max.String()) + if v.kwargs.max != nil { + value, _ := strconv.Atoi(v.kwargs.max.String()) validations["max"] = value } - if v.oneOf != nil { + if v.kwargs.oneOf != nil { enum := []interface{}{} - iter := starlark.Iterate(v.oneOf) + iter := starlark.Iterate(v.kwargs.oneOf) defer iter.Done() var x starlark.Value for iter.Next(&x) {