...
1
16
17 package options
18
19 import (
20 "fmt"
21
22 "github.com/spf13/pflag"
23
24 ephemeralvolumeconfig "k8s.io/kubernetes/pkg/controller/volume/ephemeral/config"
25 )
26
27
28 type EphemeralVolumeControllerOptions struct {
29 *ephemeralvolumeconfig.EphemeralVolumeControllerConfiguration
30 }
31
32
33 func (o *EphemeralVolumeControllerOptions) AddFlags(fs *pflag.FlagSet) {
34 if o == nil {
35 return
36 }
37
38 fs.Int32Var(&o.ConcurrentEphemeralVolumeSyncs, "concurrent-ephemeralvolume-syncs", o.ConcurrentEphemeralVolumeSyncs, "The number of ephemeral volume syncing operations that will be done concurrently. Larger number = faster ephemeral volume updating, but more CPU (and network) load")
39 }
40
41
42 func (o *EphemeralVolumeControllerOptions) ApplyTo(cfg *ephemeralvolumeconfig.EphemeralVolumeControllerConfiguration) error {
43 if o == nil {
44 return nil
45 }
46
47 cfg.ConcurrentEphemeralVolumeSyncs = o.ConcurrentEphemeralVolumeSyncs
48
49 return nil
50 }
51
52
53 func (o *EphemeralVolumeControllerOptions) Validate() []error {
54 if o == nil {
55 return nil
56 }
57
58 errs := []error{}
59 if o.ConcurrentEphemeralVolumeSyncs < 1 {
60 errs = append(errs, fmt.Errorf("concurrent-ephemeralvolume-syncs must be greater than 0, but got %d", o.ConcurrentEphemeralVolumeSyncs))
61 }
62 return errs
63 }
64
View as plain text