diff --git a/pkg/crd/schema.go b/pkg/crd/schema.go index 2eaadb675..d2955c510 100644 --- a/pkg/crd/schema.go +++ b/pkg/crd/schema.go @@ -254,7 +254,7 @@ func localNamedToSchema(ctx *schemaContext, ident *ast.Ident) *apiext.JSONSchema } // NB(directxman12): if there are dot imports, this might be an external reference, // so use typechecking info to get the actual object - typeNameInfo := typeInfo.(*types.Named).Obj() + typeNameInfo := typeInfo.(interface{ Obj() *types.TypeName }).Obj() pkg := typeNameInfo.Pkg() pkgPath := loader.NonVendorPath(pkg.Path()) if pkg == ctx.pkg.Types { diff --git a/pkg/crd/testdata/cronjob_types.go b/pkg/crd/testdata/cronjob_types.go index d43622516..2f7047645 100644 --- a/pkg/crd/testdata/cronjob_types.go +++ b/pkg/crd/testdata/cronjob_types.go @@ -327,6 +327,9 @@ type CronJobSpec struct { HostsAlias Hosts `json:"hostsAlias,omitempty"` + // This tests that string alias is handled correctly. + StringAlias StringAlias `json:"stringAlias,omitempty"` + // This tests string slice validation. // +kubebuilder:validation:MinItems=2 // +kubebuilder:validation:MaxItems=2 @@ -351,6 +354,8 @@ type CronJobSpec struct { Protocol corev1.Protocol `json:"protocol,omitempty" protobuf:"bytes,4,opt,name=protocol,casttype=Protocol"` } +type StringAlias = string + type ContainsNestedMap struct { InnerMap map[string]string `json:"innerMap,omitempty"` } diff --git a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml index 189f407a7..44bc08fee 100644 --- a/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml +++ b/pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml @@ -8972,6 +8972,9 @@ spec: time for any reason. Missed jobs executions will be counted as failed ones. format: int64 type: integer + stringAlias: + description: This tests that string alias is handled correctly. + type: string stringPair: description: This tests string slice validation. items: