Skip to content
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

api: fix WasmCodeSourceType enum validation #3203

Merged
merged 1 commit into from
Apr 16, 2024
Merged

api: fix WasmCodeSourceType enum validation #3203

merged 1 commit into from
Apr 16, 2024

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Apr 15, 2024

What

This PR fixes the validation enum values of the WasmCodeSourceType type.

When the following EnvoyExtensionPolicy resource was deployed, the CRD validation failed

---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyExtensionPolicy
metadata:
  name: my-wasm-1
  namespace: envoy-gateway-system
spec:
  targetRef:
    kind: Gateway
    name: eg
    group: gateway.networking.k8s.io
  wasm:
    - name: my_wasm_1
      code:
        type: Image
        image:
          url: oci://example.com/project/my-wasm:latest
          pullSecret:
            name: "some-secret-name"
      failOpen: true
      config:
        foo: value1

The validation message:

The EnvoyExtensionPolicy "my-wasm-1" is invalid: 
* spec.wasm[0].code.type: Unsupported value: "Image": supported values: "Global", "Local"
* <nil>: Invalid value: "": "spec.wasm[0].code.type" must validate all the schemas (allOf)

Verification steps

  • Checkout the current branch
  • Create local Kind cluster
make create-cluster
  • Build custom image
make kube-install-image
  • Run custom image
IMAGE_PULL_POLICY=IfNotPresent make kube-deploy
  • Create EnvoyExtensionPolicy resource
kubectl apply -f - << EOF
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: EnvoyExtensionPolicy
metadata:
  name: my-wasm-1
  namespace: envoy-gateway-system
spec:
  targetRef:
    kind: Gateway
    name: eg
    group: gateway.networking.k8s.io
  wasm:
    - name: my_wasm_1
      code:
        type: Image
        image:
          url: oci://example.com/project/my-wasm:latest
          pullSecret:
            name: "some-secret-name"
      failOpen: true
      config:
        foo: value1
EOF

The resource should be created without issues

envoyextensionpolicy.gateway.envoyproxy.io/my-wasm-1 created

Signed-off-by: Eguzki Astiz Lezaun <eastizle@redhat.com>
@eguzki eguzki requested a review from a team as a code owner April 15, 2024 15:55
@zirain
Copy link
Contributor

zirain commented Apr 15, 2024

/retest

Copy link
Contributor

@zirain zirain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

cc @zhaohuabing

Copy link
Member

@zhaohuabing zhaohuabing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@zhaohuabing zhaohuabing merged commit 0692b09 into envoyproxy:main Apr 16, 2024
18 of 19 checks passed
@eguzki eguzki deleted the wasmcodesourcetype-validation branch April 16, 2024 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants