@@ -32,7 +32,7 @@ import (
3232 networkingv1 "k8s.io/api/networking/v1"
3333 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3434 "k8s.io/apimachinery/pkg/runtime"
35- "k8s.io/apimachinery/pkg/types"
35+ k8stypes "k8s.io/apimachinery/pkg/types"
3636 ctrl "sigs.k8s.io/controller-runtime"
3737 "sigs.k8s.io/controller-runtime/pkg/builder"
3838 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -45,6 +45,7 @@ import (
4545 "github.com/apache/apisix-ingress-controller/internal/controller/indexer"
4646 "github.com/apache/apisix-ingress-controller/internal/controller/status"
4747 "github.com/apache/apisix-ingress-controller/internal/provider"
48+ "github.com/apache/apisix-ingress-controller/internal/types"
4849 "github.com/apache/apisix-ingress-controller/internal/utils"
4950 pkgutils "github.com/apache/apisix-ingress-controller/pkg/utils"
5051)
@@ -134,7 +135,7 @@ func (r *ApisixRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
134135 return ctrl.Result {}, err
135136 }
136137 if err = r .Provider .Update (ctx , tctx , & ar ); err != nil {
137- err = ReasonError {
138+ err = types. ReasonError {
138139 Reason : string (apiv2 .ConditionReasonSyncFailed ),
139140 Message : err .Error (),
140141 }
@@ -152,7 +153,7 @@ func (r *ApisixRouteReconciler) processApisixRoute(ctx context.Context, tc *prov
152153 for httpIndex , http := range in .Spec .HTTP {
153154 // check rule names
154155 if _ , ok := rules [http .Name ]; ok {
155- return ReasonError {
156+ return types. ReasonError {
156157 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
157158 Message : "duplicate route rule name" ,
158159 }
@@ -178,15 +179,15 @@ func (r *ApisixRouteReconciler) processApisixRoute(ctx context.Context, tc *prov
178179
179180 // check vars
180181 if _ , err := http .Match .NginxVars .ToVars (); err != nil {
181- return ReasonError {
182+ return types. ReasonError {
182183 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
183184 Message : fmt .Sprintf (".spec.http[%d].match.exprs: %s" , httpIndex , err .Error ()),
184185 }
185186 }
186187
187188 // validate remote address
188189 if err := utils .ValidateRemoteAddrs (http .Match .RemoteAddrs ); err != nil {
189- return ReasonError {
190+ return types. ReasonError {
190191 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
191192 Message : fmt .Sprintf (".spec.http[%d].match.remoteAddrs: %s" , httpIndex , err .Error ()),
192193 }
@@ -220,7 +221,7 @@ func (r *ApisixRouteReconciler) validatePluginConfig(ctx context.Context, tc *pr
220221 pcNN = utils .NamespacedName (& pc )
221222 )
222223 if err := r .Get (ctx , pcNN , & pc ); err != nil {
223- return ReasonError {
224+ return types. ReasonError {
224225 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
225226 Message : fmt .Sprintf ("failed to get ApisixPluginConfig: %s" , pcNN ),
226227 }
@@ -230,13 +231,13 @@ func (r *ApisixRouteReconciler) validatePluginConfig(ctx context.Context, tc *pr
230231 if in .Spec .IngressClassName != pc .Spec .IngressClassName && pc .Spec .IngressClassName != "" {
231232 var pcIC networkingv1.IngressClass
232233 if err := r .Get (ctx , client.ObjectKey {Name : pc .Spec .IngressClassName }, & pcIC ); err != nil {
233- return ReasonError {
234+ return types. ReasonError {
234235 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
235236 Message : fmt .Sprintf ("failed to get IngressClass %s for ApisixPluginConfig %s: %v" , pc .Spec .IngressClassName , pcNN , err ),
236237 }
237238 }
238239 if ! matchesController (pcIC .Spec .Controller ) {
239- return ReasonError {
240+ return types. ReasonError {
240241 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
241242 Message : fmt .Sprintf ("ApisixPluginConfig %s references IngressClass %s with non-matching controller" , pcNN , pc .Spec .IngressClassName ),
242243 }
@@ -271,7 +272,7 @@ func (r *ApisixRouteReconciler) validateSecrets(ctx context.Context, tc *provide
271272 secretNN = utils .NamespacedName (& secret )
272273 )
273274 if err := r .Get (ctx , secretNN , & secret ); err != nil {
274- return ReasonError {
275+ return types. ReasonError {
275276 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
276277 Message : fmt .Sprintf ("failed to get Secret: %s" , secretNN ),
277278 }
@@ -282,18 +283,18 @@ func (r *ApisixRouteReconciler) validateSecrets(ctx context.Context, tc *provide
282283}
283284
284285func (r * ApisixRouteReconciler ) validateBackends (ctx context.Context , tc * provider.TranslateContext , in * apiv2.ApisixRoute , http apiv2.ApisixRouteHTTP ) error {
285- var backends = make (map [types .NamespacedName ]struct {})
286+ var backends = make (map [k8stypes .NamespacedName ]struct {})
286287 for _ , backend := range http .Backends {
287288 var (
288289 au apiv2.ApisixUpstream
289290 service corev1.Service
290- serviceNN = types .NamespacedName {
291+ serviceNN = k8stypes .NamespacedName {
291292 Namespace : in .GetNamespace (),
292293 Name : backend .ServiceName ,
293294 }
294295 )
295296 if _ , ok := backends [serviceNN ]; ok {
296- return ReasonError {
297+ return types. ReasonError {
297298 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
298299 Message : fmt .Sprintf ("duplicate backend service: %s" , serviceNN ),
299300 }
@@ -344,7 +345,7 @@ func (r *ApisixRouteReconciler) validateBackends(ctx context.Context, tc *provid
344345 discoveryv1 .LabelServiceName : service .Name ,
345346 },
346347 ); err != nil {
347- return ReasonError {
348+ return types. ReasonError {
348349 Reason : string (apiv2 .ConditionReasonInvalidSpec ),
349350 Message : fmt .Sprintf ("failed to list endpoint slices: %v" , err ),
350351 }
@@ -366,7 +367,7 @@ func (r *ApisixRouteReconciler) validateUpstreams(ctx context.Context, tc *provi
366367 }
367368 var (
368369 ups apiv2.ApisixUpstream
369- upsNN = types .NamespacedName {
370+ upsNN = k8stypes .NamespacedName {
370371 Namespace : ar .GetNamespace (),
371372 Name : upstream .Name ,
372373 }
@@ -384,7 +385,7 @@ func (r *ApisixRouteReconciler) validateUpstreams(ctx context.Context, tc *provi
384385 if node .Type == apiv2 .ExternalTypeService {
385386 var (
386387 service corev1.Service
387- serviceNN = types .NamespacedName {Namespace : ups .GetNamespace (), Name : node .Name }
388+ serviceNN = k8stypes .NamespacedName {Namespace : ups .GetNamespace (), Name : node .Name }
388389 )
389390 if err := r .Get (ctx , serviceNN , & service ); err != nil {
390391 r .Log .Error (err , "failed to get service in ApisixUpstream" , "ApisixUpstream" , upsNN , "Service" , serviceNN )
@@ -400,7 +401,7 @@ func (r *ApisixRouteReconciler) validateUpstreams(ctx context.Context, tc *provi
400401 if ups .Spec .TLSSecret != nil && ups .Spec .TLSSecret .Name != "" {
401402 var (
402403 secret corev1.Secret
403- secretNN = types .NamespacedName {Namespace : cmp .Or (ups .Spec .TLSSecret .Namespace , ar .GetNamespace ()), Name : ups .Spec .TLSSecret .Name }
404+ secretNN = k8stypes .NamespacedName {Namespace : cmp .Or (ups .Spec .TLSSecret .Namespace , ar .GetNamespace ()), Name : ups .Spec .TLSSecret .Name }
404405 )
405406 if err := r .Get (ctx , secretNN , & secret ); err != nil {
406407 r .Log .Error (err , "failed to get secret in ApisixUpstream" , "ApisixUpstream" , upsNN , "Secret" , secretNN )
@@ -578,7 +579,7 @@ func (r *ApisixRouteReconciler) listApisixRoutesForPluginConfig(ctx context.Cont
578579 return pkgutils .DedupComparable (requests )
579580}
580581
581- func (r * ApisixRouteReconciler ) getSubsetLabels (tctx * provider.TranslateContext , auNN types .NamespacedName , backend apiv2.ApisixRouteHTTPBackend ) map [string ]string {
582+ func (r * ApisixRouteReconciler ) getSubsetLabels (tctx * provider.TranslateContext , auNN k8stypes .NamespacedName , backend apiv2.ApisixRouteHTTPBackend ) map [string ]string {
582583 if backend .Subset == "" {
583584 return nil
584585 }
@@ -621,7 +622,7 @@ func (r *ApisixRouteReconciler) filterEndpointSliceByTargetPod(ctx context.Conte
621622
622623 var (
623624 pod corev1.Pod
624- podNN = types .NamespacedName {
625+ podNN = k8stypes .NamespacedName {
625626 Namespace : v .TargetRef .Namespace ,
626627 Name : v .TargetRef .Name ,
627628 }
0 commit comments