mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-05-01 00:00:03 +08:00
Merge pull request #62412 from bhcleek/go1.10
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. generated code should pass go vet for go1.10 **What this PR does / why we need it**: Update code generator and the code it generates to pass `go vet`. go1.10 runs `go vet` whenever `go test` is run. Because of this, generated code for CRDs needs to pass `go vet`. **Release note**: ```release-note Code generated for CRDs now passes `go vet`. ``` Kubernetes-commit: 5dde701b876d1d0915314c3ed146e986c4327f7e
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"ImportPath": "k8s.io/code-generator",
|
||||
"GoVersion": "go1.9",
|
||||
"GodepVersion": "v79",
|
||||
"GodepVersion": "v80",
|
||||
"Packages": [
|
||||
"./..."
|
||||
],
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example
|
||||
// +groupName=example.apiserver.code-generator.k8s.io
|
||||
package v1
|
||||
|
||||
+1
@@ -15,6 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=example.test.apiserver.code-generator.k8s.io
|
||||
// +k8s:conversion-gen=k8s.io/code-generator/_examples/apiserver/apis/example2
|
||||
// +groupGoName=SecondExample
|
||||
|
||||
Generated
Vendored
+5
-4
@@ -43,9 +43,10 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
}
|
||||
|
||||
fakePtr := testing.Fake{}
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
fakePtr.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
cs := &Clientset{}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
@@ -55,7 +56,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
|
||||
Generated
Vendored
+5
-4
@@ -43,9 +43,10 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
}
|
||||
|
||||
fakePtr := testing.Fake{}
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
fakePtr.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
cs := &Clientset{}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
@@ -55,7 +56,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
|
||||
+1
@@ -15,5 +15,6 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=example.crd.code-generator.k8s.io
|
||||
package v1
|
||||
|
||||
Generated
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
return nil
|
||||
}
|
||||
+1
@@ -15,6 +15,7 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
// +k8s:deepcopy-gen=package
|
||||
// +k8s:defaulter-gen=TypeMeta
|
||||
// +groupName=example.test.crd.code-generator.k8s.io
|
||||
// +groupGoName=SecondExample
|
||||
package v1
|
||||
|
||||
Generated
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
// +build !ignore_autogenerated
|
||||
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by defaulter-gen. DO NOT EDIT.
|
||||
|
||||
package v1
|
||||
|
||||
import (
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// RegisterDefaults adds defaulters functions to the given scheme.
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
return nil
|
||||
}
|
||||
Generated
Vendored
+5
-4
@@ -43,9 +43,10 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
}
|
||||
|
||||
fakePtr := testing.Fake{}
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
fakePtr.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
cs := &Clientset{}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
@@ -55,7 +56,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
|
||||
+11
-11
@@ -45,12 +45,12 @@ func TestGVPackageFlag(t *testing.T) {
|
||||
args: []string{"foo/bar/v1", "foo/bar/v2", "foo/bar/", "foo/v1"},
|
||||
expectedGroups: []types.GroupVersions{
|
||||
{PackageName: "bar", Group: types.Group("bar"), Versions: []types.PackageVersion{
|
||||
{"v1", "foo/bar/v1"},
|
||||
{"v2", "foo/bar/v2"},
|
||||
{"", "foo/bar"},
|
||||
{Version: "v1", Package: "foo/bar/v1"},
|
||||
{Version: "v2", Package: "foo/bar/v2"},
|
||||
{Version: "", Package: "foo/bar"},
|
||||
}},
|
||||
{PackageName: "foo", Group: types.Group("foo"), Versions: []types.PackageVersion{
|
||||
{"v1", "foo/v1"},
|
||||
{Version: "v1", Package: "foo/v1"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -59,12 +59,12 @@ func TestGVPackageFlag(t *testing.T) {
|
||||
def: []string{"foo/bar/v1alpha1", "foo/v1"},
|
||||
expectedGroups: []types.GroupVersions{
|
||||
{PackageName: "bar", Group: types.Group("bar"), Versions: []types.PackageVersion{
|
||||
{"v1", "foo/bar/v1"},
|
||||
{"v2", "foo/bar/v2"},
|
||||
{"", "foo/bar"},
|
||||
{Version: "v1", Package: "foo/bar/v1"},
|
||||
{Version: "v2", Package: "foo/bar/v2"},
|
||||
{Version: "", Package: "foo/bar"},
|
||||
}},
|
||||
{PackageName: "foo", Group: types.Group("foo"), Versions: []types.PackageVersion{
|
||||
{"v1", "foo/v1"},
|
||||
{Version: "v1", Package: "foo/v1"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -72,8 +72,8 @@ func TestGVPackageFlag(t *testing.T) {
|
||||
args: []string{"api/v1", "api"},
|
||||
expectedGroups: []types.GroupVersions{
|
||||
{PackageName: "core", Group: types.Group("api"), Versions: []types.PackageVersion{
|
||||
{"v1", "core/v1"},
|
||||
{"", "core"},
|
||||
{Version: "v1", Package: "core/v1"},
|
||||
{Version: "", Package: "core"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
@@ -82,7 +82,7 @@ func TestGVPackageFlag(t *testing.T) {
|
||||
importBasePath: "k8s.io/api",
|
||||
expectedGroups: []types.GroupVersions{
|
||||
{PackageName: "foo", Group: types.Group("foo"), Versions: []types.PackageVersion{
|
||||
{"v1", "k8s.io/api/foo/v1"},
|
||||
{Version: "v1", Package: "k8s.io/api/foo/v1"},
|
||||
}},
|
||||
},
|
||||
},
|
||||
|
||||
Generated
Vendored
+6
-5
@@ -63,7 +63,7 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
|
||||
groupClientPackage := filepath.Join(g.fakeClientsetPackage, "typed", group.PackageName, version.NonEmpty())
|
||||
fakeGroupClientPackage := filepath.Join(groupClientPackage, "fake")
|
||||
|
||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{group.Group, version.Version}])
|
||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), groupClientPackage)))
|
||||
imports = append(imports, strings.ToLower(fmt.Sprintf("fake%s%s \"%s\"", groupAlias, version.NonEmpty(), fakeGroupClientPackage)))
|
||||
}
|
||||
@@ -125,9 +125,10 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
}
|
||||
}
|
||||
|
||||
fakePtr := testing.Fake{}
|
||||
fakePtr.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
fakePtr.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
cs := &Clientset{}
|
||||
cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
|
||||
cs.AddReactor("*", "*", testing.ObjectReaction(o))
|
||||
cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
|
||||
gvr := action.GetResource()
|
||||
ns := action.GetNamespace()
|
||||
watch, err := o.Watch(gvr, ns)
|
||||
@@ -137,7 +138,7 @@ func NewSimpleClientset(objects ...runtime.Object) *Clientset {
|
||||
return true, watch, nil
|
||||
})
|
||||
|
||||
return &Clientset{fakePtr, &fakediscovery.FakeDiscovery{Fake: &fakePtr}}
|
||||
return cs
|
||||
}
|
||||
|
||||
// Clientset implements clientset.Interface. Meant to be embedded into a
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -59,7 +59,7 @@ func (g *genClientset) Imports(c *generator.Context) (imports []string) {
|
||||
for _, group := range g.groups {
|
||||
for _, version := range group.Versions {
|
||||
typedClientPath := filepath.Join(g.clientsetPackage, "typed", group.PackageName, version.NonEmpty())
|
||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{group.Group, version.Version}])
|
||||
groupAlias := strings.ToLower(g.groupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
||||
imports = append(imports, strings.ToLower(fmt.Sprintf("%s%s \"%s\"", groupAlias, version.NonEmpty(), typedClientPath)))
|
||||
}
|
||||
}
|
||||
|
||||
Generated
Vendored
+1
-1
@@ -62,7 +62,7 @@ func (g *GenScheme) Imports(c *generator.Context) (imports []string) {
|
||||
for _, group := range g.Groups {
|
||||
for _, version := range group.Versions {
|
||||
packagePath := g.InputPackages[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}]
|
||||
groupAlias := strings.ToLower(g.GroupGoNames[clientgentypes.GroupVersion{group.Group, version.Version}])
|
||||
groupAlias := strings.ToLower(g.GroupGoNames[clientgentypes.GroupVersion{Group: group.Group, Version: version.Version}])
|
||||
if g.CreateRegistry {
|
||||
// import the install package for internal clientsets instead of the type package with register.go
|
||||
if version.Version != "" {
|
||||
|
||||
Reference in New Issue
Block a user