diff --git a/README.md b/README.md index 20fc646..20b1e6f 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,10 @@ apiGroups: ![rendered with groups](imgs/parsed4_groups.png) +If no grouping information is provided, the rendered CRD's group version is used. + +![rendered without groups](imgs/parsed4_groups_2.png) + ## Schema Generation `cty` also provides a way to generate a JSON Schema out of a CRD. Simply use: diff --git a/cmd/config_handler.go b/cmd/config_handler.go index 7c4721d..ee0b487 100644 --- a/cmd/config_handler.go +++ b/cmd/config_handler.go @@ -31,7 +31,7 @@ func (h *ConfigHandler) CRDs() ([]*pkg.SchemaType, error) { // the CRDs. var result []*pkg.SchemaType - for _, group := range configFile.ApiGroups { + for _, group := range configFile.APIGroups { for _, file := range group.Files { handler := FileHandler{location: file, group: group.Name} fileResults, err := handler.CRDs() diff --git a/cmd/crd.go b/cmd/crd.go index 0333c3b..3d2cb94 100644 --- a/cmd/crd.go +++ b/cmd/crd.go @@ -58,7 +58,7 @@ func runGenerate(_ *cobra.Command, _ []string) error { if crdArgs.format == FormatHTML { if crdArgs.output == "" { - return fmt.Errorf("output must be set to a filename if format is HTML") + return errors.New("output must be set to a filename if format is HTML") } if err := pkg.LoadTemplates(); err != nil { diff --git a/imgs/parsed4_groups_2.png b/imgs/parsed4_groups_2.png new file mode 100644 index 0000000..627c58b Binary files /dev/null and b/imgs/parsed4_groups_2.png differ diff --git a/pkg/config_file_schema.go b/pkg/config_file_schema.go index 6a774cc..ccd58b8 100644 --- a/pkg/config_file_schema.go +++ b/pkg/config_file_schema.go @@ -1,7 +1,7 @@ package pkg -// ApiGroups defines groups by which grouping will happen in the resulting HTML output. -type ApiGroups struct { +// APIGroups defines groups by which grouping will happen in the resulting HTML output. +type APIGroups struct { Name string `json:"name"` Description string `json:"description"` Files []string `json:"files,omitempty"` @@ -10,5 +10,5 @@ type ApiGroups struct { // RenderConfig defines a configuration for the resulting rendered HTML content. type RenderConfig struct { - ApiGroups []ApiGroups `json:"apiGroups"` + APIGroups []APIGroups `json:"apiGroups"` } diff --git a/pkg/create_html_output.go b/pkg/create_html_output.go index 4599593..f12b2cf 100644 --- a/pkg/create_html_output.go +++ b/pkg/create_html_output.go @@ -14,8 +14,6 @@ import ( "github.com/Skarlso/crd-to-sample-yaml/v1beta1" ) -const defaultGroup = "Ungrouped" - type Index struct { Page []ViewPage }