Skip to content

Commit f2b6165

Browse files
committed
refactor
1 parent 10d8e94 commit f2b6165

File tree

10 files changed

+20
-43
lines changed

10 files changed

+20
-43
lines changed

internal/adc/client/client.go

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -66,36 +66,6 @@ type Task struct {
6666
Resources *adctypes.Resources
6767
}
6868

69-
func (d *Client) Insert(ctx context.Context, args Task) error {
70-
d.mu.Lock()
71-
defer d.mu.Unlock()
72-
for _, config := range args.Configs {
73-
if err := d.Store.Insert(config.Name, args.ResourceTypes, args.Resources, args.Labels); err != nil {
74-
log.Errorw("failed to insert resources into store",
75-
zap.String("name", config.Name),
76-
zap.Error(err),
77-
)
78-
return err
79-
}
80-
}
81-
return nil
82-
}
83-
84-
func (d *Client) Remove(ctx context.Context, args Task) error {
85-
d.mu.Lock()
86-
defer d.mu.Unlock()
87-
for _, config := range args.Configs {
88-
if err := d.Store.Delete(config.Name, args.ResourceTypes, args.Labels); err != nil {
89-
log.Errorw("failed to delete resources from store",
90-
zap.String("name", config.Name),
91-
zap.Error(err),
92-
)
93-
return err
94-
}
95-
}
96-
return nil
97-
}
98-
9969
func (d *Client) Update(ctx context.Context, args Task) error {
10070
d.mu.Lock()
10171
defer d.mu.Unlock()
@@ -190,6 +160,7 @@ func (d *Client) Delete(ctx context.Context, args Task) error {
190160
return d.sync(ctx, Task{
191161
Labels: args.Labels,
192162
ResourceTypes: args.ResourceTypes,
163+
Configs: configs,
193164
})
194165
}
195166

internal/provider/common/configmanager.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ func (s *ConfigManager[K, T]) SetParentRefs(key K, refs []K) {
4646
s.parentRefs[key] = refs
4747
}
4848

49-
func (s *ConfigManager[K, T]) Get(key K) []T {
49+
func (s *ConfigManager[K, T]) Get(key K) map[K]T {
5050
s.mu.Lock()
5151
defer s.mu.Unlock()
5252

5353
parentRefs := s.parentRefs[key]
54-
configs := make([]T, 0, len(parentRefs))
54+
configs := make(map[K]T, len(parentRefs))
5555
for _, parent := range parentRefs {
5656
if cfg, ok := s.configs[parent]; ok {
57-
configs = append(configs, cfg)
57+
configs[parent] = cfg
5858
}
5959
}
6060
return configs

test/e2e/crds/v1alpha1/consumer.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
. "github.com/onsi/ginkgo/v2"
2525
. "github.com/onsi/gomega"
2626

27+
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2728
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2829
)
2930

@@ -599,7 +600,7 @@ spec:
599600
})
600601

601602
It("Should sync Consumer during startup", func() {
602-
if s.Deployer.Name() == "api7ee" {
603+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
603604
Skip("skipping test in API7EE mode")
604605
}
605606
Expect(s.CreateResourceFromString(consumer2)).NotTo(HaveOccurred(), "creating unused consumer")

test/e2e/crds/v1alpha1/gatewayproxy.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ spec:
132132
`
133133
BeforeEach(func() {
134134
By("create GatewayProxy")
135-
if s.Deployer.Name() == "api7ee" {
135+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
136136
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxySpecAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
137137
} else {
138138
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxySpec, framework.ProviderType, s.AdminKey()))
@@ -161,7 +161,7 @@ spec:
161161

162162
Context("Test GatewayProxy update configs", func() {
163163
It("scaling apisix pods to test that the controller watches endpoints", func() {
164-
if s.Deployer.Name() == "api7ee" {
164+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
165165
Skip("this case only for apisix/apisix-standalone mode")
166166
}
167167

@@ -207,7 +207,7 @@ spec:
207207
keyword string
208208
)
209209

210-
if framework.ProviderType == "api7ee" {
210+
if framework.ProviderType == framework.BackendModeAPI7EE {
211211
keyword = fmt.Sprintf(`{"config.ServerAddrs": ["%s"]}`, s.Deployer.GetAdminEndpoint())
212212
} else {
213213
keyword = fmt.Sprintf(`{"config.ServerAddrs": ["http://%s:9180"]}`, s.GetPodIP(s.Namespace(), "app.kubernetes.io/name=apisix"))

test/e2e/crds/v2/globalrule.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ spec:
8282
Should(Equal(http.StatusOK))
8383
})
8484

85-
It("Test GlobalRule with response-rewrite plugin", func() {
85+
FIt("Test GlobalRule with response-rewrite plugin", func() {
8686
globalRuleYaml := `
8787
apiVersion: apisix.apache.org/v2
8888
kind: ApisixGlobalRule

test/e2e/crds/v2/route.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ spec:
239239
})
240240

241241
It("Test ApisixRoute filterFunc", func() {
242-
if s.Deployer.Name() == "api7ee" {
242+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
243243
Skip("filterFunc is not supported in api7ee")
244244
}
245245
const apisixRouteSpec = `
@@ -726,7 +726,7 @@ spec:
726726
servicePort: 80
727727
`
728728
It("Should sync ApisixRoute during startup", func() {
729-
if s.Deployer.Name() == "api7ee" {
729+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
730730
Skip("skipping test in API7EE mode")
731731
}
732732
By("apply ApisixRoute")

test/e2e/crds/v2/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ spec:
156156
})
157157

158158
It("dataplane unavailable", func() {
159-
if os.Getenv("PROVIDER_TYPE") == "api7ee" {
159+
if os.Getenv("PROVIDER_TYPE") == framework.BackendModeAPI7EE {
160160
Skip("skip for api7ee mode because it use dashboard admin api")
161161
}
162162
By("apply ApisixRoute")

test/e2e/framework/api7_consts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,8 @@ const (
3535
DashboardTLSEndpoint = "https://api7ee3-dashboard.api7-ee-e2e:7443"
3636
DPManagerTLSEndpoint = "https://api7ee3-dp-manager.api7-ee-e2e:7943"
3737
)
38+
39+
const (
40+
ProviderAPISIX = "apisix"
41+
BackendModeAPI7EE = "api7ee"
42+
)

test/e2e/gatewayapi/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ spec:
111111
})
112112

113113
It("dataplane unavailable", func() {
114-
if os.Getenv("PROVIDER_TYPE") == "api7ee" {
114+
if os.Getenv("PROVIDER_TYPE") == framework.BackendModeAPI7EE {
115115
Skip("skip for api7ee mode because it use dashboard admin api")
116116
}
117117
By("Create HTTPRoute")

test/e2e/scaffold/k8s.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ spec:
309309
value: "%s"
310310
`
311311

312-
if s.Deployer.Name() == "api7ee" {
312+
if s.Deployer.Name() == framework.BackendModeAPI7EE {
313313
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
314314
}
315315
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())

0 commit comments

Comments
 (0)