1
0
mirror of https://github.com/kubernetes-sigs/descheduler.git synced 2026-01-28 06:29:29 +01:00
Files
descheduler/vendor/k8s.io/code-generator/cmd/deepcopy-gen/args/args.go
2024-05-14 14:17:34 -04:00

53 lines
1.6 KiB
Go
Vendored

/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package args
import (
"fmt"
"github.com/spf13/pflag"
)
type Args struct {
OutputFile string
BoundingDirs []string // Only deal with types rooted under these dirs.
GoHeaderFile string
}
// New returns default arguments for the generator.
func New() *Args {
return &Args{}
}
// AddFlags add the generator flags to the flag set.
func (args *Args) AddFlags(fs *pflag.FlagSet) {
fs.StringVar(&args.OutputFile, "output-file", "generated.deepcopy.go",
"the name of the file to be generated")
fs.StringSliceVar(&args.BoundingDirs, "bounding-dirs", args.BoundingDirs,
"Comma-separated list of import paths which bound the types for which deep-copies will be generated.")
fs.StringVar(&args.GoHeaderFile, "go-header-file", "",
"the path to a file containing boilerplate header text; the string \"YEAR\" will be replaced with the current 4-digit year")
}
// Validate checks the given arguments.
func (args *Args) Validate() error {
if len(args.OutputFile) == 0 {
return fmt.Errorf("--output-file must be specified")
}
return nil
}