diff --git a/tests/apichecks/crds_test.go b/tests/apichecks/crds_test.go index 19ceb37599..67158bdc54 100644 --- a/tests/apichecks/crds_test.go +++ b/tests/apichecks/crds_test.go @@ -372,3 +372,21 @@ func TestCRDCamelCase(t *testing.T) { t.Fatal(errs) } } + +func TestCRDShortNames(t *testing.T) { + crds, err := crdloader.LoadAllCRDs() + if err != nil { + t.Fatalf("error loading CRDs: %v", err) + } + + var errs []string + for _, crd := range crds { + if len(crd.Spec.Names.ShortNames) == 0 { + errs = append(errs, fmt.Sprintf("[shortnames] crd=%s: missing shortnames", crd.Name)) + } + } + + sort.Strings(errs) + want := strings.Join(errs, "\n") + test.CompareGoldenFile(t, "testdata/exceptions/shortnames.txt", want) +} diff --git a/tests/apichecks/testdata/exceptions/shortnames.txt b/tests/apichecks/testdata/exceptions/shortnames.txt new file mode 100644 index 0000000000..2c27fa2457 --- /dev/null +++ b/tests/apichecks/testdata/exceptions/shortnames.txt @@ -0,0 +1,16 @@ +[shortnames] crd=bigqueryanalyticshublistings.bigqueryanalyticshub.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=bigquerydatatransferconfigs.bigquerydatatransfer.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=cloudbuildworkerpools.cloudbuild.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=configconnectorcontexts.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=configconnectors.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=controllerreconcilers.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=controllerresources.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=firestoredatabases.firestore.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=mutatingwebhookconfigurationcustomizations.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=namespacedcontrollerreconcilers.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=namespacedcontrollerresources.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=networkconnectivityserviceconnectionpolicies.networkconnectivity.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=privilegedaccessmanagerentitlements.privilegedaccessmanager.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=redisclusters.redis.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=validatingwebhookconfigurationcustomizations.customize.core.cnrm.cloud.google.com: missing shortnames +[shortnames] crd=workstationclusters.workstations.cnrm.cloud.google.com: missing shortnames \ No newline at end of file