Skip to content

Commit

Permalink
Merge pull request #73 from pwittrock/master
Browse files Browse the repository at this point in the history
Stop generating clients for non-resource types
  • Loading branch information
Phillip Wittrock authored Jun 21, 2017
2 parents 1a90a57 + d2f8892 commit aa63f79
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
16 changes: 15 additions & 1 deletion cmd/apiregister-gen/generators/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ type APIGroup struct {
type Struct struct {
// Name is the name of the type
Name string
// IsResource
IsResource bool
// Fields is the list of fields appearing in the struct
Fields []*Field
}
Expand Down Expand Up @@ -481,6 +483,12 @@ func (b *APIsBuilder) GetResourceTag(c *types.Type) string {
return resource
}

func (b *APIsBuilder) IsResource(c *types.Type) bool {
comments := Comments(c.CommentLines)
resource := comments.GetTag("resource", ":")
return len(resource) > 0
}

func (b *APIsBuilder) GetControllerTag(c *types.Type) string {
comments := Comments(c.CommentLines)
resource := comments.GetTag("controller", ":")
Expand Down Expand Up @@ -574,6 +582,11 @@ func (b *APIsBuilder) ParseStructs(apigroup *APIGroup) {

// Generate the struct and append to the list
result, additionalTypes := apigroup.DoType(next)

// This is a resource, so generate the client
if b.IsResource(next) {
result.IsResource = true
}
apigroup.Structs = append(apigroup.Structs, result)

// Add the newly discovered subtypes
Expand All @@ -584,7 +597,8 @@ func (b *APIsBuilder) ParseStructs(apigroup *APIGroup) {
func (apigroup *APIGroup) DoType(t *types.Type) (*Struct, []*types.Type) {
remaining := []*types.Type{}
s := &Struct{
Name: t.Name.Name,
Name: t.Name.Name,
IsResource: false,
}
for _, member := range t.Members {
memberGroup := GetGroup(member.Type)
Expand Down
2 changes: 1 addition & 1 deletion cmd/apiregister-gen/generators/unversioned_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func Resource(resource string) schema.GroupResource {
}
{{ range $s := .Structs -}}
// +genclient=true
{{ if $s.IsResource }}// +genclient=true{{end}}
type {{ $s.Name }} struct {
{{ range $f := $s.Fields -}}
Expand Down
8 changes: 1 addition & 7 deletions cmd/apiserver-builder-release/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,7 @@ func BuildVendor(tooldir string) string {
cmd.Dir = pkgDir
RunCmd(cmd, vendordir)

cmd = exec.Command("go", "test", filepath.Join(
"github.com", "kubernetes-incubator", "test", "pkg", "apis", "misk", "v1beta1"))
cmd.Dir = pkgDir
RunCmd(cmd, vendordir)

cmd = exec.Command("go", "test", filepath.Join(
"github.com", "kubernetes-incubator", "test", "pkg", "controller", "student"))
cmd = exec.Command("go", "test", filepath.Join("pkg", "..."))
cmd.Dir = pkgDir
RunCmd(cmd, vendordir)
}
Expand Down
3 changes: 3 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import:
- package: github.com/markbates/inflect
version: 6cacb66d100482ef7cc366289ccb156020e57e76
- package: k8s.io/apimachinery
version: cff8db64dd5b6fb0166dc2cf36e39c7ff4fe48c8
- package: k8s.io/apiserver
version: 2e70bac0745c7f8e506f7f3e432d040c55d5718a
- package: k8s.io/client-go
version: 36b51953e6efc7779fe27c14258d78573de4e0de
- package: k8s.io/gengo
- package: github.com/onsi/ginkgo
version: ~1.3.1
Expand Down

0 comments on commit aa63f79

Please sign in to comment.