-
Notifications
You must be signed in to change notification settings - Fork 39.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
client-gen tag shortcomings when newline is omitted #53893
Labels
kind/bug
Categorizes issue or PR as related to a bug.
sig/api-machinery
Categorizes an issue or PR as relevant to SIG API Machinery.
Comments
k8s-ci-robot
added
kind/bug
Categorizes issue or PR as related to a bug.
sig/api-machinery
Categorizes an issue or PR as relevant to SIG API Machinery.
labels
Oct 13, 2017
antoineco
changed the title
clientgen tag shortcomings when newline is omitted
client-gen tag shortcomings when newline is omitted
Oct 13, 2017
Full diff of what happened after I added the new line: diff --git a/pkg/apis/hcs/v1alpha1/types.go b/pkg/apis/hcs/v1alpha1/types.go
index 5a8df93..4be5682 100644
--- a/pkg/apis/hcs/v1alpha1/types.go
+++ b/pkg/apis/hcs/v1alpha1/types.go
@@ -7,6 +7,7 @@ import (
// MyCustomResource is my custom resource.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
+
type MyCustomResource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
diff --git a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/fake/fake_hcs_client.go b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/fake/fake_hcs_client.go
index ba9fa5a..350d9e8 100644
--- a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/fake/fake_hcs_client.go
+++ b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/fake/fake_hcs_client.go
@@ -2,4 +2,21 @@ package fake
import (
v1alpha1 "my.repo/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1"
+ rest "k8s.io/client-go/rest"
+ testing "k8s.io/client-go/testing"
)
+
+type FakeHcsV1alpha1 struct {
+ *testing.Fake
+}
+
+func (c *FakeHcsV1alpha1) MyCustomResources(namespace string) v1alpha1.MyCustomResourceInterface {
+ return &FakeMyCustomResources{c, namespace}
+}
+
+// RESTClient returns a RESTClient that is used to communicate
+// with API server by this client implementation.
+func (c *FakeHcsV1alpha1) RESTClient() rest.Interface {
+ var ret *rest.RESTClient
+ return ret
+}
diff --git a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/generated_expansion.go b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/generated_expansion.go
index 1c26788..a12c950 100644
--- a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/generated_expansion.go
+++ b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/generated_expansion.go
@@ -1 +1,3 @@
package v1alpha1
+
+type MyCustomResourceExpansion interface{}
diff --git a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/hcs_client.go b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/hcs_client.go
index e8cfb42..af96279 100644
--- a/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/hcs_client.go
+++ b/pkg/client/clientset_generated/internalclientset/typed/hcs/v1alpha1/hcs_client.go
@@ -1,5 +1,72 @@
package v1alpha1
import (
+ v1alpha1 "my.repo/pkg/apis/hcs/v1alpha1"
"my.repo/pkg/client/clientset_generated/internalclientset/scheme"
+ serializer "k8s.io/apimachinery/pkg/runtime/serializer"
+ rest "k8s.io/client-go/rest"
)
+
+type HcsV1alpha1Interface interface {
+ RESTClient() rest.Interface
+ MyCustomResourcesGetter
+}
+
+// HcsV1alpha1Client is used to interact with features provided by the hcs group.
+type HcsV1alpha1Client struct {
+ restClient rest.Interface
+}
+
+func (c *HcsV1alpha1Client) MyCustomResources(namespace string) MyCustomResourceInterface {
+ return newMyCustomResources(c, namespace)
+}
+
+// NewForConfig creates a new HcsV1alpha1Client for the given config.
+func NewForConfig(c *rest.Config) (*HcsV1alpha1Client, error) {
+ config := *c
+ if err := setConfigDefaults(&config); err != nil {
+ return nil, err
+ }
+ client, err := rest.RESTClientFor(&config)
+ if err != nil {
+ return nil, err
+ }
+ return &HcsV1alpha1Client{client}, nil
+}
+
+// NewForConfigOrDie creates a new HcsV1alpha1Client for the given config and
+// panics if there is an error in the config.
+func NewForConfigOrDie(c *rest.Config) *HcsV1alpha1Client {
+ client, err := NewForConfig(c)
+ if err != nil {
+ panic(err)
+ }
+ return client
+}
+
+// New creates a new HcsV1alpha1Client for the given RESTClient.
+func New(c rest.Interface) *HcsV1alpha1Client {
+ return &HcsV1alpha1Client{c}
+}
+
+func setConfigDefaults(config *rest.Config) error {
+ gv := v1alpha1.SchemeGroupVersion
+ config.GroupVersion = &gv
+ config.APIPath = "/apis"
+ config.NegotiatedSerializer = serializer.DirectCodecFactory{CodecFactory: scheme.Codecs}
+
+ if config.UserAgent == "" {
+ config.UserAgent = rest.DefaultKubernetesUserAgent()
+ }
+
+ return nil
+}
+
+// RESTClient returns a RESTClient that is used to communicate
+// with API server by this client implementation.
+func (c *HcsV1alpha1Client) RESTClient() rest.Interface {
+ if c == nil {
+ return nil
+ }
+ return c.restClient
+} |
Other tags must not have newlines #53579. We should remove this distinction. |
k8s-github-robot
pushed a commit
that referenced
this issue
Nov 18, 2017
Automatic merge from submit-queue (batch tested with PRs 55233, 55927, 55903, 54867, 55940). 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>. code-generators: remove distinction of 1st and 2nd comment block for tags Follow-up for #53579. Fixes #53893. ```release-note Allow code-generator tags in the 2nd closest comment block and directly above a statement. ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
kind/bug
Categorizes issue or PR as related to a bug.
sig/api-machinery
Categorizes an issue or PR as relevant to SIG API Machinery.
client-gen
does not generate the content oftyped/<group>/<version>/<group>_client.go
/typed/<group>/<version>/generated_expansion.go
when there is no new line between the// +genclient
tag and the next struct.How to reproduce:
works
fails
See also:
https://kubernetes.slack.com/archives/C0EG7JC6T/p1507887214000200
/kind bug
/sig api-machinery
The text was updated successfully, but these errors were encountered: