@@ -44,25 +44,25 @@ const (
4444)
4545
4646type ADCExecutor interface {
47- Execute (ctx context.Context , mode string , config adctypes.Config , args []string ) error
47+ Execute (ctx context.Context , config adctypes.Config , args []string ) error
4848}
4949
5050type DefaultADCExecutor struct {
5151 sync.Mutex
5252 log logr.Logger
5353}
5454
55- func (e * DefaultADCExecutor ) Execute (ctx context.Context , mode string , config adctypes.Config , args []string ) error {
56- return e .runADC (ctx , mode , config , args )
55+ func (e * DefaultADCExecutor ) Execute (ctx context.Context , config adctypes.Config , args []string ) error {
56+ return e .runADC (ctx , config , args )
5757}
5858
59- func (e * DefaultADCExecutor ) runADC (ctx context.Context , mode string , config adctypes.Config , args []string ) error {
59+ func (e * DefaultADCExecutor ) runADC (ctx context.Context , config adctypes.Config , args []string ) error {
6060 var execErrs = types.ADCExecutionError {
6161 Name : config .Name ,
6262 }
6363
6464 for _ , addr := range config .ServerAddrs {
65- if err := e .runForSingleServerWithTimeout (ctx , addr , mode , config , args ); err != nil {
65+ if err := e .runForSingleServerWithTimeout (ctx , addr , config , args ); err != nil {
6666 e .log .Error (err , "failed to run adc for server" , "server" , addr )
6767 var execErr types.ADCExecutionServerAddrError
6868 if errors .As (err , & execErr ) {
@@ -81,21 +81,21 @@ func (e *DefaultADCExecutor) runADC(ctx context.Context, mode string, config adc
8181 return nil
8282}
8383
84- func (e * DefaultADCExecutor ) runForSingleServerWithTimeout (ctx context.Context , serverAddr , mode string , config adctypes.Config , args []string ) error {
84+ func (e * DefaultADCExecutor ) runForSingleServerWithTimeout (ctx context.Context , serverAddr string , config adctypes.Config , args []string ) error {
8585 ctx , cancel := context .WithTimeout (ctx , 15 * time .Second )
8686 defer cancel ()
87- return e .runForSingleServer (ctx , serverAddr , mode , config , args )
87+ return e .runForSingleServer (ctx , serverAddr , config , args )
8888}
8989
90- func (e * DefaultADCExecutor ) runForSingleServer (ctx context.Context , serverAddr , mode string , config adctypes.Config , args []string ) error {
90+ func (e * DefaultADCExecutor ) runForSingleServer (ctx context.Context , serverAddr string , config adctypes.Config , args []string ) error {
9191 cmdArgs := append ([]string {}, args ... )
9292 if ! config .TlsVerify {
9393 cmdArgs = append (cmdArgs , "--tls-skip-verify" )
9494 }
9595
9696 cmdArgs = append (cmdArgs , "--timeout" , "15s" )
9797
98- env := e .prepareEnv (serverAddr , mode , config .Token )
98+ env := e .prepareEnv (serverAddr , config . BackendType , config .Token )
9999
100100 var stdout , stderr bytes.Buffer
101101 cmd := exec .CommandContext (ctx , "adc" , cmdArgs ... )
@@ -250,26 +250,26 @@ func NewHTTPADCExecutor(log logr.Logger, serverURL string, timeout time.Duration
250250}
251251
252252// Execute implements the ADCExecutor interface using HTTP calls
253- func (e * HTTPADCExecutor ) Execute (ctx context.Context , mode string , config adctypes.Config , args []string ) error {
254- return e .runHTTPSync (ctx , mode , config , args )
253+ func (e * HTTPADCExecutor ) Execute (ctx context.Context , config adctypes.Config , args []string ) error {
254+ return e .runHTTPSync (ctx , config , args )
255255}
256256
257257// runHTTPSync performs HTTP sync to ADC Server for each server address
258- func (e * HTTPADCExecutor ) runHTTPSync (ctx context.Context , mode string , config adctypes.Config , args []string ) error {
258+ func (e * HTTPADCExecutor ) runHTTPSync (ctx context.Context , config adctypes.Config , args []string ) error {
259259 var execErrs = types.ADCExecutionError {
260260 Name : config .Name ,
261261 }
262262
263263 serverAddrs := func () []string {
264- if mode == "apisix-standalone" {
264+ if config . BackendType == "apisix-standalone" {
265265 return []string {strings .Join (config .ServerAddrs , "," )}
266266 }
267267 return config .ServerAddrs
268268 }()
269- e .log .V (1 ).Info ("running http sync" , "serverAddrs" , serverAddrs , "mode" , mode )
269+ e .log .V (1 ).Info ("running http sync" , "serverAddrs" , serverAddrs )
270270
271271 for _ , addr := range serverAddrs {
272- if err := e .runHTTPSyncForSingleServer (ctx , addr , mode , config , args ); err != nil {
272+ if err := e .runHTTPSyncForSingleServer (ctx , addr , config , args ); err != nil {
273273 e .log .Error (err , "failed to run http sync for server" , "server" , addr )
274274 var execErr types.ADCExecutionServerAddrError
275275 if errors .As (err , & execErr ) {
@@ -289,7 +289,7 @@ func (e *HTTPADCExecutor) runHTTPSync(ctx context.Context, mode string, config a
289289}
290290
291291// runHTTPSyncForSingleServer performs HTTP sync to a single ADC Server
292- func (e * HTTPADCExecutor ) runHTTPSyncForSingleServer (ctx context.Context , serverAddr , mode string , config adctypes.Config , args []string ) error {
292+ func (e * HTTPADCExecutor ) runHTTPSyncForSingleServer (ctx context.Context , serverAddr string , config adctypes.Config , args []string ) error {
293293 ctx , cancel := context .WithTimeout (ctx , e .httpClient .Timeout )
294294 defer cancel ()
295295
@@ -306,7 +306,7 @@ func (e *HTTPADCExecutor) runHTTPSyncForSingleServer(ctx context.Context, server
306306 }
307307
308308 // Build HTTP request
309- req , err := e .buildHTTPRequest (ctx , serverAddr , mode , config , labels , types , resources )
309+ req , err := e .buildHTTPRequest (ctx , serverAddr , config , labels , types , resources )
310310 if err != nil {
311311 return fmt .Errorf ("failed to build HTTP request: %w" , err )
312312 }
@@ -379,13 +379,13 @@ func (e *HTTPADCExecutor) loadResourcesFromFile(filePath string) (*adctypes.Reso
379379}
380380
381381// buildHTTPRequest builds the HTTP request for ADC Server
382- func (e * HTTPADCExecutor ) buildHTTPRequest (ctx context.Context , serverAddr , mode string , config adctypes.Config , labels map [string ]string , types []string , resources * adctypes.Resources ) (* http.Request , error ) {
382+ func (e * HTTPADCExecutor ) buildHTTPRequest (ctx context.Context , serverAddr string , config adctypes.Config , labels map [string ]string , types []string , resources * adctypes.Resources ) (* http.Request , error ) {
383383 // Prepare request body
384384 tlsVerify := config .TlsVerify
385385 reqBody := ADCServerRequest {
386386 Task : ADCServerTask {
387387 Opts : ADCServerOpts {
388- Backend : mode ,
388+ Backend : config . BackendType ,
389389 Server : strings .Split (serverAddr , "," ),
390390 Token : config .Token ,
391391 LabelSelector : labels ,
@@ -407,7 +407,7 @@ func (e *HTTPADCExecutor) buildHTTPRequest(ctx context.Context, serverAddr, mode
407407 e .log .V (1 ).Info ("sending HTTP request to ADC Server" ,
408408 "url" , e .serverURL + "/sync" ,
409409 "server" , serverAddr ,
410- "mode" , mode ,
410+ "mode" , config . BackendType ,
411411 "cacheKey" , config .Name ,
412412 "labelSelector" , labels ,
413413 "includeResourceType" , types ,
0 commit comments