From 11325d13cdc272f4e30220110ad08590adbde560 Mon Sep 17 00:00:00 2001 From: Srinandan Sridhar <13950006+srinandan@users.noreply.github.com> Date: Fri, 22 Mar 2024 08:27:40 -0700 Subject: [PATCH] chore: add docs for resource types #440 (#441) --- internal/client/res/res.go | 10 +++++++--- internal/cmd/res/crtres.go | 3 ++- internal/cmd/res/delres.go | 3 ++- internal/cmd/res/getres.go | 3 ++- internal/cmd/res/updres.go | 3 ++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/internal/client/res/res.go b/internal/client/res/res.go index 4082e96a8..911920ca0 100644 --- a/internal/client/res/res.go +++ b/internal/client/res/res.go @@ -22,6 +22,9 @@ import ( "internal/apiclient" ) +// validResourceTypes contains a list of valid resources +var validResourceTypes = []string{"js", "jsc", "properties", "java", "wsdl", "xsd", "py", "xslt", "oas", "graphql"} + // Create func Create(name string, resPath string, resourceType string) (respBody []byte, err error) { if !validate(resourceType) { @@ -100,9 +103,6 @@ func List(resourceType string) (respBody []byte, err error) { // validate returns true is the resource type is valid func validate(resType string) bool { - // validResourceTypes contains a list of valid resources - validResourceTypes := [10]string{"js", "jsc", "properties", "java", "wsdl", "xsd", "py", "xslt", "oas", "graphql"} - for _, n := range validResourceTypes { if n == resType { return true @@ -110,3 +110,7 @@ func validate(resType string) bool { } return false } + +func GetValidResourceTypes() []string { + return validResourceTypes +} diff --git a/internal/cmd/res/crtres.go b/internal/cmd/res/crtres.go index 764248685..8b7bdc472 100644 --- a/internal/cmd/res/crtres.go +++ b/internal/cmd/res/crtres.go @@ -16,6 +16,7 @@ package res import ( "internal/apiclient" + "strings" "internal/client/res" @@ -44,7 +45,7 @@ func init() { CreateCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the resource file") CreateCmd.Flags().StringVarP(&resType, "type", "p", - "", "Resource type; Valid types include java, js, jsc, properties, py, wsdl, xsd, or xsl.") + "", "Resource type; Valid types include "+strings.Join(res.GetValidResourceTypes(), ", ")) CreateCmd.Flags().StringVarP(&resPath, "respath", "", "", "Resource Path") diff --git a/internal/cmd/res/delres.go b/internal/cmd/res/delres.go index cf5688861..d48a052df 100644 --- a/internal/cmd/res/delres.go +++ b/internal/cmd/res/delres.go @@ -16,6 +16,7 @@ package res import ( "internal/apiclient" + "strings" "internal/client/res" @@ -42,7 +43,7 @@ func init() { DelCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the resource file") DelCmd.Flags().StringVarP(&resType, "type", "p", - "", "Resource type") + "", "Resource type. Valid resource types include "+strings.Join(res.GetValidResourceTypes(), ", ")) _ = DelCmd.MarkFlagRequired("name") _ = DelCmd.MarkFlagRequired("type") diff --git a/internal/cmd/res/getres.go b/internal/cmd/res/getres.go index 9c3d6674e..41d2190a1 100644 --- a/internal/cmd/res/getres.go +++ b/internal/cmd/res/getres.go @@ -16,6 +16,7 @@ package res import ( "internal/apiclient" + "strings" "internal/client/res" @@ -41,7 +42,7 @@ func init() { GetCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the resource file") GetCmd.Flags().StringVarP(&resType, "type", "p", - "", "Resource type") + "", "Resource type. Valid resource types include "+strings.Join(res.GetValidResourceTypes(), ", ")) _ = GetCmd.MarkFlagRequired("name") _ = GetCmd.MarkFlagRequired("type") diff --git a/internal/cmd/res/updres.go b/internal/cmd/res/updres.go index 61fb12545..015608804 100644 --- a/internal/cmd/res/updres.go +++ b/internal/cmd/res/updres.go @@ -16,6 +16,7 @@ package res import ( "internal/apiclient" + "strings" "internal/client/res" @@ -41,7 +42,7 @@ func init() { UpdateCmd.Flags().StringVarP(&name, "name", "n", "", "Name of the resource file") UpdateCmd.Flags().StringVarP(&resType, "type", "p", - "", "Resource type. Valid types include java, js, jsc, properties, py, wsdl, xsd, or xsl.") + "", "Resource type. Valid types include "+strings.Join(res.GetValidResourceTypes(), ", ")) UpdateCmd.Flags().StringVarP(&resPath, "respath", "", "", "Resource Path")