ronething commented on code in PR #2460: URL: https://github.com/apache/apisix-ingress-controller/pull/2460#discussion_r2188483680
########## internal/controller/utils/utils.go: ########## @@ -0,0 +1,57 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package controller Review Comment: package name can be `utils`? ########## internal/provider/adc/adc.go: ########## @@ -404,3 +415,150 @@ func prepareSyncFile(resources any) (string, func(), error) { return tmpFile.Name(), cleanup, nil } + +func (d *adcClient) handlerADCExecutionErrors(statusesMap map[string]types.ADCExecutionErrors) { + statusUpdateMap := d.resolveADCExecutionErrors(statusesMap) + d.handlerStatusUpdate(statusUpdateMap) +} + +func (d *adcClient) handlerStatusUpdate(statusUpdateMap map[types.NamespacedNameKind][]string) { + for nnk, msgs := range statusUpdateMap { + d.updateStatus(nnk, cutils.NewConditionTypeAccepted( + apiv2.ConditionReasonSyncFailed, + false, + 0, + strings.Join(msgs, "; "), + )) + } + + for nnk := range d.statusUpdateMap { + if _, ok := statusUpdateMap[nnk]; !ok { + d.updateStatus(nnk, cutils.NewConditionTypeAccepted( + apiv2.ConditionReasonAccepted, + true, + 0, + "", + )) + } + } + d.statusUpdateMap = statusUpdateMap +} + +func (d *adcClient) resolveADCExecutionErrors(statusesMap map[string]types.ADCExecutionErrors) map[types.NamespacedNameKind][]string { + statusUpdateMap := map[types.NamespacedNameKind][]string{} + for configName, execErrors := range statusesMap { + log.Warnw("sync failed", zap.String("configName", configName), zap.Any("statuses", execErrors)) + for _, execErr := range execErrors.Errors { + for _, failedStatus := range execErr.FailedErrors { Review Comment: Can multi-layer nesting be deconstructed? ########## internal/provider/adc/adc.go: ########## @@ -404,3 +415,150 @@ func prepareSyncFile(resources any) (string, func(), error) { return tmpFile.Name(), cleanup, nil } + +func (d *adcClient) handlerADCExecutionErrors(statusesMap map[string]types.ADCExecutionErrors) { Review Comment: ```suggestion func (d *adcClient) handleADCExecutionErrors(statusesMap map[string]types.ADCExecutionErrors) { ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org