From 6f3c01616ad78ddee7f52e3a44eb3410a42926ec Mon Sep 17 00:00:00 2001 From: Stavros Kontopoulos Date: Wed, 18 Dec 2024 13:16:26 +0200 Subject: [PATCH] fix --- go.mod | 2 +- pkg/markers/parse.go | 2 +- pkg/markers/parse_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9e8593298..daa9f75cf 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,7 @@ module sigs.k8s.io/controller-tools go 1.21 -toolchain go1.22.0 +toolchain go1.22.10 require ( github.com/fatih/color v1.16.0 diff --git a/pkg/markers/parse.go b/pkg/markers/parse.go index 259bff027..7ae6e28f2 100644 --- a/pkg/markers/parse.go +++ b/pkg/markers/parse.go @@ -910,7 +910,7 @@ func (d *Definition) Parse(rawMarker string) (interface{}, error) { if d.Strict { for argName, arg := range d.Fields { - if _, wasSeen := seen[argName]; !wasSeen && !arg.Optional { + if _, wasSeen := seen[argName]; !wasSeen && !arg.Optional && argName != "" { scanner.Error(scanner, fmt.Sprintf("missing argument %q", argName)) } } diff --git a/pkg/markers/parse_test.go b/pkg/markers/parse_test.go index 012da56f9..1606bb05a 100644 --- a/pkg/markers/parse_test.go +++ b/pkg/markers/parse_test.go @@ -85,9 +85,9 @@ var _ = Describe("Parsing", func() { It("should work with fiddled field names", parseTestCase{reg: ®, raw: "+testing:custom={hi}", output: CustomType{Value: []string{"hi"}}}.Run) It("should parse name-only markers", parseTestCase{reg: ®, raw: "+testing:empty", output: struct{}{}}.Run) - Context("when parsing anonymous markers", func() { It("should parse into literal-typed values", parseTestCase{reg: ®, raw: "+testing:anonymous:literal=foo", output: "foo"}.Run) + It("should parse into literal-typed values", parseTestCase{reg: ®, raw: "+testing:anonymous:literal=", output: ""}.Run) It("should parse into named-typed values", parseTestCase{reg: ®, raw: "+testing:anonymous:named=foo", output: wrappedMarkerVal("foo")}.Run) It("shouldn't require any argument to an optional-valued marker", parseTestCase{reg: ®, raw: "+testing:anonymousOptional", output: (*int)(nil)}.Run) })