diff --git a/e2e/plugin/plugin_test.go b/e2e/plugin/plugin_test.go index 5a3e5d5c0..1c9892bee 100644 --- a/e2e/plugin/plugin_test.go +++ b/e2e/plugin/plugin_test.go @@ -140,6 +140,12 @@ var _ = Describe("Test Kubectl Plugin", func() { Expect(output).Should(ContainSubstring("targetPort")) Expect(output).Should(ContainSubstring("target port num for service provider.")) }) + It("Test show traitDefinition def with cue single map parameter", func() { + tdName := "annotations" + output, err := e2e.Exec(fmt.Sprintf("kubectl-vela show %s", tdName)) + Expect(err).NotTo(HaveOccurred()) + Expect(output).Should(ContainSubstring("map[string]string")) + }) }) Context("Test kubectl vela comp discover", func() { diff --git a/references/plugins/references.go b/references/plugins/references.go index 163b36aa0..b452d8b75 100644 --- a/references/plugins/references.go +++ b/references/plugins/references.go @@ -536,6 +536,17 @@ func (ref *ParseReference) parseParameters(paraValue cue.Value, paramKey string, if err != nil { return fmt.Errorf("arguments not defined as struct %w", err) } + if arguments.Len() == 0 { + var param ReferenceParameter + param.Name = "undefined" + param.Required = true + tl := paraValue.Template() + if tl != nil { // is map type + param.PrintableType = fmt.Sprintf("map[string]%s", tl("").IncompleteKind().String()) + } + params = append(params, param) + } + for i := 0; i < arguments.Len(); i++ { var param ReferenceParameter fi := arguments.Field(i)