Skip to content

Commit

Permalink
added sample that uses no groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Skarlso committed Oct 27, 2024
1 parent fb4424a commit 1641240
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cmd/config_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion cmd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Binary file added imgs/parsed4_groups_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions pkg/config_file_schema.go
Original file line number Diff line number Diff line change
@@ -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"`
Expand All @@ -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"`
}
2 changes: 0 additions & 2 deletions pkg/create_html_output.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import (
"github.com/Skarlso/crd-to-sample-yaml/v1beta1"
)

const defaultGroup = "Ungrouped"

type Index struct {
Page []ViewPage
}
Expand Down

0 comments on commit 1641240

Please sign in to comment.