Skip to content

Commit b7945e2

Browse files
Merge pull request #17 from varshaprasad96/add-missing-clientgen-markers
Add missing clientgen markers
2 parents 7a5b91f + c64c58b commit b7945e2

File tree

9 files changed

+671
-164
lines changed

9 files changed

+671
-164
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

+10-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
goflags "flag"
2021
"fmt"
2122
"os"
2223
"strings"
2324

2425
"github.com/spf13/cobra"
26+
"k8s.io/klog/v2"
2527
"sigs.k8s.io/controller-tools/pkg/genall"
2628
"sigs.k8s.io/controller-tools/pkg/markers"
2729

@@ -39,9 +41,10 @@ var (
3941
func main() {
4042
f := &flag.Flags{}
4143
cmd := &cobra.Command{
42-
Use: "code-gen",
43-
Short: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
44-
Long: "Generate cluster-aware kcp wrappers around clients, listers and informers.",
44+
Use: "code-gen",
45+
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.",
4548
Example: `Generate cluster-aware kcp clients from existing code scaffolded by k8.io/code-gen.
4649
For example:
4750
# To generate client wrappers:
@@ -94,6 +97,10 @@ func main() {
9497
},
9598
}
9699

100+
fs := goflags.NewFlagSet("klog", goflags.PanicOnError)
101+
klog.InitFlags(fs)
102+
cmd.Flags().AddGoFlagSet(fs)
103+
97104
f.AddTo(cmd.Flags())
98105

99106
if err := cmd.Execute(); err != nil {

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)