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
6 changes: 6 additions & 0 deletions pkg/crd/testdata/cronjob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ type CronJobSpec struct {
// +kubebuilder:validation:XValidation:rule="self.size() % 2 == 0",message="must have even length"
// +kubebuilder:validation:XValidation:rule="true"
StringWithEvenLength string `json:"stringWithEvenLength,omitempty"`

// Checks that fixed-length arrays work
Array [3]int `json:"array,omitempty"`

// Checks that arrays work when the type contains a composite literal
ArrayUsingCompositeLiteral [len(struct{ X [3]int }{}.X)]string `json:"arrayUsingCompositeLiteral,omitempty"`
}

type ContainsNestedMap struct {
Expand Down
11 changes: 11 additions & 0 deletions pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ spec:
spec:
description: CronJobSpec defines the desired state of CronJob
properties:
array:
description: Checks that fixed-length arrays work
items:
type: integer
type: array
arrayUsingCompositeLiteral:
description: Checks that arrays work when the type contains a composite
literal
items:
type: string
type: array
associativeList:
description: This tests that associative lists work.
items:
Expand Down
11 changes: 8 additions & 3 deletions pkg/loader/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,14 @@ func (c *referenceCollector) Visit(node ast.Node) ast.Visitor {
// local reference or dot-import, ignore
return nil
case *ast.SelectorExpr:
pkgName := typedNode.X.(*ast.Ident).Name
c.refs.external(pkgName)
return nil
switch x := typedNode.X.(type) {
case *ast.Ident:
pkgName := x.Name
c.refs.external(pkgName)
return nil
default:
return c
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WDYT about adding a test to ensure the scenario raised?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, I will add a test.

default:
return c
}
Expand Down