-
Notifications
You must be signed in to change notification settings - Fork 4
feat: validate APISIX resources in webhooks #393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
ba91ae8
feat: validate APISIX resources in webhooks
AlinsRan 0b74a9c
fix: use validate API in webhook checks
AlinsRan 10d76b4
fix(e2e): add skip guards and redesign ADC validation tests
AlinsRan d9ba66c
fix: export kind kubeconfig in v2 e2e
AlinsRan 07b7c4d
fix: recreate kind cluster for v2 e2e
AlinsRan 73f3836
fix: wait for kind apiserver readiness
AlinsRan 23fb4e7
fix: use internal kind kubeconfig in CI
AlinsRan 7663b68
fix: support old kind kubeconfig setup
AlinsRan 8859187
fix: harden e2e environment setup
AlinsRan 742f11b
fix: use mirrored images in self-hosted e2e
AlinsRan 9b1533e
fix: proxy docker hub pulls in self-hosted e2e
AlinsRan 24f141d
fix: build local echo server image for e2e
AlinsRan ec74a51
fix: proxy remaining docker hub images
AlinsRan e90710e
fix: defer dashboard readiness checks in e2e
AlinsRan d401305
fix: wait for postgres readiness in v2 e2e
AlinsRan 6618932
fix: stabilize postgres startup in v2 e2e
AlinsRan 4141447
fix: avoid flaky docker login action downloads
AlinsRan d1a32ed
fix: scope postgres mirror to v2 CI
AlinsRan a58fd8c
fix: stabilize webhook CI coverage
AlinsRan f032228
fix: retry v2 postgres image preload
AlinsRan 4dee995
fix: use legacy postgres image in v2 CI
AlinsRan eef1a88
test: stabilize standalone apisixconsumer webhook e2e
AlinsRan 9a29eb2
fix: stabilize adc e2e retries
AlinsRan 9efafc9
test: stabilize corrected consumer webhook e2e
AlinsRan badcb29
ci: fix misspell workflow install
AlinsRan f9905c1
Merge branch 'master' into feat/webhook-adc-validation
AlinsRan 65b8f1d
revert: remove unnecessary CI/CD changes unrelated to webhook validation
5f3e401
test(e2e): fix TLS test retry with RequestAssert
0db12c2
fix: restore warn behavior for ApisixTls with missing secrets
4789243
fix: address PR review comments
AlinsRan b35e0f9
fix: populate global_rules and plugin_metadata in ADC validate payload
AlinsRan 58ce2fb
fix: use consumerGatewayRef field index in validateDuplicateKeyAuthCr…
AlinsRan 70b6a7c
fix: skip duplicate key-auth check for malformed credential JSON
AlinsRan a0b54cd
Merge remote-tracking branch 'origin/master' into feat/webhook-adc-va…
AlinsRan 4ffeb5e
test(e2e): fix and expand ADC validation webhook tests
AlinsRan 4c1ec6b
fix: resolve lint issues in webhook e2e tests and consumer webhook
AlinsRan f4047f6
fix(e2e): fix UPDATE path webhook tests
AlinsRan 3d240f1
chore: remove unrelated framework changes from webhook validation PR
AlinsRan bf5fed5
test: remove apisix-standalone-only skip in ADC validation e2e tests
AlinsRan 70137d0
fix: remove unused framework import in webhook e2e tests
AlinsRan d95462e
refactor: use ADC server /validate endpoint for all backends
AlinsRan 134e77e
fix: use PUT method for ADC server /validate endpoint
AlinsRan a003a3e
test: use spec.plugins for Consumer ADC validation e2e tests
AlinsRan ce3ecb4
chore: migrate image registry from hkccr to ghcr.io
AlinsRan 9d8ecb6
chore: remove legacy registry login and add packages:read permission
AlinsRan 138d2d4
chore: retrigger CI
AlinsRan cfce22b
Update conformance-test.yml
AlinsRan 65c6747
chore: add pull-requests write permission for add-pr-comment action
AlinsRan c3e4ec4
Merge branch 'feat/migrate-registry-to-ghcr' into feat/webhook-adc-va…
AlinsRan 3bf9e3f
fix: remove duplicate failurePolicy in webhook markers; fix ApisixCon…
AlinsRan f5363b0
fix: restore len(warnings) > 0 guard in ApisixConsumer webhook
AlinsRan 6b88e29
refactor: add explicit log when skipping ADC due to initErr in Apisix…
AlinsRan 878ee57
Merge remote-tracking branch 'origin/master' into feat/webhook-adc-va…
AlinsRan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // 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 | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/go-logr/logr" | ||
| networkingv1 "k8s.io/api/networking/v1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
|
||
| v1alpha1 "github.com/apache/apisix-ingress-controller/api/v1alpha1" | ||
| apiv2 "github.com/apache/apisix-ingress-controller/api/v2" | ||
| "github.com/apache/apisix-ingress-controller/internal/provider" | ||
| "github.com/apache/apisix-ingress-controller/internal/utils" | ||
| ) | ||
|
|
||
| func PrepareApisixRouteForValidation(ctx context.Context, c client.Client, log logr.Logger, route *apiv2.ApisixRoute) (*provider.TranslateContext, error) { | ||
| tctx := provider.NewDefaultTranslateContext(ctx) | ||
|
|
||
| ingressClass, err := FindMatchingIngressClassByObject(tctx, c, log, route, networkingv1.SchemeGroupVersion.String()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := ProcessIngressClassParameters(tctx, c, log, route, ingressClass); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| reconciler := &ApisixRouteReconciler{ | ||
| Client: c, | ||
| Log: log, | ||
| ICGV: networkingv1.SchemeGroupVersion, | ||
| supportsEndpointSlice: false, | ||
| } | ||
|
AlinsRan marked this conversation as resolved.
|
||
| if err := reconciler.processApisixRoute(tctx, route); err != nil { | ||
|
AlinsRan marked this conversation as resolved.
|
||
| return nil, err | ||
| } | ||
| return tctx, nil | ||
| } | ||
|
|
||
| func PrepareApisixConsumerForValidation(ctx context.Context, c client.Client, log logr.Logger, consumer *apiv2.ApisixConsumer) (*provider.TranslateContext, error) { | ||
| tctx := provider.NewDefaultTranslateContext(ctx) | ||
|
|
||
| ingressClass, err := FindMatchingIngressClassByObject(tctx, c, log, consumer, networkingv1.SchemeGroupVersion.String()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := ProcessIngressClassParameters(tctx, c, log, consumer, ingressClass); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| reconciler := &ApisixConsumerReconciler{ | ||
| Client: c, | ||
| Log: log, | ||
| ICGV: networkingv1.SchemeGroupVersion, | ||
| } | ||
| if err := reconciler.processSpec(ctx, tctx, consumer); err != nil { | ||
| return nil, err | ||
| } | ||
| return tctx, nil | ||
| } | ||
|
|
||
| func PrepareConsumerForValidation(ctx context.Context, c client.Client, log logr.Logger, consumer *v1alpha1.Consumer) (*provider.TranslateContext, error) { | ||
| tctx := provider.NewDefaultTranslateContext(ctx) | ||
|
|
||
| reconciler := &ConsumerReconciler{ | ||
| Client: c, | ||
| Log: log, | ||
| } | ||
| gateway, err := reconciler.getGateway(ctx, consumer) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := ProcessGatewayProxy(c, log, tctx, gateway, utils.NamespacedNameKind(consumer)); err != nil { | ||
| return nil, err | ||
| } | ||
| if err := reconciler.processSpec(ctx, tctx, consumer); err != nil { | ||
| return nil, err | ||
| } | ||
| return tctx, nil | ||
| } | ||
|
|
||
| func PrepareApisixTlsForValidation(ctx context.Context, c client.Client, log logr.Logger, tls *apiv2.ApisixTls) (*provider.TranslateContext, error) { | ||
| tctx := provider.NewDefaultTranslateContext(ctx) | ||
|
|
||
| ingressClass, err := FindMatchingIngressClassByObject(tctx, c, log, tls, networkingv1.SchemeGroupVersion.String()) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if err := ProcessIngressClassParameters(tctx, c, log, tls, ingressClass); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| reconciler := &ApisixTlsReconciler{ | ||
| Client: c, | ||
| Log: log, | ||
| } | ||
| if err := reconciler.processApisixTls(ctx, tctx, tls); err != nil { | ||
| return nil, err | ||
| } | ||
| return tctx, nil | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.