mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 22:17:14 +00:00
Use protobuf for core clients
Signed-off-by: Monis Khan <mok@microsoft.com>
This commit is contained in:
parent
fe1eda0649
commit
c2ae465355
@ -645,6 +645,7 @@ function codegen::clients() {
|
|||||||
--input-base="k8s.io/api" \
|
--input-base="k8s.io/api" \
|
||||||
--plural-exceptions "${PLURAL_EXCEPTIONS}" \
|
--plural-exceptions "${PLURAL_EXCEPTIONS}" \
|
||||||
--apply-configuration-package "${APPLYCONFIG_PKG}" \
|
--apply-configuration-package "${APPLYCONFIG_PKG}" \
|
||||||
|
--prefers-protobuf \
|
||||||
$(printf -- " --input %s" "${gv_dirs[@]}") \
|
$(printf -- " --input %s" "${gv_dirs[@]}") \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
|
@ -52,4 +52,5 @@ kube::codegen::gen_client \
|
|||||||
--output-pkg "${THIS_PKG}/pkg/client" \
|
--output-pkg "${THIS_PKG}/pkg/client" \
|
||||||
--versioned-name "clientset" \
|
--versioned-name "clientset" \
|
||||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||||
|
--prefers-protobuf \
|
||||||
"${SCRIPT_ROOT}/pkg/apis"
|
"${SCRIPT_ROOT}/pkg/apis"
|
||||||
|
@ -51,6 +51,8 @@ type Client[T objectWithMeta] struct {
|
|||||||
namespace string // "" for non-namespaced clients
|
namespace string // "" for non-namespaced clients
|
||||||
newObject func() T
|
newObject func() T
|
||||||
parameterCodec runtime.ParameterCodec
|
parameterCodec runtime.ParameterCodec
|
||||||
|
|
||||||
|
prefersProtobuf bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientWithList represents a client with support for lists.
|
// ClientWithList represents a client with support for lists.
|
||||||
@ -82,26 +84,37 @@ type alsoApplier[T objectWithMeta, C namedObject] struct {
|
|||||||
client *Client[T]
|
client *Client[T]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Option[T objectWithMeta] func(*Client[T])
|
||||||
|
|
||||||
|
func PrefersProtobuf[T objectWithMeta]() Option[T] {
|
||||||
|
return func(c *Client[T]) { c.prefersProtobuf = true }
|
||||||
|
}
|
||||||
|
|
||||||
// NewClient constructs a client, namespaced or not, with no support for lists or apply.
|
// NewClient constructs a client, namespaced or not, with no support for lists or apply.
|
||||||
// Non-namespaced clients are constructed by passing an empty namespace ("").
|
// Non-namespaced clients are constructed by passing an empty namespace ("").
|
||||||
func NewClient[T objectWithMeta](
|
func NewClient[T objectWithMeta](
|
||||||
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
||||||
|
options ...Option[T],
|
||||||
) *Client[T] {
|
) *Client[T] {
|
||||||
return &Client[T]{
|
c := &Client[T]{
|
||||||
resource: resource,
|
resource: resource,
|
||||||
client: client,
|
client: client,
|
||||||
parameterCodec: parameterCodec,
|
parameterCodec: parameterCodec,
|
||||||
namespace: namespace,
|
namespace: namespace,
|
||||||
newObject: emptyObjectCreator,
|
newObject: emptyObjectCreator,
|
||||||
}
|
}
|
||||||
|
for _, option := range options {
|
||||||
|
option(c)
|
||||||
|
}
|
||||||
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClientWithList constructs a namespaced client with support for lists.
|
// NewClientWithList constructs a namespaced client with support for lists.
|
||||||
func NewClientWithList[T objectWithMeta, L runtime.Object](
|
func NewClientWithList[T objectWithMeta, L runtime.Object](
|
||||||
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
||||||
emptyListCreator func() L,
|
emptyListCreator func() L, options ...Option[T],
|
||||||
) *ClientWithList[T, L] {
|
) *ClientWithList[T, L] {
|
||||||
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator)
|
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator, options...)
|
||||||
return &ClientWithList[T, L]{
|
return &ClientWithList[T, L]{
|
||||||
typeClient,
|
typeClient,
|
||||||
alsoLister[T, L]{typeClient, emptyListCreator},
|
alsoLister[T, L]{typeClient, emptyListCreator},
|
||||||
@ -111,8 +124,9 @@ func NewClientWithList[T objectWithMeta, L runtime.Object](
|
|||||||
// NewClientWithApply constructs a namespaced client with support for apply declarative configurations.
|
// NewClientWithApply constructs a namespaced client with support for apply declarative configurations.
|
||||||
func NewClientWithApply[T objectWithMeta, C namedObject](
|
func NewClientWithApply[T objectWithMeta, C namedObject](
|
||||||
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
||||||
|
options ...Option[T],
|
||||||
) *ClientWithApply[T, C] {
|
) *ClientWithApply[T, C] {
|
||||||
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator)
|
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator, options...)
|
||||||
return &ClientWithApply[T, C]{
|
return &ClientWithApply[T, C]{
|
||||||
typeClient,
|
typeClient,
|
||||||
alsoApplier[T, C]{typeClient},
|
alsoApplier[T, C]{typeClient},
|
||||||
@ -122,9 +136,9 @@ func NewClientWithApply[T objectWithMeta, C namedObject](
|
|||||||
// NewClientWithListAndApply constructs a client with support for lists and applying declarative configurations.
|
// NewClientWithListAndApply constructs a client with support for lists and applying declarative configurations.
|
||||||
func NewClientWithListAndApply[T objectWithMeta, L runtime.Object, C namedObject](
|
func NewClientWithListAndApply[T objectWithMeta, L runtime.Object, C namedObject](
|
||||||
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
resource string, client rest.Interface, parameterCodec runtime.ParameterCodec, namespace string, emptyObjectCreator func() T,
|
||||||
emptyListCreator func() L,
|
emptyListCreator func() L, options ...Option[T],
|
||||||
) *ClientWithListAndApply[T, L, C] {
|
) *ClientWithListAndApply[T, L, C] {
|
||||||
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator)
|
typeClient := NewClient[T](resource, client, parameterCodec, namespace, emptyObjectCreator, options...)
|
||||||
return &ClientWithListAndApply[T, L, C]{
|
return &ClientWithListAndApply[T, L, C]{
|
||||||
typeClient,
|
typeClient,
|
||||||
alsoLister[T, L]{typeClient, emptyListCreator},
|
alsoLister[T, L]{typeClient, emptyListCreator},
|
||||||
@ -146,6 +160,7 @@ func (c *Client[T]) GetNamespace() string {
|
|||||||
func (c *Client[T]) Get(ctx context.Context, name string, options metav1.GetOptions) (T, error) {
|
func (c *Client[T]) Get(ctx context.Context, name string, options metav1.GetOptions) (T, error) {
|
||||||
result := c.newObject()
|
result := c.newObject()
|
||||||
err := c.client.Get().
|
err := c.client.Get().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -181,6 +196,7 @@ func (l *alsoLister[T, L]) list(ctx context.Context, opts metav1.ListOptions) (L
|
|||||||
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
|
||||||
}
|
}
|
||||||
err := l.client.client.Get().
|
err := l.client.client.Get().
|
||||||
|
UseProtobufAsDefaultIfPreferred(l.client.prefersProtobuf).
|
||||||
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
||||||
Resource(l.client.resource).
|
Resource(l.client.resource).
|
||||||
VersionedParams(&opts, l.client.parameterCodec).
|
VersionedParams(&opts, l.client.parameterCodec).
|
||||||
@ -198,6 +214,7 @@ func (l *alsoLister[T, L]) watchList(ctx context.Context, opts metav1.ListOption
|
|||||||
}
|
}
|
||||||
result = l.newList()
|
result = l.newList()
|
||||||
err = l.client.client.Get().
|
err = l.client.client.Get().
|
||||||
|
UseProtobufAsDefaultIfPreferred(l.client.prefersProtobuf).
|
||||||
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
||||||
Resource(l.client.resource).
|
Resource(l.client.resource).
|
||||||
VersionedParams(&opts, l.client.parameterCodec).
|
VersionedParams(&opts, l.client.parameterCodec).
|
||||||
@ -215,6 +232,7 @@ func (c *Client[T]) Watch(ctx context.Context, opts metav1.ListOptions) (watch.I
|
|||||||
}
|
}
|
||||||
opts.Watch = true
|
opts.Watch = true
|
||||||
return c.client.Get().
|
return c.client.Get().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
VersionedParams(&opts, c.parameterCodec).
|
VersionedParams(&opts, c.parameterCodec).
|
||||||
@ -226,6 +244,7 @@ func (c *Client[T]) Watch(ctx context.Context, opts metav1.ListOptions) (watch.I
|
|||||||
func (c *Client[T]) Create(ctx context.Context, obj T, opts metav1.CreateOptions) (T, error) {
|
func (c *Client[T]) Create(ctx context.Context, obj T, opts metav1.CreateOptions) (T, error) {
|
||||||
result := c.newObject()
|
result := c.newObject()
|
||||||
err := c.client.Post().
|
err := c.client.Post().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
VersionedParams(&opts, c.parameterCodec).
|
VersionedParams(&opts, c.parameterCodec).
|
||||||
@ -239,6 +258,7 @@ func (c *Client[T]) Create(ctx context.Context, obj T, opts metav1.CreateOptions
|
|||||||
func (c *Client[T]) Update(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) {
|
func (c *Client[T]) Update(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) {
|
||||||
result := c.newObject()
|
result := c.newObject()
|
||||||
err := c.client.Put().
|
err := c.client.Put().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
Name(obj.GetName()).
|
Name(obj.GetName()).
|
||||||
@ -253,6 +273,7 @@ func (c *Client[T]) Update(ctx context.Context, obj T, opts metav1.UpdateOptions
|
|||||||
func (c *Client[T]) UpdateStatus(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) {
|
func (c *Client[T]) UpdateStatus(ctx context.Context, obj T, opts metav1.UpdateOptions) (T, error) {
|
||||||
result := c.newObject()
|
result := c.newObject()
|
||||||
err := c.client.Put().
|
err := c.client.Put().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
Name(obj.GetName()).
|
Name(obj.GetName()).
|
||||||
@ -267,6 +288,7 @@ func (c *Client[T]) UpdateStatus(ctx context.Context, obj T, opts metav1.UpdateO
|
|||||||
// Delete takes name of the resource and deletes it. Returns an error if one occurs.
|
// Delete takes name of the resource and deletes it. Returns an error if one occurs.
|
||||||
func (c *Client[T]) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
func (c *Client[T]) Delete(ctx context.Context, name string, opts metav1.DeleteOptions) error {
|
||||||
return c.client.Delete().
|
return c.client.Delete().
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -282,6 +304,7 @@ func (l *alsoLister[T, L]) DeleteCollection(ctx context.Context, opts metav1.Del
|
|||||||
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
|
||||||
}
|
}
|
||||||
return l.client.client.Delete().
|
return l.client.client.Delete().
|
||||||
|
UseProtobufAsDefaultIfPreferred(l.client.prefersProtobuf).
|
||||||
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
NamespaceIfScoped(l.client.namespace, l.client.namespace != "").
|
||||||
Resource(l.client.resource).
|
Resource(l.client.resource).
|
||||||
VersionedParams(&listOpts, l.client.parameterCodec).
|
VersionedParams(&listOpts, l.client.parameterCodec).
|
||||||
@ -295,6 +318,7 @@ func (l *alsoLister[T, L]) DeleteCollection(ctx context.Context, opts metav1.Del
|
|||||||
func (c *Client[T]) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error) {
|
func (c *Client[T]) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts metav1.PatchOptions, subresources ...string) (T, error) {
|
||||||
result := c.newObject()
|
result := c.newObject()
|
||||||
err := c.client.Patch(pt).
|
err := c.client.Patch(pt).
|
||||||
|
UseProtobufAsDefaultIfPreferred(c.prefersProtobuf).
|
||||||
NamespaceIfScoped(c.namespace, c.namespace != "").
|
NamespaceIfScoped(c.namespace, c.namespace != "").
|
||||||
Resource(c.resource).
|
Resource(c.resource).
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -321,6 +345,7 @@ func (a *alsoApplier[T, C]) Apply(ctx context.Context, obj C, opts metav1.ApplyO
|
|||||||
return *new(T), fmt.Errorf("obj.Name must be provided to Apply")
|
return *new(T), fmt.Errorf("obj.Name must be provided to Apply")
|
||||||
}
|
}
|
||||||
err = a.client.client.Patch(types.ApplyPatchType).
|
err = a.client.client.Patch(types.ApplyPatchType).
|
||||||
|
UseProtobufAsDefaultIfPreferred(a.client.prefersProtobuf).
|
||||||
NamespaceIfScoped(a.client.namespace, a.client.namespace != "").
|
NamespaceIfScoped(a.client.namespace, a.client.namespace != "").
|
||||||
Resource(a.client.resource).
|
Resource(a.client.resource).
|
||||||
Name(*obj.GetName()).
|
Name(*obj.GetName()).
|
||||||
@ -348,6 +373,7 @@ func (a *alsoApplier[T, C]) ApplyStatus(ctx context.Context, obj C, opts metav1.
|
|||||||
|
|
||||||
result := a.client.newObject()
|
result := a.client.newObject()
|
||||||
err = a.client.client.Patch(types.ApplyPatchType).
|
err = a.client.client.Patch(types.ApplyPatchType).
|
||||||
|
UseProtobufAsDefaultIfPreferred(a.client.prefersProtobuf).
|
||||||
NamespaceIfScoped(a.client.namespace, a.client.namespace != "").
|
NamespaceIfScoped(a.client.namespace, a.client.namespace != "").
|
||||||
Resource(a.client.resource).
|
Resource(a.client.resource).
|
||||||
Name(*obj.GetName()).
|
Name(*obj.GetName()).
|
||||||
|
@ -176,12 +176,7 @@ func NewRequest(c *RESTClient) *Request {
|
|||||||
contentTypeNotSet: contentTypeNotSet,
|
contentTypeNotSet: contentTypeNotSet,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
r.setAcceptHeader()
|
||||||
case len(c.content.AcceptContentTypes) > 0:
|
|
||||||
r.SetHeader("Accept", c.content.AcceptContentTypes)
|
|
||||||
case len(c.content.ContentType) > 0:
|
|
||||||
r.SetHeader("Accept", c.content.ContentType+", */*")
|
|
||||||
}
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,6 +190,31 @@ func NewRequestWithClient(base *url.URL, versionedAPIPath string, content Client
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *Request) UseProtobufAsDefaultIfPreferred(prefersProtobuf bool) *Request {
|
||||||
|
if prefersProtobuf {
|
||||||
|
return r.UseProtobufAsDefault()
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Request) UseProtobufAsDefault() *Request {
|
||||||
|
if r.contentTypeNotSet && len(r.contentConfig.AcceptContentTypes) == 0 {
|
||||||
|
r.contentConfig.AcceptContentTypes = "application/vnd.kubernetes.protobuf,application/json"
|
||||||
|
r.contentConfig.ContentType = "application/vnd.kubernetes.protobuf"
|
||||||
|
r.setAcceptHeader()
|
||||||
|
}
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *Request) setAcceptHeader() {
|
||||||
|
switch {
|
||||||
|
case len(r.contentConfig.AcceptContentTypes) > 0:
|
||||||
|
r.SetHeader("Accept", r.contentConfig.AcceptContentTypes)
|
||||||
|
case len(r.contentConfig.ContentType) > 0:
|
||||||
|
r.SetHeader("Accept", r.contentConfig.ContentType+", */*")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Verb sets the verb this request will use.
|
// Verb sets the verb this request will use.
|
||||||
func (r *Request) Verb(verb string) *Request {
|
func (r *Request) Verb(verb string) *Request {
|
||||||
r.verb = verb
|
r.verb = verb
|
||||||
|
@ -61,6 +61,9 @@ type Args struct {
|
|||||||
// If non-empty, Apply functions are generated for each type and reference the apply builders.
|
// If non-empty, Apply functions are generated for each type and reference the apply builders.
|
||||||
// If empty (""), Apply functions are not generated.
|
// If empty (""), Apply functions are not generated.
|
||||||
ApplyConfigurationPackage string
|
ApplyConfigurationPackage string
|
||||||
|
|
||||||
|
// PrefersProtobuf determines if the generated clientset uses protobuf for API requests.
|
||||||
|
PrefersProtobuf bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func New() *Args {
|
func New() *Args {
|
||||||
@ -99,6 +102,8 @@ func (args *Args) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
|||||||
"list of comma separated plural exception definitions in Type:PluralizedType form")
|
"list of comma separated plural exception definitions in Type:PluralizedType form")
|
||||||
fs.StringVar(&args.ApplyConfigurationPackage, "apply-configuration-package", args.ApplyConfigurationPackage,
|
fs.StringVar(&args.ApplyConfigurationPackage, "apply-configuration-package", args.ApplyConfigurationPackage,
|
||||||
"optional package of apply configurations, generated by applyconfiguration-gen, that are required to generate Apply functions for each type in the clientset. By default Apply functions are not generated.")
|
"optional package of apply configurations, generated by applyconfiguration-gen, that are required to generate Apply functions for each type in the clientset. By default Apply functions are not generated.")
|
||||||
|
fs.BoolVar(&args.PrefersProtobuf, "prefers-protobuf", args.PrefersProtobuf,
|
||||||
|
"when set, client-gen will generate a clientset that uses protobuf for API requests")
|
||||||
|
|
||||||
// support old flags
|
// support old flags
|
||||||
fs.SetNormalizeFunc(mapFlagName("clientset-path", "output-pkg", fs.GetNormalizeFunc()))
|
fs.SetNormalizeFunc(mapFlagName("clientset-path", "output-pkg", fs.GetNormalizeFunc()))
|
||||||
|
@ -128,7 +128,7 @@ func DefaultNameSystem() string {
|
|||||||
return "public"
|
return "public"
|
||||||
}
|
}
|
||||||
|
|
||||||
func targetForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetDir, clientsetPkg string, groupPkgName string, groupGoName string, apiPath string, inputPkg string, applyBuilderPkg string, boilerplate []byte) generator.Target {
|
func targetForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clientsetDir, clientsetPkg string, groupPkgName string, groupGoName string, apiPath string, inputPkg string, applyBuilderPkg string, boilerplate []byte, prefersProtobuf bool) generator.Target {
|
||||||
subdir := []string{"typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty())}
|
subdir := []string{"typed", strings.ToLower(groupPkgName), strings.ToLower(gv.Version.NonEmpty())}
|
||||||
gvDir := filepath.Join(clientsetDir, filepath.Join(subdir...))
|
gvDir := filepath.Join(clientsetDir, filepath.Join(subdir...))
|
||||||
gvPkg := path.Join(clientsetPkg, path.Join(subdir...))
|
gvPkg := path.Join(clientsetPkg, path.Join(subdir...))
|
||||||
@ -160,6 +160,7 @@ func targetForGroup(gv clientgentypes.GroupVersion, typeList []*types.Type, clie
|
|||||||
group: gv.Group.NonEmpty(),
|
group: gv.Group.NonEmpty(),
|
||||||
version: gv.Version.String(),
|
version: gv.Version.String(),
|
||||||
groupGoName: groupGoName,
|
groupGoName: groupGoName,
|
||||||
|
prefersProtobuf: prefersProtobuf,
|
||||||
typeToMatch: t,
|
typeToMatch: t,
|
||||||
imports: generator.NewImportTrackerForPackage(gvPkg),
|
imports: generator.NewImportTrackerForPackage(gvPkg),
|
||||||
})
|
})
|
||||||
@ -424,7 +425,7 @@ func GetTargets(context *generator.Context, args *args.Args) []generator.Target
|
|||||||
targetForGroup(
|
targetForGroup(
|
||||||
gv, orderer.OrderTypes(types), clientsetDir, clientsetPkg,
|
gv, orderer.OrderTypes(types), clientsetDir, clientsetPkg,
|
||||||
group.PackageName, groupGoNames[gv], args.ClientsetAPIPath,
|
group.PackageName, groupGoNames[gv], args.ClientsetAPIPath,
|
||||||
inputPath, args.ApplyConfigurationPackage, boilerplate))
|
inputPath, args.ApplyConfigurationPackage, boilerplate, args.PrefersProtobuf))
|
||||||
if args.FakeClient {
|
if args.FakeClient {
|
||||||
targetList = append(targetList,
|
targetList = append(targetList,
|
||||||
fake.TargetForGroup(gv, orderer.OrderTypes(types), clientsetDir, clientsetPkg, group.PackageName, groupGoNames[gv], inputPath, args.ApplyConfigurationPackage, boilerplate))
|
fake.TargetForGroup(gv, orderer.OrderTypes(types), clientsetDir, clientsetPkg, group.PackageName, groupGoNames[gv], inputPath, args.ApplyConfigurationPackage, boilerplate))
|
||||||
|
@ -41,6 +41,7 @@ type genClientForType struct {
|
|||||||
group string
|
group string
|
||||||
version string
|
version string
|
||||||
groupGoName string
|
groupGoName string
|
||||||
|
prefersProtobuf bool
|
||||||
typeToMatch *types.Type
|
typeToMatch *types.Type
|
||||||
imports namer.ImportTracker
|
imports namer.ImportTracker
|
||||||
}
|
}
|
||||||
@ -161,6 +162,7 @@ func (g *genClientForType) GenerateType(c *generator.Context, t *types.Type, w i
|
|||||||
"subresource": false,
|
"subresource": false,
|
||||||
"subresourcePath": "",
|
"subresourcePath": "",
|
||||||
"GroupGoName": g.groupGoName,
|
"GroupGoName": g.groupGoName,
|
||||||
|
"prefersProtobuf": g.prefersProtobuf,
|
||||||
"Version": namer.IC(g.version),
|
"Version": namer.IC(g.version),
|
||||||
"CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}),
|
"CreateOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "CreateOptions"}),
|
||||||
"DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}),
|
"DeleteOptions": c.Universe.Type(types.Name{Package: "k8s.io/apimachinery/pkg/apis/meta/v1", Name: "DeleteOptions"}),
|
||||||
@ -483,7 +485,9 @@ var newStruct = []string{
|
|||||||
c.RESTClient(),
|
c.RESTClient(),
|
||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
namespace,
|
namespace,
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} }),
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -496,7 +500,9 @@ var newStruct = []string{
|
|||||||
c.RESTClient(),
|
c.RESTClient(),
|
||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
namespace,
|
namespace,
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} }),
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -510,7 +516,9 @@ var newStruct = []string{
|
|||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
namespace,
|
namespace,
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
func() *$.resultType|raw$List { return &$.resultType|raw$List{} }),
|
func() *$.resultType|raw$List { return &$.resultType|raw$List{} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -524,7 +532,9 @@ var newStruct = []string{
|
|||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
namespace,
|
namespace,
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
func() *$.resultType|raw$List { return &$.resultType|raw$List{} }),
|
func() *$.resultType|raw$List { return &$.resultType|raw$List{} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -537,7 +547,9 @@ var newStruct = []string{
|
|||||||
c.RESTClient(),
|
c.RESTClient(),
|
||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
"",
|
"",
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} }),
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -550,7 +562,9 @@ var newStruct = []string{
|
|||||||
c.RESTClient(),
|
c.RESTClient(),
|
||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
"",
|
"",
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} }),
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -564,7 +578,9 @@ var newStruct = []string{
|
|||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
"",
|
"",
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
func() *$.resultType|raw$List { return &$.resultType|raw$List{} }),
|
func() *$.resultType|raw$List { return &$.resultType|raw$List{} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -578,7 +594,9 @@ var newStruct = []string{
|
|||||||
$.schemeParameterCodec|raw$,
|
$.schemeParameterCodec|raw$,
|
||||||
"",
|
"",
|
||||||
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
func() *$.resultType|raw$ { return &$.resultType|raw${} },
|
||||||
func() *$.resultType|raw$List { return &$.resultType|raw$List{} }),
|
func() *$.resultType|raw$List { return &$.resultType|raw$List{} },
|
||||||
|
$if .prefersProtobuf$gentype.PrefersProtobuf[*$.resultType|raw$](),$end$
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
@ -614,6 +632,7 @@ func (c *$.type|privatePlural$) list(ctx $.context|raw$, opts $.ListOptions|raw$
|
|||||||
}
|
}
|
||||||
result = &$.resultType|raw$List{}
|
result = &$.resultType|raw$List{}
|
||||||
err = c.GetClient().Get().
|
err = c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
||||||
@ -633,6 +652,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name
|
|||||||
}
|
}
|
||||||
result = &$.resultType|raw$List{}
|
result = &$.resultType|raw$List{}
|
||||||
err = c.GetClient().Get().
|
err = c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.type|private$Name).
|
Name($.type|private$Name).
|
||||||
@ -650,6 +670,7 @@ var getTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Get().
|
err = c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -665,6 +686,7 @@ var getSubresourceTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, options $.GetOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Get().
|
err = c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.type|private$Name).
|
Name($.type|private$Name).
|
||||||
@ -680,6 +702,7 @@ var deleteTemplate = `
|
|||||||
// $.verb$ takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
|
// $.verb$ takes name of the $.type|private$ and deletes it. Returns an error if one occurs.
|
||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, opts $.DeleteOptions|raw$) error {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, opts $.DeleteOptions|raw$) error {
|
||||||
return c.GetClient().Delete().
|
return c.GetClient().Delete().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -694,6 +717,7 @@ var createSubresourceTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Post().
|
err = c.GetClient().Post().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.type|private$Name).
|
Name($.type|private$Name).
|
||||||
@ -711,6 +735,7 @@ var createTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.CreateOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Post().
|
err = c.GetClient().Post().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
||||||
@ -726,6 +751,7 @@ var updateSubresourceTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name string, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Put().
|
err = c.GetClient().Put().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.type|private$Name).
|
Name($.type|private$Name).
|
||||||
@ -743,6 +769,7 @@ var updateTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$ *$.inputType|raw$, opts $.UpdateOptions|raw$) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Put().
|
err = c.GetClient().Put().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.inputType|private$.Name).
|
Name($.inputType|private$.Name).
|
||||||
@ -763,6 +790,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, opts $.ListOptions|r
|
|||||||
}
|
}
|
||||||
opts.Watch = true
|
opts.Watch = true
|
||||||
return c.GetClient().Get().
|
return c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
||||||
Timeout(timeout).
|
Timeout(timeout).
|
||||||
@ -779,6 +807,7 @@ func (c *$.type|privatePlural$) watchList(ctx $.context|raw$, opts $.ListOptions
|
|||||||
}
|
}
|
||||||
result = &$.resultType|raw$List{}
|
result = &$.resultType|raw$List{}
|
||||||
err = c.GetClient().Get().
|
err = c.GetClient().Get().
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
VersionedParams(&opts, $.schemeParameterCodec|raw$).
|
||||||
@ -794,6 +823,7 @@ var patchTemplate = `
|
|||||||
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) {
|
func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, name string, pt $.PatchType|raw$, data []byte, opts $.PatchOptions|raw$, subresources ...string) (result *$.resultType|raw$, err error) {
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Patch(pt).
|
err = c.GetClient().Patch(pt).
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -823,6 +853,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.inputType|private$
|
|||||||
}
|
}
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Patch($.ApplyPatchType|raw$).
|
err = c.GetClient().Patch($.ApplyPatchType|raw$).
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name(*name).
|
Name(*name).
|
||||||
@ -849,6 +880,7 @@ func (c *$.type|privatePlural$) $.verb$(ctx $.context|raw$, $.type|private$Name
|
|||||||
|
|
||||||
result = &$.resultType|raw${}
|
result = &$.resultType|raw${}
|
||||||
err = c.GetClient().Patch($.ApplyPatchType|raw$).
|
err = c.GetClient().Patch($.ApplyPatchType|raw$).
|
||||||
|
$if .prefersProtobuf$UseProtobufAsDefault().$end$
|
||||||
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
$if .namespaced$Namespace(c.GetNamespace()).$end$
|
||||||
Resource("$.type|resource$").
|
Resource("$.type|resource$").
|
||||||
Name($.type|private$Name).
|
Name($.type|private$Name).
|
||||||
|
@ -433,6 +433,9 @@ function kube::codegen::gen_openapi() {
|
|||||||
# --plural-exceptions <string = "">
|
# --plural-exceptions <string = "">
|
||||||
# An optional list of comma separated plural exception definitions in Type:PluralizedType form.
|
# An optional list of comma separated plural exception definitions in Type:PluralizedType form.
|
||||||
#
|
#
|
||||||
|
# --prefers-protobuf
|
||||||
|
# Enables generation of clientsets that use protobuf for API requests.
|
||||||
|
#
|
||||||
function kube::codegen::gen_client() {
|
function kube::codegen::gen_client() {
|
||||||
local in_dir=""
|
local in_dir=""
|
||||||
local one_input_api=""
|
local one_input_api=""
|
||||||
@ -450,6 +453,7 @@ function kube::codegen::gen_client() {
|
|||||||
local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt"
|
local boilerplate="${KUBE_CODEGEN_ROOT}/hack/boilerplate.go.txt"
|
||||||
local plural_exceptions=""
|
local plural_exceptions=""
|
||||||
local v="${KUBE_VERBOSE:-0}"
|
local v="${KUBE_VERBOSE:-0}"
|
||||||
|
local prefers_protobuf="false"
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -509,6 +513,10 @@ function kube::codegen::gen_client() {
|
|||||||
plural_exceptions="$2"
|
plural_exceptions="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
"--prefers-protobuf")
|
||||||
|
prefers_protobuf="true"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ "$1" =~ ^-- ]]; then
|
if [[ "$1" =~ ^-- ]]; then
|
||||||
echo "unknown argument: $1" >&2
|
echo "unknown argument: $1" >&2
|
||||||
@ -625,6 +633,7 @@ function kube::codegen::gen_client() {
|
|||||||
--apply-configuration-package "${applyconfig_pkg}" \
|
--apply-configuration-package "${applyconfig_pkg}" \
|
||||||
--input-base "$(cd "${in_dir}" && pwd -P)" `# must be absolute path or Go import path"` \
|
--input-base "$(cd "${in_dir}" && pwd -P)" `# must be absolute path or Go import path"` \
|
||||||
--plural-exceptions "${plural_exceptions}" \
|
--plural-exceptions "${plural_exceptions}" \
|
||||||
|
--prefers-protobuf="${prefers_protobuf}" \
|
||||||
"${inputs[@]}"
|
"${inputs[@]}"
|
||||||
|
|
||||||
if [ "${watchable}" == "true" ]; then
|
if [ "${watchable}" == "true" ]; then
|
||||||
|
@ -51,4 +51,5 @@ kube::codegen::gen_client \
|
|||||||
--clientset-name "clientset_generated" \
|
--clientset-name "clientset_generated" \
|
||||||
--versioned-name "clientset" \
|
--versioned-name "clientset" \
|
||||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||||
|
--prefers-protobuf \
|
||||||
"${SCRIPT_ROOT}/pkg/apis"
|
"${SCRIPT_ROOT}/pkg/apis"
|
||||||
|
@ -36,4 +36,5 @@ kube::codegen::gen_client \
|
|||||||
--output-dir "${SCRIPT_ROOT}/pkg/client" \
|
--output-dir "${SCRIPT_ROOT}/pkg/client" \
|
||||||
--output-pkg "${THIS_PKG}/pkg/client" \
|
--output-pkg "${THIS_PKG}/pkg/client" \
|
||||||
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
--boilerplate "${SCRIPT_ROOT}/hack/boilerplate.go.txt" \
|
||||||
|
--prefers-protobuf \
|
||||||
"${SCRIPT_ROOT}/pkg/apis"
|
"${SCRIPT_ROOT}/pkg/apis"
|
||||||
|
Loading…
Reference in New Issue
Block a user