Skip to content

Commit a748e41

Browse files
Merge pull request #122772 from thockin/codegen_use_passed_flagset
code-gen: Use the passed FlagSet, not hardcoded Kubernetes-commit: c75a146f2346d21f8c8723b79b524e58eec3bea0
2 parents e0047a8 + 4ad37ee commit a748e41

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

cmd/applyconfiguration-gen/args/args.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
7070
}
7171

7272
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
73-
pflag.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations",
73+
fs.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations",
7474
"list of comma separated external apply configurations locations in <type-package>.<type-name>:<applyconfiguration-package> form."+
7575
"For example: k8s.io/api/apps/v1.Deployment:k8s.io/client-go/applyconfigurations/apps/v1")
76-
pflag.StringVar(&ca.OpenAPISchemaFilePath, "openapi-schema", "",
76+
fs.StringVar(&ca.OpenAPISchemaFilePath, "openapi-schema", "",
7777
"path to the openapi schema containing all the types that apply configurations will be generated for")
7878
}
7979

cmd/client-gen/args/args.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
8181

8282
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
8383
gvsBuilder := NewGroupVersionsBuilder(&ca.Groups)
84-
pflag.Var(NewGVPackagesValue(gvsBuilder, nil), "input", "group/versions that client-gen will generate clients for. At most one version per group is allowed. Specified in the format \"group1/version1,group2/version2...\".")
85-
pflag.Var(NewGVTypesValue(&ca.IncludedTypesOverrides, []string{}), "included-types-overrides", "list of group/version/type for which client should be generated. By default, client is generated for all types which have genclient in types.go. This overrides that. For each groupVersion in this list, only the types mentioned here will be included. The default check of genclient will be used for other group versions.")
86-
pflag.Var(NewInputBasePathValue(gvsBuilder, inputBase), "input-base", "base path to look for the api group.")
87-
pflag.StringVarP(&ca.ClientsetName, "clientset-name", "n", ca.ClientsetName, "the name of the generated clientset package.")
88-
pflag.StringVarP(&ca.ClientsetAPIPath, "clientset-api-path", "", ca.ClientsetAPIPath, "the value of default API HTTP path, starting with / and without trailing /.")
89-
pflag.BoolVar(&ca.ClientsetOnly, "clientset-only", ca.ClientsetOnly, "when set, client-gen only generates the clientset shell, without generating the individual typed clients")
90-
pflag.BoolVar(&ca.FakeClient, "fake-clientset", ca.FakeClient, "when set, client-gen will generate the fake clientset that can be used in tests")
84+
fs.Var(NewGVPackagesValue(gvsBuilder, nil), "input", "group/versions that client-gen will generate clients for. At most one version per group is allowed. Specified in the format \"group1/version1,group2/version2...\".")
85+
fs.Var(NewGVTypesValue(&ca.IncludedTypesOverrides, []string{}), "included-types-overrides", "list of group/version/type for which client should be generated. By default, client is generated for all types which have genclient in types.go. This overrides that. For each groupVersion in this list, only the types mentioned here will be included. The default check of genclient will be used for other group versions.")
86+
fs.Var(NewInputBasePathValue(gvsBuilder, inputBase), "input-base", "base path to look for the api group.")
87+
fs.StringVarP(&ca.ClientsetName, "clientset-name", "n", ca.ClientsetName, "the name of the generated clientset package.")
88+
fs.StringVarP(&ca.ClientsetAPIPath, "clientset-api-path", "", ca.ClientsetAPIPath, "the value of default API HTTP path, starting with / and without trailing /.")
89+
fs.BoolVar(&ca.ClientsetOnly, "clientset-only", ca.ClientsetOnly, "when set, client-gen only generates the clientset shell, without generating the individual typed clients")
90+
fs.BoolVar(&ca.FakeClient, "fake-clientset", ca.FakeClient, "when set, client-gen will generate the fake clientset that can be used in tests")
9191

9292
fs.StringSliceVar(&ca.PluralExceptions, "plural-exceptions", ca.PluralExceptions, "list of comma separated plural exception definitions in Type:PluralizedType form")
9393
fs.StringVar(&ca.ApplyConfigurationPackage, "apply-configuration-package", ca.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.")

cmd/conversion-gen/args/args.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
6868

6969
// AddFlags add the generator flags to the flag set.
7070
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
71-
pflag.CommandLine.StringSliceVar(&ca.BasePeerDirs, "base-peer-dirs", ca.BasePeerDirs,
71+
fs.StringSliceVar(&ca.BasePeerDirs, "base-peer-dirs", ca.BasePeerDirs,
7272
"Comma-separated list of apimachinery import paths which are considered, after tag-specified peers, for conversions. Only change these if you have very good reasons.")
73-
pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs,
73+
fs.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs,
7474
"Application specific comma-separated list of import paths which are considered, after tag-specified peers and base-peer-dirs, for conversions.")
75-
pflag.CommandLine.StringSliceVar(&ca.ExtraDirs, "extra-dirs", ca.ExtraDirs,
75+
fs.StringSliceVar(&ca.ExtraDirs, "extra-dirs", ca.ExtraDirs,
7676
"Application specific comma-separated list of import paths which are loaded and considered for callable conversions, but are not considered peers for conversion.")
77-
pflag.CommandLine.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe,
77+
fs.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe,
7878
"If true, will not generate code using unsafe pointer conversions; resulting code may be slower.")
7979
}
8080

cmd/deepcopy-gen/args/args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
3838

3939
// AddFlags add the generator flags to the flag set.
4040
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
41-
pflag.CommandLine.StringSliceVar(&ca.BoundingDirs, "bounding-dirs", ca.BoundingDirs,
41+
fs.StringSliceVar(&ca.BoundingDirs, "bounding-dirs", ca.BoundingDirs,
4242
"Comma-separated list of import paths which bound the types for which deep-copies will be generated.")
4343
}
4444

cmd/defaulter-gen/args/args.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
3838

3939
// AddFlags add the generator flags to the flag set.
4040
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
41-
pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs,
41+
fs.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs,
4242
"Comma-separated list of import paths which are considered, after tag-specified peers, for conversions.")
4343
}
4444

0 commit comments

Comments
 (0)