Skip to content

Commit 2fd08d0

Browse files
committed
Merge branch 'feat/apisix-mod' into feat/support-admin-api-mode
2 parents 1f4c010 + de499ee commit 2fd08d0

File tree

7 files changed

+18
-27
lines changed

7 files changed

+18
-27
lines changed

internal/controller/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ func (c *Config) Validate() error {
113113

114114
func validateProvider(config ProviderConfig) error {
115115
switch config.Type {
116-
case ProviderTypeStandalone:
116+
case ProviderTypeStandalone, ProviderTypeAPISIX:
117117
if config.SyncPeriod.Duration <= 0 {
118118
return fmt.Errorf("sync_period must be greater than 0 for standalone provider")
119119
}
120120
return nil
121-
case ProviderTypeAPI7EE, ProviderTypeAPISIX:
121+
case ProviderTypeAPI7EE:
122122
return nil
123123
default:
124124
return fmt.Errorf("unsupported provider type: %s", config.Type)

internal/provider/adc/adc.go

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,21 +186,11 @@ func (d *adcClient) Update(ctx context.Context, tctx *provider.TranslateContext,
186186
}
187187
}
188188

189-
switch d.BackendMode {
190-
case BackendModeAPI7EE:
191-
if apiv2.Is(obj) {
192-
return nil
193-
}
194-
case BackendModeAPISIX:
195-
// do nothing
196-
case BackendModeAPISIXStandalone:
197-
// This mode is full synchronization,
198-
// which only needs to be saved in cache
199-
// and triggered by a timer for synchronization
189+
// This mode is full synchronization,
190+
// which only needs to be saved in cache
191+
// and triggered by a timer for synchronization
192+
if d.BackendMode == BackendModeAPISIXStandalone || d.BackendMode == BackendModeAPISIX || apiv2.Is(obj) {
200193
return nil
201-
default:
202-
return errors.Errorf("unknown backend mode: %s", d.BackendMode)
203-
204194
}
205195

206196
return d.sync(ctx, Task{
@@ -260,7 +250,7 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
260250
log.Debugw("successfully deleted resources from store", zap.Any("object", obj))
261251

262252
switch d.BackendMode {
263-
case BackendModeAPISIXStandalone:
253+
case BackendModeAPISIXStandalone, BackendModeAPISIX:
264254
// Full synchronization is performed on a gateway by gateway basis
265255
// and it is not possible to perform scheduled synchronization
266256
// on deleted gateway level resources
@@ -271,7 +261,7 @@ func (d *adcClient) Delete(ctx context.Context, obj client.Object) error {
271261
})
272262
}
273263
return nil
274-
case BackendModeAPI7EE, BackendModeAPISIX:
264+
case BackendModeAPI7EE:
275265
return d.sync(ctx, Task{
276266
Name: obj.GetName(),
277267
Labels: labels,

test/conformance/apisix/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func TestMain(m *testing.M) {
161161
Namespace: namespace,
162162
StatusAddress: address,
163163
InitSyncDelay: 1 * time.Minute,
164-
ProviderType: cmp.Or(os.Getenv(framework.EnvKeyProviderType), "apisix-standalone"),
164+
ProviderType: cmp.Or(framework.ProviderType, "apisix-standalone"),
165165
ProviderSyncPeriod: 10 * time.Millisecond,
166166
})
167167

test/e2e/framework/apisix_consts.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ package framework
1414

1515
import (
1616
_ "embed"
17+
"os"
1718
"text/template"
1819

1920
"github.com/Masterminds/sprig/v3"
2021
)
2122

22-
const (
23-
EnvKeyProviderType = "PROVIDER_TYPE"
23+
var (
24+
ProviderType = os.Getenv("PROVIDER_TYPE")
2425
)
2526

2627
var (

test/e2e/framework/manifests/etcd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ spec:
3838
- port: 2379
3939
targetPort: 2379
4040
selector:
41-
app: etcd
41+
app: etcd

test/e2e/scaffold/adc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func (a *adcDataplaneResource) dumpResources(ctx context.Context) (*translator.T
132132
"ADC_SERVER=" + a.serverAddr,
133133
"ADC_TOKEN=" + a.token,
134134
}
135-
if providerType := os.Getenv(framework.EnvKeyProviderType); providerType != "" {
136-
adcEnv = append(adcEnv, "ADC_BACKEND="+providerType)
135+
if framework.ProviderType != "" {
136+
adcEnv = append(adcEnv, "ADC_BACKEND="+framework.ProviderType)
137137
}
138138

139139
var stdout, stderr bytes.Buffer

test/e2e/scaffold/apisix_deployer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (s *APISIXDeployer) deployDataplane(opts *APISIXDeployOptions) *corev1.Serv
194194

195195
kubectlOpts := k8s.NewKubectlOptions("", "", opts.Namespace)
196196

197-
if os.Getenv(framework.EnvKeyProviderType) == adc.BackendModeAPISIX {
197+
if framework.ProviderType == adc.BackendModeAPISIX {
198198
opts.ServiceName = "apisix"
199199
opts.ConfigProvider = "etcd"
200200
// deploy etcd
@@ -236,7 +236,7 @@ func (s *APISIXDeployer) deployDataplane(opts *APISIXDeployOptions) *corev1.Serv
236236
func (s *APISIXDeployer) DeployIngress() {
237237
s.Framework.DeployIngress(framework.IngressDeployOpts{
238238
ControllerName: s.opts.ControllerName,
239-
ProviderType: cmp.Or(os.Getenv(framework.EnvKeyProviderType), "apisix-standalone"),
239+
ProviderType: cmp.Or(framework.ProviderType, "apisix-standalone"),
240240
ProviderSyncPeriod: 200 * time.Millisecond,
241241
Namespace: s.namespace,
242242
Replicas: 1,
@@ -246,7 +246,7 @@ func (s *APISIXDeployer) DeployIngress() {
246246
func (s *APISIXDeployer) ScaleIngress(replicas int) {
247247
s.Framework.DeployIngress(framework.IngressDeployOpts{
248248
ControllerName: s.opts.ControllerName,
249-
ProviderType: cmp.Or(os.Getenv(framework.EnvKeyProviderType), "apisix-standalone"),
249+
ProviderType: cmp.Or(framework.ProviderType, "apisix-standalone"),
250250
ProviderSyncPeriod: 200 * time.Millisecond,
251251
Namespace: s.namespace,
252252
Replicas: replicas,

0 commit comments

Comments
 (0)