Skip to content

Add missing clientgen markers #17

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/pkg/apis/example/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

// +genclient
// +genclient:noStatus
// TestType is a top-level type. A client is created for it.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type TestType struct {
Expand Down
109 changes: 54 additions & 55 deletions examples/pkg/clusterclient/typed/example/v1/examplev1.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.5
k8s.io/code-generator v0.23.0
k8s.io/klog/v2 v2.60.1
sigs.k8s.io/controller-tools v0.8.0
)

Expand Down Expand Up @@ -49,7 +50,6 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.23.5 // indirect
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 // indirect
k8s.io/klog/v2 v2.60.1 // indirect
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
Expand Down
13 changes: 10 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ limitations under the License.
package main

import (
goflags "flag"
Copy link
Member

@njhale njhale May 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this is probably an indication that we either shouldn't use the name flag OR the flags should be exported from another package; e.g. pkg/generators

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have flags imported internally here:

"github.com/kcp-dev/code-generator/pkg/flag"
. Did you mean to rename those instead of tagging this as go flags?

"fmt"
"os"
"strings"

"github.com/spf13/cobra"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-tools/pkg/genall"
"sigs.k8s.io/controller-tools/pkg/markers"

Expand All @@ -39,9 +41,10 @@ var (
func main() {
f := &flag.Flags{}
cmd := &cobra.Command{
Use: "code-gen",
Short: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
Long: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
Use: "code-gen",
SilenceUsage: true,
Short: "Generate cluster-aware kcp wrappers around clients, listers, and informers.",
Long: "Generate cluster-aware kcp wrappers around clients, listers, and informers.",
Example: `Generate cluster-aware kcp clients from existing code scaffolded by k8.io/code-gen.
For example:
# To generate client wrappers:
Expand Down Expand Up @@ -94,6 +97,10 @@ func main() {
},
}

fs := goflags.NewFlagSet("klog", goflags.PanicOnError)
klog.InitFlags(fs)
cmd.Flags().AddGoFlagSet(fs)

f.AddTo(cmd.Flags())

if err := cmd.Execute(); err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/flag/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ type Flags struct {
InputDir string
// ClientsetAPIPath is the path to where client sets are scaffolded by codegen.
ClientsetAPIPath string
// 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. If this is provided, then wrappers for Apply functions will be generated.
ApplyConfigurationPackage string
// List of group versions for which the wrappers are to be generated.
GroupVersions []string
// Path to the headerfile.
Expand All @@ -41,7 +44,7 @@ func (f *Flags) AddTo(flagset *pflag.FlagSet) {
flagset.StringVar(&f.InputDir, "input-dir", "", "Input directory where types are defined. It is assumed that 'types.go' is present inside <InputDir>/pkg/apis.")
flagset.StringVar(&f.OutputDir, "output-dir", "output", "Output directory where wrapped clients will be generated. The wrappers will be present in '<output-dir>/generated' path.")
flagset.StringVar(&f.ClientsetAPIPath, "clientset-api-path", "/apis", "package path where clients are generated.")

flagset.StringVar(&f.ApplyConfigurationPackage, "apply-configuration-package", "", "optional package of apply configurations, generated by applyconfiguration-gen, that are required to generate Apply functions for each type in the clientset. If this is provided, then wrappers for Apply functions will be generated.")
flagset.StringArrayVar(&f.GroupVersions, "group-versions", []string{}, "specify group versions for the clients.")
flagset.StringVar(&f.GoHeaderFilePath, "go-header-file", "", "path to headerfile for the generated text.")
flagset.StringVar(&f.ClientsetName, "clientset-name", "clientset", "the name of the generated clientset package.")
Expand Down
Loading