diff --git a/cns/middlewares/SFSwiftV2.go b/cns/middlewares/SFSwiftV2.go index ef313f61bb..abc2613f85 100644 --- a/cns/middlewares/SFSwiftV2.go +++ b/cns/middlewares/SFSwiftV2.go @@ -3,9 +3,8 @@ package middlewares import ( "context" - "github.com/Azure/azure-container-networking/cns/configuration" - "github.com/Azure/azure-container-networking/cns" + "github.com/Azure/azure-container-networking/cns/configuration" "github.com/Azure/azure-container-networking/cns/types" "github.com/pkg/errors" ) diff --git a/cns/middlewares/k8sSwiftV2.go b/cns/middlewares/k8sSwiftV2.go index 5e6e1775be..3336769b7e 100644 --- a/cns/middlewares/k8sSwiftV2.go +++ b/cns/middlewares/k8sSwiftV2.go @@ -284,5 +284,5 @@ func (m *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error { } func (m *K8sSWIFTv2Middleware) GetMiddlewareType() configuration.SWIFTV2Mode { - return configuration.SFSWIFTV2 + return configuration.K8sSWIFTV2 } diff --git a/cns/restserver/ipam.go b/cns/restserver/ipam.go index 56bf324eea..94b20d5647 100644 --- a/cns/restserver/ipam.go +++ b/cns/restserver/ipam.go @@ -280,11 +280,13 @@ func (service *HTTPRestService) requestIPConfigsHandler(w http.ResponseWriter, r if service.IPConfigsHandlerMiddleware != nil { // Wrap the default datapath handlers with the middleware depending on middleware type var wrappedHandler cns.IPConfigsHandlerFunc - if service.IPConfigsHandlerMiddleware.GetMiddlewareType() == configuration.K8sSWIFTV2 { + switch service.IPConfigsHandlerMiddleware.GetMiddlewareType() { + case configuration.K8sSWIFTV2: wrappedHandler = service.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(service.requestIPConfigHandlerHelper, service.releaseIPConfigHandlerHelper) - } else if service.IPConfigsHandlerMiddleware.GetMiddlewareType() == configuration.SFSWIFTV2 { - wrappedHandler = service.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(service.requestIPConfigHandlerHelperSF, service.releaseIPConfigHandlerHelper) + case configuration.SFSWIFTV2: + wrappedHandler = service.IPConfigsHandlerMiddleware.IPConfigsRequestHandlerWrapper(service.requestIPConfigHandlerHelperSF, nil) } + ipConfigsResp, err = wrappedHandler(r.Context(), ipconfigsRequest) } else { ipConfigsResp, err = service.requestIPConfigHandlerHelper(r.Context(), ipconfigsRequest) // nolint:contextcheck // appease linter