@@ -174,6 +174,43 @@ func (c *Client) DeleteConfig(ctx context.Context, args Task) error {
174174 return err
175175}
176176
177+ func (c * Client ) Validate (ctx context.Context , task Task ) error {
178+ if len (task .Configs ) == 0 || task .Resources == nil {
179+ return nil
180+ }
181+
182+ fileIOStart := time .Now ()
183+ syncFilePath , cleanup , err := prepareSyncFile (task .Resources )
184+ if err != nil {
185+ pkgmetrics .RecordFileIODuration ("prepare_sync_file" , "failure" , time .Since (fileIOStart ).Seconds ())
186+ return err
187+ }
188+ pkgmetrics .RecordFileIODuration ("prepare_sync_file" , adctypes .StatusSuccess , time .Since (fileIOStart ).Seconds ())
189+ defer cleanup ()
190+
191+ args := BuildADCExecuteArgs (syncFilePath , task .Labels , task .ResourceTypes )
192+
193+ var errs types.ADCValidationErrors
194+ for _ , config := range task .Configs {
195+ if config .BackendType == "" {
196+ config .BackendType = c .defaultMode
197+ }
198+ if err := c .executor .Validate (ctx , config , args ); err != nil {
199+ var validationErr types.ADCValidationError
200+ if errors .As (err , & validationErr ) {
201+ errs .Errors = append (errs .Errors , validationErr )
202+ continue
203+ }
204+ return err
205+ }
206+ }
207+
208+ if len (errs .Errors ) > 0 {
209+ return errs
210+ }
211+ return nil
212+ }
213+
177214func (c * Client ) Sync (ctx context.Context ) (map [string ]types.ADCExecutionErrors , error ) {
178215 c .syncMu .Lock ()
179216 defer c .syncMu .Unlock ()
0 commit comments