From 7162b930becdf3a534a024182ce05101c138f94c Mon Sep 17 00:00:00 2001 From: Tim Hockin Date: Thu, 21 Dec 2023 13:22:18 -0800 Subject: [PATCH] code-gen: Use the passed FlagSet, not hardcoded Even if the one we pass in is apparently always the default CommandLine, we should use the one passed in. --- .../cmd/applyconfiguration-gen/args/args.go | 4 ++-- .../code-generator/cmd/client-gen/args/args.go | 14 +++++++------- .../code-generator/cmd/conversion-gen/args/args.go | 8 ++++---- .../code-generator/cmd/deepcopy-gen/args/args.go | 2 +- .../code-generator/cmd/defaulter-gen/args/args.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/args/args.go b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/args/args.go index c7e873d3fa5..95ebd79598d 100644 --- a/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/args/args.go +++ b/staging/src/k8s.io/code-generator/cmd/applyconfiguration-gen/args/args.go @@ -70,10 +70,10 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) { } func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) { - pflag.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations", + fs.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations", "list of comma separated external apply configurations locations in .: form."+ "For example: k8s.io/api/apps/v1.Deployment:k8s.io/client-go/applyconfigurations/apps/v1") - pflag.StringVar(&ca.OpenAPISchemaFilePath, "openapi-schema", "", + fs.StringVar(&ca.OpenAPISchemaFilePath, "openapi-schema", "", "path to the openapi schema containing all the types that apply configurations will be generated for") } diff --git a/staging/src/k8s.io/code-generator/cmd/client-gen/args/args.go b/staging/src/k8s.io/code-generator/cmd/client-gen/args/args.go index 4460ad26a25..5b3f1981fad 100644 --- a/staging/src/k8s.io/code-generator/cmd/client-gen/args/args.go +++ b/staging/src/k8s.io/code-generator/cmd/client-gen/args/args.go @@ -81,13 +81,13 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) { func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) { gvsBuilder := NewGroupVersionsBuilder(&ca.Groups) - 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...\".") - 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.") - pflag.Var(NewInputBasePathValue(gvsBuilder, inputBase), "input-base", "base path to look for the api group.") - pflag.StringVarP(&ca.ClientsetName, "clientset-name", "n", ca.ClientsetName, "the name of the generated clientset package.") - pflag.StringVarP(&ca.ClientsetAPIPath, "clientset-api-path", "", ca.ClientsetAPIPath, "the value of default API HTTP path, starting with / and without trailing /.") - pflag.BoolVar(&ca.ClientsetOnly, "clientset-only", ca.ClientsetOnly, "when set, client-gen only generates the clientset shell, without generating the individual typed clients") - pflag.BoolVar(&ca.FakeClient, "fake-clientset", ca.FakeClient, "when set, client-gen will generate the fake clientset that can be used in tests") + 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...\".") + 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.") + fs.Var(NewInputBasePathValue(gvsBuilder, inputBase), "input-base", "base path to look for the api group.") + fs.StringVarP(&ca.ClientsetName, "clientset-name", "n", ca.ClientsetName, "the name of the generated clientset package.") + fs.StringVarP(&ca.ClientsetAPIPath, "clientset-api-path", "", ca.ClientsetAPIPath, "the value of default API HTTP path, starting with / and without trailing /.") + fs.BoolVar(&ca.ClientsetOnly, "clientset-only", ca.ClientsetOnly, "when set, client-gen only generates the clientset shell, without generating the individual typed clients") + fs.BoolVar(&ca.FakeClient, "fake-clientset", ca.FakeClient, "when set, client-gen will generate the fake clientset that can be used in tests") fs.StringSliceVar(&ca.PluralExceptions, "plural-exceptions", ca.PluralExceptions, "list of comma separated plural exception definitions in Type:PluralizedType form") 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.") diff --git a/staging/src/k8s.io/code-generator/cmd/conversion-gen/args/args.go b/staging/src/k8s.io/code-generator/cmd/conversion-gen/args/args.go index c69280b1063..d3166b56593 100644 --- a/staging/src/k8s.io/code-generator/cmd/conversion-gen/args/args.go +++ b/staging/src/k8s.io/code-generator/cmd/conversion-gen/args/args.go @@ -68,13 +68,13 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) { // AddFlags add the generator flags to the flag set. func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) { - pflag.CommandLine.StringSliceVar(&ca.BasePeerDirs, "base-peer-dirs", ca.BasePeerDirs, + fs.StringSliceVar(&ca.BasePeerDirs, "base-peer-dirs", ca.BasePeerDirs, "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.") - pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs, + fs.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs, "Application specific comma-separated list of import paths which are considered, after tag-specified peers and base-peer-dirs, for conversions.") - pflag.CommandLine.StringSliceVar(&ca.ExtraDirs, "extra-dirs", ca.ExtraDirs, + fs.StringSliceVar(&ca.ExtraDirs, "extra-dirs", ca.ExtraDirs, "Application specific comma-separated list of import paths which are loaded and considered for callable conversions, but are not considered peers for conversion.") - pflag.CommandLine.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe, + fs.BoolVar(&ca.SkipUnsafe, "skip-unsafe", ca.SkipUnsafe, "If true, will not generate code using unsafe pointer conversions; resulting code may be slower.") } diff --git a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go index 789713012ad..9674e5b5c92 100644 --- a/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go +++ b/staging/src/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go @@ -38,7 +38,7 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) { // AddFlags add the generator flags to the flag set. func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) { - pflag.CommandLine.StringSliceVar(&ca.BoundingDirs, "bounding-dirs", ca.BoundingDirs, + fs.StringSliceVar(&ca.BoundingDirs, "bounding-dirs", ca.BoundingDirs, "Comma-separated list of import paths which bound the types for which deep-copies will be generated.") } diff --git a/staging/src/k8s.io/code-generator/cmd/defaulter-gen/args/args.go b/staging/src/k8s.io/code-generator/cmd/defaulter-gen/args/args.go index 3c5a042c7ca..b6ea2dd0289 100644 --- a/staging/src/k8s.io/code-generator/cmd/defaulter-gen/args/args.go +++ b/staging/src/k8s.io/code-generator/cmd/defaulter-gen/args/args.go @@ -38,7 +38,7 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) { // AddFlags add the generator flags to the flag set. func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) { - pflag.CommandLine.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs, + fs.StringSliceVar(&ca.ExtraPeerDirs, "extra-peer-dirs", ca.ExtraPeerDirs, "Comma-separated list of import paths which are considered, after tag-specified peers, for conversions.") }