Validate options
This commit is contained in:
parent
2c0c8d2e51
commit
3b50fbcd16
18
main.go
18
main.go
|
|
@ -34,6 +34,19 @@ import (
|
|||
"k8s.io/kube-state-metrics/v2/pkg/options"
|
||||
)
|
||||
|
||||
func validate(opts *options.Options) error {
|
||||
shardableResource := "pods"
|
||||
if opts.Nodename == "" {
|
||||
return nil
|
||||
}
|
||||
for _, x := range opts.Resources.AsSlice() {
|
||||
if x != shardableResource {
|
||||
return fmt.Errorf("Resource %s can't be sharding by field selector nodeName", x)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
opts := options.NewOptions()
|
||||
opts.AddFlags()
|
||||
|
|
@ -53,6 +66,11 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if err := validate(opts); err != nil {
|
||||
klog.ErrorS(err, "Validating options error")
|
||||
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
|
||||
}
|
||||
|
||||
var factories []customresource.RegistryFactory
|
||||
if config, set := resolveCustomResourceConfig(opts); set {
|
||||
crf, err := customresourcestate.FromConfig(config)
|
||||
|
|
|
|||
Loading…
Reference in New Issue