Update/verify client generator in scripts

This commit is contained in:
Wojciech Tyczynski 2015-12-28 14:13:57 +01:00
parent 5cf0659502
commit 9d912e843b
5 changed files with 10 additions and 16 deletions

View File

@ -37,10 +37,12 @@ import (
// Default returns a defaulted GeneratorArgs. You may change the defaults // Default returns a defaulted GeneratorArgs. You may change the defaults
// before calling AddFlags. // before calling AddFlags.
func Default() *GeneratorArgs { func Default() *GeneratorArgs {
return &GeneratorArgs{ generatorArgs := &GeneratorArgs{
OutputBase: DefaultSourceTree(), OutputBase: DefaultSourceTree(),
GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt"), GoHeaderFilePath: filepath.Join(DefaultSourceTree(), "k8s.io/kubernetes/hack/boilerplate/boilerplate.go.txt"),
} }
generatorArgs.AddFlags(pflag.CommandLine)
return generatorArgs
} }
// GeneratorArgs has arguments common to most generators. // GeneratorArgs has arguments common to most generators.
@ -105,7 +107,6 @@ func DefaultSourceTree() string {
// If you don't need any non-default behavior, use as: // If you don't need any non-default behavior, use as:
// args.Default().Execute(...) // args.Default().Execute(...)
func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error { func (g *GeneratorArgs) Execute(nameSystems namer.NameSystems, defaultSystem string, pkgs func(*generator.Context, *GeneratorArgs) generator.Packages) error {
g.AddFlags(pflag.CommandLine)
pflag.Parse() pflag.Parse()
b, err := g.NewBuilder() b, err := g.NewBuilder()

View File

@ -90,23 +90,11 @@ func (c *testTypes) Delete(name string, options *api.DeleteOptions) error {
// DeleteCollection deletes a collection of objects. // DeleteCollection deletes a collection of objects.
func (c *testTypes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error { func (c *testTypes) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
if options == nil {
return c.client.Delete().
NamespaceIfScoped(c.ns, len(c.ns) > 0).
Resource("testTypes").
VersionedParams(&listOptions, api.Scheme).
Do().
Error()
}
body, err := api.Scheme.EncodeToVersion(options, c.client.APIVersion().String())
if err != nil {
return err
}
return c.client.Delete(). return c.client.Delete().
NamespaceIfScoped(c.ns, len(c.ns) > 0). NamespaceIfScoped(c.ns, len(c.ns) > 0).
Resource("testTypes"). Resource("testTypes").
VersionedParams(&listOptions, api.Scheme). VersionedParams(&listOptions, api.Scheme).
Body(body). Body(options).
Do(). Do().
Error() Error()
} }

View File

@ -24,12 +24,15 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env kube::golang::setup_env
setgen=$(kube::util::find-binary "set-gen") setgen=$(kube::util::find-binary "set-gen")
clientgen=$(kube::util::find-binary "client-gen")
# Please do not add any logic to this shell script. Add logic to the go code # Please do not add any logic to this shell script. Add logic to the go code
# that generates the set-gen program. # that generates the set-gen program.
# #
# This can be called with one flag, --verify-only, so it works for both the # This can be called with one flag, --verify-only, so it works for both the
# update- and verify- scripts. # update- and verify- scripts.
${clientgen} "$@"
${clientgen} -t "$@"
${setgen} "$@" ${setgen} "$@"
# You may add additional calls of code generators like set-gen below. # You may add additional calls of code generators like set-gen above.

View File

@ -25,6 +25,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env kube::golang::setup_env
"${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/client-gen
"${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/set-gen "${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/set-gen
"${KUBE_ROOT}/hack/after-build/run-codegen.sh" "$@" "${KUBE_ROOT}/hack/after-build/run-codegen.sh" "$@"

View File

@ -25,6 +25,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
kube::golang::setup_env kube::golang::setup_env
"${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/client-gen
"${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/set-gen "${KUBE_ROOT}/hack/build-go.sh" cmd/libs/go2idl/set-gen
"${KUBE_ROOT}/hack/after-build/run-codegen.sh" --verify-only "${KUBE_ROOT}/hack/after-build/run-codegen.sh" --verify-only