@@ -60,7 +60,11 @@ func NewCommand(ctx context.Context, newOperatorClient func(*rest.Config) (v1hel
6060 if err := o .validate (); err != nil {
6161 return err
6262 }
63- return o .run (ctx )
63+ operatorClient , err := o .complete ()
64+ if err != nil {
65+ return err
66+ }
67+ return o .run (ctx , operatorClient )
6468 },
6569 }
6670 o .addFlags (cmd .Flags ())
@@ -80,10 +84,15 @@ func (o *options) validate() error {
8084 if len (o .KMSSockets ) == 0 {
8185 return fmt .Errorf ("--kms-sockets is required, at least one" )
8286 }
87+ socketSet := make (map [string ]struct {}, len (o .KMSSockets ))
8388 for _ , s := range o .KMSSockets {
8489 if ! kmsSocketPattern .MatchString (s ) {
8590 return fmt .Errorf ("--kms-sockets entry %q must match %s" , s , kmsSocketPattern )
8691 }
92+ if _ , ok := socketSet [s ]; ok {
93+ return fmt .Errorf ("--kms-sockets entry %q is duplicated" , s )
94+ }
95+ socketSet [s ] = struct {}{}
8796 }
8897
8998 if o .Interval <= 0 {
@@ -102,20 +111,25 @@ func (o *options) validate() error {
102111 return nil
103112}
104113
105- func (o * options ) run (ctx context.Context ) error {
106- ctx = setupSignalContext (ctx )
107-
114+ func (o * options ) complete () (v1helpers.OperatorClient , error ) {
108115 // Empty kubeconfig falls back to the in-cluster config (service account
109116 // token + KUBERNETES_SERVICE_HOST), which is the deployed path.
110117 cfg , err := clientcmd .BuildConfigFromFlags ("" , o .Kubeconfig )
111118 if err != nil {
112- return fmt .Errorf ("build rest config: %w" , err )
119+ return nil , fmt .Errorf ("build rest config: %w" , err )
113120 }
114121
115- if _ , err := o .newOperatorClient (cfg ); err != nil {
116- return fmt .Errorf ("build operator client: %w" , err )
122+ operatorClient , err := o .newOperatorClient (cfg )
123+ if err != nil {
124+ return nil , fmt .Errorf ("build operator client: %w" , err )
117125 }
118126
127+ return operatorClient , nil
128+ }
129+
130+ func (o * options ) run (ctx context.Context , operatorClient v1helpers.OperatorClient ) error {
131+ ctx = setupSignalContext (ctx )
132+
119133 plugins , err := buildPlugins (ctx , o .KMSSockets , o .ReadTimeout )
120134 if err != nil {
121135 return err
@@ -128,7 +142,8 @@ func (o *options) run(ctx context.Context) error {
128142 // Each Status RPC enforces o.ReadTimeout internally (set at dial time);
129143 // ctx here only carries shutdown cancellation.
130144 conditions := prober .probeAll (ctx )
131- // TODO: hand conditions to the writer once it lands; logging is a placeholder.
145+ // TODO: hand conditions to the writer (via operatorClient) once it lands;
146+ // logging is a placeholder.
132147 klog .InfoS ("kms plugin health" , "conditions" , conditions )
133148 }, o .Interval , 0.1 , false )
134149
0 commit comments