Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pkg/schemapatcher/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,16 @@ func crdsFromDirectory(ctx *genall.GenerationContext, dir string) (map[schema.Gr
if err := kyaml.Unmarshal(rawContent, &typeMeta); err != nil {
continue
}

if typeMeta.APIVersion == "" || typeMeta.Kind != "CustomResourceDefinition" {
// If there's no API version this file probably isn't a CRD.
// Likewise we don't need to care if the Kind isn't CustomResourceDefinition.
continue
}

if !isSupportedAPIExtGroupVer(typeMeta.APIVersion) {
return nil, fmt.Errorf("load %q: apiVersion %q not supported", filepath.Join(dir, fileInfo.Name()), typeMeta.APIVersion)
}
if typeMeta.Kind != "CustomResourceDefinition" {
continue
}

// collect the group-kind and versions from the actual structured form
var actualCRD crdIsh
Expand Down
3 changes: 3 additions & 0 deletions pkg/schemapatcher/testdata/valid/example.cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This is an example of the resource defined in this package.
apiVersion: kubebuilder.schemapatcher.controller-tools.sigs.k8s.io/v1
kind: Example
1 change: 1 addition & 0 deletions pkg/schemapatcher/testdata/valid/random.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
name: This is a random YAML file to ensure the generator doesn't error with non-kube YAML files.