Skip to content

Commit 2d5dbd9

Browse files
committed
fix test
1 parent b8dfa61 commit 2d5dbd9

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

internal/provider/adc/adc.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,13 @@ func (d *adcClient) Update(ctx context.Context, tctx *provider.TranslateContext,
122122
return err
123123
}
124124
for _, config := range deleteConfigs {
125-
d.store.Delete(config.Name, resourceTypes, label.GenLabel(obj))
125+
if err := d.store.Delete(config.Name, resourceTypes, label.GenLabel(obj)); err != nil {
126+
log.Errorw("failed to delete resources from store",
127+
zap.String("name", config.Name),
128+
zap.Error(err),
129+
)
130+
return err
131+
}
126132
}
127133
}
128134

@@ -185,9 +191,17 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
185191
defer d.deleteConfigs(rk)
186192

187193
for _, config := range configs {
188-
d.store.Delete(config.Name, resourceTypes, labels)
194+
if err := d.store.Delete(config.Name, resourceTypes, labels); err != nil {
195+
log.Errorw("failed to delete resources from store",
196+
zap.String("name", config.Name),
197+
zap.Error(err),
198+
)
199+
return err
200+
}
189201
}
190202

203+
log.Debugw("successfully deleted resources from store", zap.Any("object", obj))
204+
191205
err := d.sync(ctx, Task{
192206
Name: obj.GetName(),
193207
Labels: labels,

internal/provider/adc/cache/memdb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ package cache
1818
import (
1919
"errors"
2020

21+
"github.com/api7/gopkg/pkg/log"
2122
"github.com/hashicorp/go-memdb"
2223
"go.uber.org/zap"
2324

2425
types "github.com/api7/api7-ingress-controller/api/adc"
25-
"github.com/api7/gopkg/pkg/log"
2626
)
2727

2828
var (

internal/provider/adc/store.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ package adc
33
import (
44
"sync"
55

6+
"github.com/api7/gopkg/pkg/log"
7+
68
adctypes "github.com/api7/api7-ingress-controller/api/adc"
79
label "github.com/api7/api7-ingress-controller/internal/controller/label"
810
"github.com/api7/api7-ingress-controller/internal/provider/adc/cache"
9-
"github.com/api7/gopkg/pkg/log"
1011
)
1112

1213
type Store struct {

internal/provider/adc/translator/gateway.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ func (t *Translator) TranslateGateway(tctx *provider.TranslateContext, obj *gate
4343
return result, nil
4444
}
4545

46-
globalRules := adctypes.GlobalRule{}
47-
pluginMetadata := adctypes.PluginMetadata{}
46+
globalRules := adctypes.GlobalRule{
47+
Plugins: make(adctypes.Plugins),
48+
}
49+
pluginMetadata := adctypes.PluginMetadata{
50+
Plugins: make(adctypes.Plugins),
51+
}
4852
// apply plugins from GatewayProxy to global rules
4953
t.fillPluginsFromGatewayProxy(globalRules, &gatewayProxy)
5054
t.fillPluginMetadataFromGatewayProxy(pluginMetadata, &gatewayProxy)

internal/provider/adc/translator/ingressclass.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ func (t *Translator) TranslateIngressClass(tctx *provider.TranslateContext, obj
2323
return result, nil
2424
}
2525

26-
globalRules := adctypes.GlobalRule{}
27-
pluginMetadata := adctypes.PluginMetadata{}
26+
globalRules := adctypes.GlobalRule{
27+
Plugins: make(adctypes.Plugins),
28+
}
29+
pluginMetadata := adctypes.PluginMetadata{
30+
Plugins: make(adctypes.Plugins),
31+
}
2832
// apply plugins from GatewayProxy to global rules
2933
t.fillPluginsFromGatewayProxy(globalRules, &gatewayProxy)
3034
t.fillPluginMetadataFromGatewayProxy(pluginMetadata, &gatewayProxy)

0 commit comments

Comments
 (0)