Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix processing & linking of alias types #6

Merged
merged 2 commits into from
Jan 12, 2021
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
3 changes: 3 additions & 0 deletions processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,20 +377,23 @@ func (p *processor) loadType(pkg *loader.Package, t gotypes.Type, depth int) *ty
if typeDef.UnderlyingType != nil && typeDef.UnderlyingType.Kind == types.BasicKind {
typeDef.Package = ""
}
return typeDef

case *gotypes.Slice:
typeDef.Kind = types.SliceKind
typeDef.UnderlyingType = p.loadType(pkg, x.Elem(), depth+1)
if typeDef.UnderlyingType != nil && typeDef.UnderlyingType.Kind == types.BasicKind {
typeDef.Package = ""
}
return typeDef

case *gotypes.Array:
typeDef.Kind = types.ArrayKind
typeDef.UnderlyingType = p.loadType(pkg, x.Elem(), depth+1)
if typeDef.UnderlyingType != nil && typeDef.UnderlyingType.Kind == types.BasicKind {
typeDef.Package = ""
}
return typeDef

case *gotypes.Map:
typeDef.Kind = types.MapKind
Expand Down
5 changes: 5 additions & 0 deletions test/api/v1/guestbook_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type GuestbookSpec struct {
Entries []GuestbookEntry `json:"entries,omitempty"`
// Selector selects something
Selector metav1.LabelSelector `json:"selector,omitempty"`
// Headers contains a list of header items to include in the page
Headers []GuestbookHeader `json:"headers,omitempty"`
}

// GuestbookEntry defines an entry in a guest book.
Expand All @@ -46,6 +48,9 @@ type GuestbookStatus struct {
Status string `json:"status"`
}

// GuestbookHeaders are strings to include at the top of a page.
type GuestbookHeader string

// +kubebuilder:object:root=true

// Guestbook is the Schema for the guestbooks API.
Expand Down
5 changes: 5 additions & 0 deletions test/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion test/expected.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Guestbook is the Schema for the guestbooks API.
[id="{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookentry"]
==== GuestbookEntry


GuestbookEntry defines an entry in a guest book.

.Appears In:
****
Expand All @@ -59,6 +59,18 @@ Guestbook is the Schema for the guestbooks API.
|===


[id="{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookheader"]
==== GuestbookHeader (string)



.Appears In:
****
- xref:{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookspec[$$GuestbookSpec$$]
****



[id="{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbooklist"]
==== GuestbookList

Expand Down Expand Up @@ -93,6 +105,7 @@ GuestbookSpec defines the desired state of Guestbook.
| *`page`* __integer__ | Page indicates the page number
| *`entries`* __xref:{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookentry[$$GuestbookEntry$$] array__ | Entries contain guest book entries for the page
| *`selector`* __link:https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.15/#labelselector-v1-meta[$$LabelSelector$$]__ | Selector selects something
| *`headers`* __xref:{anchor_prefix}-github-com-elastic-crd-ref-docs-api-v1-guestbookheader[$$GuestbookHeader$$] array__ | Headers contains a list of header items to include in the page
|===


Expand Down
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (t *Type) IsBasic() bool {
switch t.Kind {
case BasicKind:
return true
case AliasKind, SliceKind, ArrayKind, PointerKind:
case SliceKind, ArrayKind, PointerKind:
return t.UnderlyingType != nil && t.UnderlyingType.IsBasic()
case MapKind:
return t.KeyType != nil && t.KeyType.IsBasic() && t.ValueType != nil && t.ValueType.IsBasic()
Expand Down