Skip to content

Commit 9bda2d0

Browse files
This commit adds support to all the //+genclient markers as specified
by upstream k8s code-generator. Signed-off-by: varshaprasad96 <[email protected]>
1 parent 037a404 commit 9bda2d0

File tree

9 files changed

+562
-181
lines changed

9 files changed

+562
-181
lines changed

examples/pkg/apis/example/v1/types.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package v1
1919
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020

2121
// +genclient
22+
// +genclient:noStatus
2223
// TestType is a top-level type. A client is created for it.
2324
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2425
type TestType struct {

examples/pkg/clusterclient/typed/example/v1/examplev1.go

+54-55
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
k8s.io/apimachinery v0.23.5
1515
k8s.io/client-go v0.23.5
1616
k8s.io/code-generator v0.23.0
17+
k8s.io/klog/v2 v2.60.1
1718
sigs.k8s.io/controller-tools v0.8.0
1819
)
1920

@@ -49,7 +50,6 @@ require (
4950
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
5051
k8s.io/api v0.23.5 // indirect
5152
k8s.io/gengo v0.0.0-20211129171323-c02415ce4185 // indirect
52-
k8s.io/klog/v2 v2.60.1 // indirect
5353
k8s.io/kube-openapi v0.0.0-20220328201542-3ee0da9b0b42 // indirect
5454
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
5555
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ func main() {
4343
cmd := &cobra.Command{
4444
Use: "code-gen",
4545
SilenceUsage: true,
46-
Short: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
47-
Long: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
46+
Short: "Generate cluster-aware kcp wrappers around clients, listers, and informers.",
47+
Long: "Generate cluster-aware kcp wrappers around clients, listers, and informers.",
4848
Example: `Generate cluster-aware kcp clients from existing code scaffolded by k8.io/code-gen.
4949
For example:
5050
# To generate client wrappers:

pkg/flag/flags.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type Flags struct {
2828
InputDir string
2929
// ClientsetAPIPath is the path to where client sets are scaffolded by codegen.
3030
ClientsetAPIPath string
31+
// optional package of apply configurations, generated by applyconfiguration-gen, that are required to generate Apply functions for each type in the clientset.
32+
// By default Apply functions are not generated. If this is provided, then wrappers for Apply functions will be generated.
33+
ApplyConfigurationPackage string
3134
// List of group versions for which the wrappers are to be generated.
3235
GroupVersions []string
3336
// Path to the headerfile.
@@ -41,7 +44,7 @@ func (f *Flags) AddTo(flagset *pflag.FlagSet) {
4144
flagset.StringVar(&f.InputDir, "input-dir", "", "Input directory where types are defined. It is assumed that 'types.go' is present inside <InputDir>/pkg/apis.")
4245
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.")
4346
flagset.StringVar(&f.ClientsetAPIPath, "clientset-api-path", "/apis", "package path where clients are generated.")
44-
47+
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.")
4548
flagset.StringArrayVar(&f.GroupVersions, "group-versions", []string{}, "specify group versions for the clients.")
4649
flagset.StringVar(&f.GoHeaderFilePath, "go-header-file", "", "path to headerfile for the generated text.")
4750
flagset.StringVar(&f.ClientsetName, "clientset-name", "clientset", "the name of the generated clientset package.")

0 commit comments

Comments
 (0)