From dc4e924a588ad4b0f0b751e78b06e7232b1e89e9 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Sat, 17 Jun 2017 09:17:32 -0700 Subject: [PATCH 1/2] pin api libs --- glide.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/glide.yaml b/glide.yaml index e2aebea78b..573748e2da 100644 --- a/glide.yaml +++ b/glide.yaml @@ -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 From d2f889200cc65d11b6758df9dc786042baa28912 Mon Sep 17 00:00:00 2001 From: Phillip Wittrock Date: Tue, 20 Jun 2017 17:41:38 -0700 Subject: [PATCH 2/2] Fixes #62 Don't generate clients for non-resource types. --- cmd/apiregister-gen/generators/parser.go | 16 +++++++++++++++- .../generators/unversioned_generator.go | 2 +- cmd/apiserver-builder-release/main.go | 8 +------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/cmd/apiregister-gen/generators/parser.go b/cmd/apiregister-gen/generators/parser.go index 53b28efa35..9840b19518 100644 --- a/cmd/apiregister-gen/generators/parser.go +++ b/cmd/apiregister-gen/generators/parser.go @@ -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 } @@ -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", ":") @@ -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 @@ -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) diff --git a/cmd/apiregister-gen/generators/unversioned_generator.go b/cmd/apiregister-gen/generators/unversioned_generator.go index e8ad40a879..1653b99d6d 100644 --- a/cmd/apiregister-gen/generators/unversioned_generator.go +++ b/cmd/apiregister-gen/generators/unversioned_generator.go @@ -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 -}} diff --git a/cmd/apiserver-builder-release/main.go b/cmd/apiserver-builder-release/main.go index 48d8cc747f..f8d298f194 100644 --- a/cmd/apiserver-builder-release/main.go +++ b/cmd/apiserver-builder-release/main.go @@ -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) }