mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
Move the OutputBase flag to each tool
...and rename to --output-dir
This commit is contained in:
parent
875566f997
commit
6a375b8f4c
@ -43,7 +43,7 @@ PATH="${KUBE_ROOT}/_output/bin:${PATH}" \
|
|||||||
"${gotoprotobuf}" \
|
"${gotoprotobuf}" \
|
||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
|
--go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
|
||||||
--output-base="${KUBE_ROOT}/staging/src" \
|
--output-dir="${KUBE_ROOT}/staging/src" \
|
||||||
--proto-import="${KUBE_ROOT}/staging/src" \
|
--proto-import="${KUBE_ROOT}/staging/src" \
|
||||||
--proto-import="${KUBE_ROOT}/vendor" `# required for gogo.proto` \
|
--proto-import="${KUBE_ROOT}/vendor" `# required for gogo.proto` \
|
||||||
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
|
--proto-import="${KUBE_ROOT}/third_party/protobuf" \
|
||||||
|
@ -552,7 +552,7 @@ function codegen::openapi() {
|
|||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--go-header-file "${BOILERPLATE_FILENAME}" \
|
--go-header-file "${BOILERPLATE_FILENAME}" \
|
||||||
--output-file-base "${output_file}" \
|
--output-file-base "${output_file}" \
|
||||||
--output-base "${output_dir}" \
|
--output-dir "${output_dir}" \
|
||||||
--output-package "${output_pkg}" \
|
--output-package "${output_pkg}" \
|
||||||
--report-filename "${report_file}" \
|
--report-filename "${report_file}" \
|
||||||
$(printf -- " -i %s" "${tag_pkgs[@]}") \
|
$(printf -- " -i %s" "${tag_pkgs[@]}") \
|
||||||
@ -608,7 +608,7 @@ function codegen::applyconfigs() {
|
|||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--openapi-schema <("${modelsschema}") \
|
--openapi-schema <("${modelsschema}") \
|
||||||
--go-header-file "${BOILERPLATE_FILENAME}" \
|
--go-header-file "${BOILERPLATE_FILENAME}" \
|
||||||
--output-base "${KUBE_ROOT}/staging/src/${APPLYCONFIG_PKG}" \
|
--output-dir "${KUBE_ROOT}/staging/src/${APPLYCONFIG_PKG}" \
|
||||||
--output-package "${APPLYCONFIG_PKG}" \
|
--output-package "${APPLYCONFIG_PKG}" \
|
||||||
$(printf -- " --input-dirs %s" "${ext_apis[@]}") \
|
$(printf -- " --input-dirs %s" "${ext_apis[@]}") \
|
||||||
"$@"
|
"$@"
|
||||||
@ -661,7 +661,7 @@ function codegen::clients() {
|
|||||||
"${clientgen}" \
|
"${clientgen}" \
|
||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--go-header-file "${BOILERPLATE_FILENAME}" \
|
--go-header-file "${BOILERPLATE_FILENAME}" \
|
||||||
--output-base "${KUBE_ROOT}/staging/src/k8s.io/client-go" \
|
--output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go" \
|
||||||
--output-package="k8s.io/client-go" \
|
--output-package="k8s.io/client-go" \
|
||||||
--clientset-name="kubernetes" \
|
--clientset-name="kubernetes" \
|
||||||
--input-base="k8s.io/api" \
|
--input-base="k8s.io/api" \
|
||||||
@ -706,7 +706,7 @@ function codegen::listers() {
|
|||||||
"${listergen}" \
|
"${listergen}" \
|
||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--go-header-file "${BOILERPLATE_FILENAME}" \
|
--go-header-file "${BOILERPLATE_FILENAME}" \
|
||||||
--output-base "${KUBE_ROOT}/staging/src/k8s.io/client-go/listers" \
|
--output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go/listers" \
|
||||||
--output-package "k8s.io/client-go/listers" \
|
--output-package "k8s.io/client-go/listers" \
|
||||||
$(printf -- " --input-dirs %s" "${ext_apis[@]}") \
|
$(printf -- " --input-dirs %s" "${ext_apis[@]}") \
|
||||||
"$@"
|
"$@"
|
||||||
@ -748,7 +748,7 @@ function codegen::informers() {
|
|||||||
"${informergen}" \
|
"${informergen}" \
|
||||||
-v "${KUBE_VERBOSE}" \
|
-v "${KUBE_VERBOSE}" \
|
||||||
--go-header-file "${BOILERPLATE_FILENAME}" \
|
--go-header-file "${BOILERPLATE_FILENAME}" \
|
||||||
--output-base "${KUBE_ROOT}/staging/src/k8s.io/client-go/informers" \
|
--output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go/informers" \
|
||||||
--output-package "k8s.io/client-go/informers" \
|
--output-package "k8s.io/client-go/informers" \
|
||||||
--single-directory \
|
--single-directory \
|
||||||
--versioned-clientset-package "k8s.io/client-go/kubernetes" \
|
--versioned-clientset-package "k8s.io/client-go/kubernetes" \
|
||||||
|
@ -26,6 +26,7 @@ import (
|
|||||||
|
|
||||||
// CustomArgs is a wrapper for arguments to applyconfiguration-gen.
|
// CustomArgs is a wrapper for arguments to applyconfiguration-gen.
|
||||||
type CustomArgs struct {
|
type CustomArgs struct {
|
||||||
|
OutputDir string // must be a directory path
|
||||||
OutputPackage string // must be a Go import-path
|
OutputPackage string // must be a Go import-path
|
||||||
|
|
||||||
// ExternalApplyConfigurations provides the locations of externally generated
|
// ExternalApplyConfigurations provides the locations of externally generated
|
||||||
@ -65,7 +66,10 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
||||||
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage, "the Go import-path of the generated results")
|
fs.StringVar(&ca.OutputDir, "output-dir", "",
|
||||||
|
"the base directory under which to generate results")
|
||||||
|
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage,
|
||||||
|
"the Go import-path of the generated results")
|
||||||
fs.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations",
|
fs.Var(NewExternalApplyConfigurationValue(&ca.ExternalApplyConfigurations, nil), "external-applyconfigurations",
|
||||||
"list of comma separated external apply configurations locations in <type-package>.<type-name>:<applyconfiguration-package> form."+
|
"list of comma separated external apply configurations locations in <type-package>.<type-name>:<applyconfiguration-package> form."+
|
||||||
"For example: k8s.io/api/apps/v1.Deployment:k8s.io/client-go/applyconfigurations/apps/v1")
|
"For example: k8s.io/api/apps/v1.Deployment:k8s.io/client-go/applyconfigurations/apps/v1")
|
||||||
@ -75,12 +79,11 @@ func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
|||||||
|
|
||||||
// Validate checks the given arguments.
|
// Validate checks the given arguments.
|
||||||
func Validate(genericArgs *args.GeneratorArgs) error {
|
func Validate(genericArgs *args.GeneratorArgs) error {
|
||||||
if len(genericArgs.OutputBase) == 0 {
|
|
||||||
return fmt.Errorf("--output-base must be specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
||||||
|
|
||||||
|
if len(customArgs.OutputDir) == 0 {
|
||||||
|
return fmt.Errorf("--output-dir must be specified")
|
||||||
|
}
|
||||||
if len(customArgs.OutputPackage) == 0 {
|
if len(customArgs.OutputPackage) == 0 {
|
||||||
return fmt.Errorf("--output-package must be specified")
|
return fmt.Errorf("--output-package must be specified")
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func GetTargets(context *generator.Context, arguments *args.GeneratorArgs) []gen
|
|||||||
// generate the apply configurations
|
// generate the apply configurations
|
||||||
targetList = append(targetList,
|
targetList = append(targetList,
|
||||||
targetForApplyConfigurationsPackage(
|
targetForApplyConfigurationsPackage(
|
||||||
arguments.OutputBase, customArgs.OutputPackage, pkgSubdir,
|
customArgs.OutputDir, customArgs.OutputPackage, pkgSubdir,
|
||||||
boilerplate, gv, toGenerate, refs, typeModels))
|
boilerplate, gv, toGenerate, refs, typeModels))
|
||||||
|
|
||||||
// group all the generated apply configurations by gv so ForKind() can be generated
|
// group all the generated apply configurations by gv so ForKind() can be generated
|
||||||
@ -133,11 +133,11 @@ func GetTargets(context *generator.Context, arguments *args.GeneratorArgs) []gen
|
|||||||
|
|
||||||
// generate ForKind() utility function
|
// generate ForKind() utility function
|
||||||
targetList = append(targetList,
|
targetList = append(targetList,
|
||||||
targetForUtils(arguments.OutputBase, customArgs.OutputPackage,
|
targetForUtils(customArgs.OutputDir, customArgs.OutputPackage,
|
||||||
boilerplate, groupVersions, applyConfigsForGroupVersion, groupGoNames))
|
boilerplate, groupVersions, applyConfigsForGroupVersion, groupGoNames))
|
||||||
// generate internal embedded schema, required for generated Extract functions
|
// generate internal embedded schema, required for generated Extract functions
|
||||||
targetList = append(targetList,
|
targetList = append(targetList,
|
||||||
targetForInternal(arguments.OutputBase, customArgs.OutputPackage,
|
targetForInternal(customArgs.OutputDir, customArgs.OutputPackage,
|
||||||
boilerplate, typeModels))
|
boilerplate, typeModels))
|
||||||
|
|
||||||
return targetList
|
return targetList
|
||||||
|
@ -29,6 +29,9 @@ var DefaultInputDirs = []string{}
|
|||||||
|
|
||||||
// CustomArgs is a wrapper for arguments to client-gen.
|
// CustomArgs is a wrapper for arguments to client-gen.
|
||||||
type CustomArgs struct {
|
type CustomArgs struct {
|
||||||
|
// The directory for the generated results.
|
||||||
|
OutputDir string
|
||||||
|
|
||||||
// The Go import-path of the generated results.
|
// The Go import-path of the generated results.
|
||||||
OutputPackage string
|
OutputPackage string
|
||||||
|
|
||||||
@ -78,7 +81,10 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
|
|||||||
|
|
||||||
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
||||||
gvsBuilder := NewGroupVersionsBuilder(&ca.Groups)
|
gvsBuilder := NewGroupVersionsBuilder(&ca.Groups)
|
||||||
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage, "the Go import-path of the generated results")
|
fs.StringVar(&ca.OutputDir, "output-dir", "",
|
||||||
|
"the base directory under which to generate results")
|
||||||
|
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage,
|
||||||
|
"the Go import-path of the generated results")
|
||||||
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(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(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.Var(NewInputBasePathValue(gvsBuilder, inputBase), "input-base", "base path to look for the api group.")
|
||||||
@ -95,12 +101,11 @@ func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet, inputBase string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Validate(genericArgs *args.GeneratorArgs) error {
|
func Validate(genericArgs *args.GeneratorArgs) error {
|
||||||
if len(genericArgs.OutputBase) == 0 {
|
|
||||||
return fmt.Errorf("--output-base must be specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
||||||
|
|
||||||
|
if len(customArgs.OutputDir) == 0 {
|
||||||
|
return fmt.Errorf("--output-dir must be specified")
|
||||||
|
}
|
||||||
if len(customArgs.OutputPackage) == 0 {
|
if len(customArgs.OutputPackage) == 0 {
|
||||||
return fmt.Errorf("--output-package must be specified")
|
return fmt.Errorf("--output-package must be specified")
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ func GetTargets(context *generator.Context, arguments *args.GeneratorArgs) []gen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clientsetDir := filepath.Join(arguments.OutputBase, customArgs.ClientsetName)
|
clientsetDir := filepath.Join(customArgs.OutputDir, customArgs.ClientsetName)
|
||||||
clientsetPkg := filepath.Join(customArgs.OutputPackage, customArgs.ClientsetName)
|
clientsetPkg := filepath.Join(customArgs.OutputPackage, customArgs.ClientsetName)
|
||||||
|
|
||||||
var targetList []generator.Target
|
var targetList []generator.Target
|
||||||
|
@ -40,7 +40,7 @@ type Generator struct {
|
|||||||
Common args.GeneratorArgs
|
Common args.GeneratorArgs
|
||||||
APIMachineryPackages string
|
APIMachineryPackages string
|
||||||
Packages string
|
Packages string
|
||||||
OutputBase string
|
OutputDir string
|
||||||
ProtoImport []string
|
ProtoImport []string
|
||||||
Conditional string
|
Conditional string
|
||||||
Clean bool
|
Clean bool
|
||||||
@ -52,12 +52,8 @@ type Generator struct {
|
|||||||
|
|
||||||
func New() *Generator {
|
func New() *Generator {
|
||||||
defaultSourceTree := "."
|
defaultSourceTree := "."
|
||||||
common := args.GeneratorArgs{
|
|
||||||
OutputBase: defaultSourceTree,
|
|
||||||
}
|
|
||||||
return &Generator{
|
return &Generator{
|
||||||
Common: common,
|
OutputDir: defaultSourceTree,
|
||||||
OutputBase: defaultSourceTree,
|
|
||||||
APIMachineryPackages: strings.Join([]string{
|
APIMachineryPackages: strings.Join([]string{
|
||||||
`+k8s.io/apimachinery/pkg/util/intstr`,
|
`+k8s.io/apimachinery/pkg/util/intstr`,
|
||||||
`+k8s.io/apimachinery/pkg/api/resource`,
|
`+k8s.io/apimachinery/pkg/api/resource`,
|
||||||
@ -77,7 +73,7 @@ func (g *Generator) BindFlags(flag *flag.FlagSet) {
|
|||||||
flag.BoolVar(&g.Common.VerifyOnly, "verify-only", g.Common.VerifyOnly, "If true, only verify existing output, do not write anything.")
|
flag.BoolVar(&g.Common.VerifyOnly, "verify-only", g.Common.VerifyOnly, "If true, only verify existing output, do not write anything.")
|
||||||
flag.StringVarP(&g.Packages, "packages", "p", g.Packages, "comma-separated list of directories to get input types from. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
flag.StringVarP(&g.Packages, "packages", "p", g.Packages, "comma-separated list of directories to get input types from. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
||||||
flag.StringVar(&g.APIMachineryPackages, "apimachinery-packages", g.APIMachineryPackages, "comma-separated list of directories to get apimachinery input types from which are needed by any API. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
flag.StringVar(&g.APIMachineryPackages, "apimachinery-packages", g.APIMachineryPackages, "comma-separated list of directories to get apimachinery input types from which are needed by any API. Directories prefixed with '-' are not generated, directories prefixed with '+' only create types with explicit IDL instructions.")
|
||||||
flag.StringVarP(&g.OutputBase, "output-base", "o", g.OutputBase, "Output base; defaults to $GOPATH/src/")
|
flag.StringVar(&g.OutputDir, "output-dir", g.OutputDir, "The base directory under which to generate results.")
|
||||||
flag.StringSliceVar(&g.ProtoImport, "proto-import", g.ProtoImport, "A search path for imported protobufs (may be repeated).")
|
flag.StringSliceVar(&g.ProtoImport, "proto-import", g.ProtoImport, "A search path for imported protobufs (may be repeated).")
|
||||||
flag.StringVar(&g.Conditional, "conditional", g.Conditional, "An optional Golang build tag condition to add to the generated Go code")
|
flag.StringVar(&g.Conditional, "conditional", g.Conditional, "An optional Golang build tag condition to add to the generated Go code")
|
||||||
flag.BoolVar(&g.Clean, "clean", g.Clean, "If true, remove all generated files for the specified Packages.")
|
flag.BoolVar(&g.Clean, "clean", g.Clean, "If true, remove all generated files for the specified Packages.")
|
||||||
@ -255,7 +251,7 @@ func Run(g *Generator) {
|
|||||||
log.Fatalf("Unable to find 'protoc': %v", err)
|
log.Fatalf("Unable to find 'protoc': %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
searchArgs := []string{"-I", ".", "-I", g.OutputBase}
|
searchArgs := []string{"-I", ".", "-I", g.OutputDir}
|
||||||
if len(g.ProtoImport) != 0 {
|
if len(g.ProtoImport) != 0 {
|
||||||
for _, s := range g.ProtoImport {
|
for _, s := range g.ProtoImport {
|
||||||
searchArgs = append(searchArgs, "-I", s)
|
searchArgs = append(searchArgs, "-I", s)
|
||||||
@ -266,12 +262,12 @@ func Run(g *Generator) {
|
|||||||
// doesn't. Given example.com/foo/bar.proto (found in one of the -I paths
|
// doesn't. Given example.com/foo/bar.proto (found in one of the -I paths
|
||||||
// above), the output becomes
|
// above), the output becomes
|
||||||
// $output_base/example.com/foo/example.com/foo/bar.pb.go - basically
|
// $output_base/example.com/foo/example.com/foo/bar.pb.go - basically
|
||||||
// useless. Users should set the output-base to a single dir under which
|
// useless. Users should set the output-dir to a single dir under which
|
||||||
// all the packages in question live (e.g. staging/src in kubernetes).
|
// all the packages in question live (e.g. staging/src in kubernetes).
|
||||||
// Alternately, we could generate into a temp path and then move the
|
// Alternately, we could generate into a temp path and then move the
|
||||||
// resulting file back to the input dir, but that seems brittle in other
|
// resulting file back to the input dir, but that seems brittle in other
|
||||||
// ways.
|
// ways.
|
||||||
args := append(searchArgs, fmt.Sprintf("--gogo_out=%s", g.OutputBase))
|
args := append(searchArgs, fmt.Sprintf("--gogo_out=%s", g.OutputDir))
|
||||||
|
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
if len(g.Conditional) > 0 {
|
if len(g.Conditional) > 0 {
|
||||||
@ -282,8 +278,8 @@ func Run(g *Generator) {
|
|||||||
for _, outputPackage := range outputPackages {
|
for _, outputPackage := range outputPackages {
|
||||||
p := outputPackage.(*protobufPackage)
|
p := outputPackage.(*protobufPackage)
|
||||||
|
|
||||||
path := filepath.Join(g.OutputBase, p.ImportPath())
|
path := filepath.Join(g.OutputDir, p.ImportPath())
|
||||||
outputPath := filepath.Join(g.OutputBase, p.OutputPath())
|
outputPath := filepath.Join(g.OutputDir, p.OutputPath())
|
||||||
|
|
||||||
// generate the gogoprotobuf protoc
|
// generate the gogoprotobuf protoc
|
||||||
cmd := exec.Command("protoc", append(args, path)...)
|
cmd := exec.Command("protoc", append(args, path)...)
|
||||||
@ -349,7 +345,7 @@ func Run(g *Generator) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
pattern := filepath.Join(g.OutputBase, p.Path(), "*.go")
|
pattern := filepath.Join(g.OutputDir, p.Path(), "*.go")
|
||||||
files, err := filepath.Glob(pattern)
|
files, err := filepath.Glob(pattern)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Can't glob pattern %q: %v", pattern, err)
|
log.Fatalf("Can't glob pattern %q: %v", pattern, err)
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
// CustomArgs is used by the gengo framework to pass args specific to this generator.
|
// CustomArgs is used by the gengo framework to pass args specific to this generator.
|
||||||
type CustomArgs struct {
|
type CustomArgs struct {
|
||||||
|
OutputDir string // must be a directory path
|
||||||
OutputPackage string // must be a Go import-path
|
OutputPackage string // must be a Go import-path
|
||||||
VersionedClientSetPackage string // must be a Go import-path
|
VersionedClientSetPackage string // must be a Go import-path
|
||||||
InternalClientSetPackage string // must be a Go import-path
|
InternalClientSetPackage string // must be a Go import-path
|
||||||
@ -50,7 +51,10 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
|
|||||||
|
|
||||||
// AddFlags add the generator flags to the flag set.
|
// AddFlags add the generator flags to the flag set.
|
||||||
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
||||||
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage, "the Go import-path of the generated results")
|
fs.StringVar(&ca.OutputDir, "output-dir", "",
|
||||||
|
"the base directory under which to generate results")
|
||||||
|
fs.StringVar(&ca.OutputPackage, "output-package", ca.OutputPackage,
|
||||||
|
"the Go import-path of the generated results")
|
||||||
fs.StringVar(&ca.InternalClientSetPackage, "internal-clientset-package", ca.InternalClientSetPackage, "the Go import-path of the internal clientset to use")
|
fs.StringVar(&ca.InternalClientSetPackage, "internal-clientset-package", ca.InternalClientSetPackage, "the Go import-path of the internal clientset to use")
|
||||||
fs.StringVar(&ca.VersionedClientSetPackage, "versioned-clientset-package", ca.VersionedClientSetPackage, "the Go import-path of the versioned clientset to use")
|
fs.StringVar(&ca.VersionedClientSetPackage, "versioned-clientset-package", ca.VersionedClientSetPackage, "the Go import-path of the versioned clientset to use")
|
||||||
fs.StringVar(&ca.ListersPackage, "listers-package", ca.ListersPackage, "the Go import-path of the listers to use")
|
fs.StringVar(&ca.ListersPackage, "listers-package", ca.ListersPackage, "the Go import-path of the listers to use")
|
||||||
@ -60,12 +64,11 @@ func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
|||||||
|
|
||||||
// Validate checks the given arguments.
|
// Validate checks the given arguments.
|
||||||
func Validate(genericArgs *args.GeneratorArgs) error {
|
func Validate(genericArgs *args.GeneratorArgs) error {
|
||||||
if len(genericArgs.OutputBase) == 0 {
|
|
||||||
return fmt.Errorf("--output-base must be specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
customArgs := genericArgs.CustomArgs.(*CustomArgs)
|
||||||
|
|
||||||
|
if len(customArgs.OutputDir) == 0 {
|
||||||
|
return fmt.Errorf("--output-dir must be specified")
|
||||||
|
}
|
||||||
if len(customArgs.OutputPackage) == 0 {
|
if len(customArgs.OutputPackage) == 0 {
|
||||||
return fmt.Errorf("--output-package must be specified")
|
return fmt.Errorf("--output-package must be specified")
|
||||||
}
|
}
|
||||||
|
@ -101,9 +101,9 @@ func GetTargets(context *generator.Context, arguments *args.GeneratorArgs) []gen
|
|||||||
|
|
||||||
customArgs := arguments.CustomArgs.(*informergenargs.CustomArgs)
|
customArgs := arguments.CustomArgs.(*informergenargs.CustomArgs)
|
||||||
|
|
||||||
internalVersionOutputDir := arguments.OutputBase
|
internalVersionOutputDir := customArgs.OutputDir
|
||||||
internalVersionOutputPkg := customArgs.OutputPackage
|
internalVersionOutputPkg := customArgs.OutputPackage
|
||||||
externalVersionOutputDir := arguments.OutputBase
|
externalVersionOutputDir := customArgs.OutputDir
|
||||||
externalVersionOutputPkg := customArgs.OutputPackage
|
externalVersionOutputPkg := customArgs.OutputPackage
|
||||||
if !customArgs.SingleDirectory {
|
if !customArgs.SingleDirectory {
|
||||||
internalVersionOutputDir = filepath.Join(internalVersionOutputDir, "internalversion")
|
internalVersionOutputDir = filepath.Join(internalVersionOutputDir, "internalversion")
|
||||||
|
@ -25,6 +25,7 @@ import (
|
|||||||
|
|
||||||
// CustomArgs is used by the gengo framework to pass args specific to this generator.
|
// CustomArgs is used by the gengo framework to pass args specific to this generator.
|
||||||
type CustomArgs struct {
|
type CustomArgs struct {
|
||||||
|
OutputDir string // must be a directory path
|
||||||
OutputPackage string // must be a Go import-path
|
OutputPackage string // must be a Go import-path
|
||||||
|
|
||||||
// PluralExceptions specify list of exceptions used when pluralizing certain types.
|
// PluralExceptions specify list of exceptions used when pluralizing certain types.
|
||||||
@ -45,6 +46,8 @@ func NewDefaults() (*args.GeneratorArgs, *CustomArgs) {
|
|||||||
|
|
||||||
// AddFlags add the generator flags to the flag set.
|
// AddFlags add the generator flags to the flag set.
|
||||||
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
||||||
|
fs.StringVar(&ca.OutputDir, "output-dir", "",
|
||||||
|
"the base directory under which to generate results")
|
||||||
fs.StringVar(&ca.OutputPackage, "output-package", "",
|
fs.StringVar(&ca.OutputPackage, "output-package", "",
|
||||||
"the base Go import-path under which to generate results")
|
"the base Go import-path under which to generate results")
|
||||||
fs.StringSliceVar(&ca.PluralExceptions, "plural-exceptions", ca.PluralExceptions,
|
fs.StringSliceVar(&ca.PluralExceptions, "plural-exceptions", ca.PluralExceptions,
|
||||||
@ -53,12 +56,11 @@ func (ca *CustomArgs) AddFlags(fs *pflag.FlagSet) {
|
|||||||
|
|
||||||
// Validate checks the given arguments.
|
// Validate checks the given arguments.
|
||||||
func Validate(genericArgs *args.GeneratorArgs) error {
|
func Validate(genericArgs *args.GeneratorArgs) error {
|
||||||
if len(genericArgs.OutputBase) == 0 {
|
|
||||||
return fmt.Errorf("--output-base must be specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
custom := genericArgs.CustomArgs.(*CustomArgs)
|
custom := genericArgs.CustomArgs.(*CustomArgs)
|
||||||
|
|
||||||
|
if len(custom.OutputDir) == 0 {
|
||||||
|
return fmt.Errorf("--output-dir must be specified")
|
||||||
|
}
|
||||||
if len(custom.OutputPackage) == 0 {
|
if len(custom.OutputPackage) == 0 {
|
||||||
return fmt.Errorf("--output-package must be specified")
|
return fmt.Errorf("--output-package must be specified")
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func GetTargets(context *generator.Context, arguments *args.GeneratorArgs) []gen
|
|||||||
typesToGenerate = orderer.OrderTypes(typesToGenerate)
|
typesToGenerate = orderer.OrderTypes(typesToGenerate)
|
||||||
|
|
||||||
subdir := filepath.Join(groupPackageName, strings.ToLower(gv.Version.NonEmpty()))
|
subdir := filepath.Join(groupPackageName, strings.ToLower(gv.Version.NonEmpty()))
|
||||||
outputDir := filepath.Join(arguments.OutputBase, subdir)
|
outputDir := filepath.Join(customArgs.OutputDir, subdir)
|
||||||
outputPkg := filepath.Join(customArgs.OutputPackage, subdir)
|
outputPkg := filepath.Join(customArgs.OutputPackage, subdir)
|
||||||
targetList = append(targetList, &generator.SimpleTarget{
|
targetList = append(targetList, &generator.SimpleTarget{
|
||||||
PkgName: strings.ToLower(gv.Version.NonEmpty()),
|
PkgName: strings.ToLower(gv.Version.NonEmpty()),
|
||||||
|
@ -375,7 +375,7 @@ function kube::codegen::gen_openapi() {
|
|||||||
-v "${v}" \
|
-v "${v}" \
|
||||||
--output-file-base zz_generated.openapi.go \
|
--output-file-base zz_generated.openapi.go \
|
||||||
--go-header-file "${boilerplate}" \
|
--go-header-file "${boilerplate}" \
|
||||||
--output-base "${out_dir}" \
|
--output-dir "${out_dir}" \
|
||||||
--output-package "${out_pkg}" \
|
--output-package "${out_pkg}" \
|
||||||
--report-filename "${new_report}" \
|
--report-filename "${new_report}" \
|
||||||
--input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1" \
|
--input-dirs "k8s.io/apimachinery/pkg/apis/meta/v1" \
|
||||||
@ -611,7 +611,7 @@ function kube::codegen::gen_client() {
|
|||||||
"${gobin}/applyconfiguration-gen" \
|
"${gobin}/applyconfiguration-gen" \
|
||||||
-v "${v}" \
|
-v "${v}" \
|
||||||
--go-header-file "${boilerplate}" \
|
--go-header-file "${boilerplate}" \
|
||||||
--output-base "${out_dir}/${applyconfig_subdir}" \
|
--output-dir "${out_dir}/${applyconfig_subdir}" \
|
||||||
--output-package "${applyconfig_pkg}" \
|
--output-package "${applyconfig_pkg}" \
|
||||||
--external-applyconfigurations "${applyconfig_external}" \
|
--external-applyconfigurations "${applyconfig_external}" \
|
||||||
"${inputs[@]}"
|
"${inputs[@]}"
|
||||||
@ -633,7 +633,7 @@ function kube::codegen::gen_client() {
|
|||||||
"${gobin}/client-gen" \
|
"${gobin}/client-gen" \
|
||||||
-v "${v}" \
|
-v "${v}" \
|
||||||
--go-header-file "${boilerplate}" \
|
--go-header-file "${boilerplate}" \
|
||||||
--output-base "${out_dir}/${clientset_subdir}" \
|
--output-dir "${out_dir}/${clientset_subdir}" \
|
||||||
--output-package "${out_pkg}/${clientset_subdir}" \
|
--output-package "${out_pkg}/${clientset_subdir}" \
|
||||||
--clientset-name "${clientset_versioned_name}" \
|
--clientset-name "${clientset_versioned_name}" \
|
||||||
--apply-configuration-package "${applyconfig_pkg}" \
|
--apply-configuration-package "${applyconfig_pkg}" \
|
||||||
@ -658,7 +658,7 @@ function kube::codegen::gen_client() {
|
|||||||
"${gobin}/lister-gen" \
|
"${gobin}/lister-gen" \
|
||||||
-v "${v}" \
|
-v "${v}" \
|
||||||
--go-header-file "${boilerplate}" \
|
--go-header-file "${boilerplate}" \
|
||||||
--output-base "${out_dir}/${listers_subdir}" \
|
--output-dir "${out_dir}/${listers_subdir}" \
|
||||||
--output-package "${out_pkg}/${listers_subdir}" \
|
--output-package "${out_pkg}/${listers_subdir}" \
|
||||||
--plural-exceptions "${plural_exceptions}" \
|
--plural-exceptions "${plural_exceptions}" \
|
||||||
"${inputs[@]}"
|
"${inputs[@]}"
|
||||||
@ -679,7 +679,7 @@ function kube::codegen::gen_client() {
|
|||||||
"${gobin}/informer-gen" \
|
"${gobin}/informer-gen" \
|
||||||
-v "${v}" \
|
-v "${v}" \
|
||||||
--go-header-file "${boilerplate}" \
|
--go-header-file "${boilerplate}" \
|
||||||
--output-base "${out_dir}/${informers_subdir}" \
|
--output-dir "${out_dir}/${informers_subdir}" \
|
||||||
--output-package "${out_pkg}/${informers_subdir}" \
|
--output-package "${out_pkg}/${informers_subdir}" \
|
||||||
--versioned-clientset-package "${out_pkg}/${clientset_subdir}/${clientset_versioned_name}" \
|
--versioned-clientset-package "${out_pkg}/${clientset_subdir}/${clientset_versioned_name}" \
|
||||||
--listers-package "${out_pkg}/${listers_subdir}" \
|
--listers-package "${out_pkg}/${listers_subdir}" \
|
||||||
|
Loading…
Reference in New Issue
Block a user