Skip to content

feat: add defaulter for gateway-api resources loading from file#5232

Merged
shawnh2 merged 8 commits intoenvoyproxy:mainfrom
shawnh2:default-standalone
Feb 12, 2025
Merged

feat: add defaulter for gateway-api resources loading from file#5232
shawnh2 merged 8 commits intoenvoyproxy:mainfrom
shawnh2:default-standalone

Conversation

@shawnh2
Copy link
Copy Markdown
Contributor

@shawnh2 shawnh2 commented Feb 8, 2025

What type of PR is this?

What this PR does / why we need it:

  • add defaulter for our crd resources, allow them to set default values while loading from file
    • the defaulter code is derived from kubectl-validate's validator, cannot reuse their logic since some of their functions/fields are not exposed
  • fix the existing test and add new test for loading supported kind resources

Which issue(s) this PR fixes:

Fixes #4858

Release Notes: Yes

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 61.68831% with 59 lines in your changes missing coverage. Please review.

Project coverage is 68.01%. Comparing base (4f01d3f) to head (9eae27e).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
internal/gatewayapi/resource/defaulter.go 62.16% 42 Missing and 14 partials ⚠️
internal/gatewayapi/resource/load.go 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5232      +/-   ##
==========================================
+ Coverage   66.91%   68.01%   +1.10%     
==========================================
  Files         211      212       +1     
  Lines       33176    33328     +152     
==========================================
+ Hits        22199    22669     +470     
+ Misses       9628     9290     -338     
- Partials     1349     1369      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shawnh2 shawnh2 changed the title feat: add defaulter for standalone feat: add defaulter for gateway-api resources loading from file Feb 8, 2025
…ting tests

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
@shawnh2 shawnh2 marked this pull request as ready for review February 9, 2025 06:23
@shawnh2 shawnh2 requested a review from a team as a code owner February 9, 2025 06:23
Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Copy link
Copy Markdown
Contributor

@arkodg arkodg 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 !
neat way to default :)

@arkodg arkodg requested review from a team February 10, 2025 22:24
@shawnh2
Copy link
Copy Markdown
Contributor Author

shawnh2 commented Feb 11, 2025

/retest

@shawnh2 shawnh2 merged commit 7146fe8 into envoyproxy:main Feb 12, 2025
25 checks passed
@shawnh2 shawnh2 deleted the default-standalone branch February 12, 2025 12:58
guydc pushed a commit to guydc/gateway that referenced this pull request Mar 4, 2025
…yproxy#5232)

* add defaulter that can set default values for our crd

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* resolve conflicts

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add gateway schema defaulter while loading resources and fix all existing tests

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add load test for all supported kind resources

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix lint

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

---------

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Co-authored-by: zirain <zirain2009@gmail.com>
(cherry picked from commit 7146fe8)
Signed-off-by: Guy Daich <guy.daich@sap.com>
guydc added a commit that referenced this pull request Mar 4, 2025
* feat: add defaulter for gateway-api resources loading from file (#5232)

* add defaulter that can set default values for our crd

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* resolve conflicts

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add gateway schema defaulter while loading resources and fix all existing tests

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* add load test for all supported kind resources

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

* fix lint

Signed-off-by: shawnh2 <shawnhxh@outlook.com>

---------

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Co-authored-by: zirain <zirain2009@gmail.com>
(cherry picked from commit 7146fe8)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix: Allow weights to be zero on endpoints (#5278)

* fix: Allow weights to be zero on endpoints

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* chore: bump go to 1.24 (#5287)

* chore: bump go to 1.24

Signed-off-by: zirain <zirain2009@gmail.com>

* fix

Signed-off-by: zirain <zirain2009@gmail.com>

---------

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* build(deps): bump sigs.k8s.io/kind from 0.26.0 to 0.27.0 in /tools/src/kind (#5295)

build(deps): bump sigs.k8s.io/kind in /tools/src/kind

Bumps [sigs.k8s.io/kind](https://github.com/kubernetes-sigs/kind) from 0.26.0 to 0.27.0.
- [Release notes](https://github.com/kubernetes-sigs/kind/releases)
- [Commits](kubernetes-sigs/kind@v0.26.0...v0.27.0)

---
updated-dependencies:
- dependency-name: sigs.k8s.io/kind
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* build(deps): bump helm.sh/helm/v3 from 3.17.0 to 3.17.1 (#5291)

Bumps [helm.sh/helm/v3](https://github.com/helm/helm) from 3.17.0 to 3.17.1.
- [Release notes](https://github.com/helm/helm/releases)
- [Commits](helm/helm@v3.17.0...v3.17.1)

---
updated-dependencies:
- dependency-name: helm.sh/helm/v3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* build(deps): bump the golang-org group across 2 directories with 1 update (#5290)

Bumps the golang-org group with 1 update in the / directory: [golang.org/x/net](https://github.com/golang/net).
Bumps the golang-org group with 1 update in the /examples/extension-server directory: [golang.org/x/net](https://github.com/golang/net).

Updates `golang.org/x/net` from 0.34.0 to 0.35.0
- [Commits](golang/net@v0.34.0...v0.35.0)

Updates `golang.org/x/net` from 0.34.0 to 0.35.0
- [Commits](golang/net@v0.34.0...v0.35.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: golang-org
- dependency-name: golang.org/x/net
  dependency-type: indirect
  update-type: version-update:semver-minor
  dependency-group: golang-org
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* build(deps): bump github.com/golangci/golangci-lint from 1.63.4 to 1.64.5 in /tools/src/golangci-lint (#5294)

build(deps): bump github.com/golangci/golangci-lint

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.63.4 to 1.64.5.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](golangci/golangci-lint@v1.63.4...v1.64.5)

---
updated-dependencies:
- dependency-name: github.com/golangci/golangci-lint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* Add test case

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* Add test case

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* one more test

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* one more test

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* remove

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* Found the bug for real

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* Focus on gatewayapi

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* cleanup

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* cleanup

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* build(deps): bump github.com/evanphx/json-patch/v5 from 5.9.0 to 5.9.11 (#5293)

Bumps [github.com/evanphx/json-patch/v5](https://github.com/evanphx/json-patch) from 5.9.0 to 5.9.11.
- [Release notes](https://github.com/evanphx/json-patch/releases)
- [Commits](evanphx/json-patch@v5.9.0...v5.9.11)

---
updated-dependencies:
- dependency-name: github.com/evanphx/json-patch/v5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* api: BackendTrafficPolicy DNSLookupFamily (#5249)

* api: BackendTrafficPolicy DNSLookupFamily

Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix api

Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix enum

Signed-off-by: Guy Daich <guy.daich@sap.com>

---------

Signed-off-by: Guy Daich <guy.daich@sap.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* clean up logic on if

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* Update logic and add udp tests

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* fix udp tests

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* chore: ignore `sched.co` (#5305)

chore: ignore

Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

* newline

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>

---------

Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Guy Daich <guy.daich@sap.com>
Signed-off-by: tobrien-nydig <100732440+tobrien-nydig@users.noreply.github.com>
Co-authored-by: zirain <zirain2009@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Guy Daich <guy.daich@sap.com>
(cherry picked from commit 1f9a1bd)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix: Standalone mode - Secret and ConfigMap parsing (#5329)

* Added Secret and ConfigMap parsing

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>

* Updated release notes

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>

* Fixed lint issues

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>

* Fixed gen-check issues

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>

* Added new test cases for Secret

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>

---------

Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com>
(cherry picked from commit a41e992)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix: backendSettings for extAuth (#5372)

* fix: backendSettings for extAuth

Fixes: #5371

Signed-off-by: Arko Dasgupta <arko@tetrate.io>

* release note

Signed-off-by: Arko Dasgupta <arko@tetrate.io>

---------

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
(cherry picked from commit 1c0eca6)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* conformance: skip, skip-test features (#5399)

So they dont show up in the supportedFeatures section
of the conformance report

Relates to kubernetes-sigs/gateway-api#3651 (comment)

Signed-off-by: Arko Dasgupta <arko@tetrate.io>
(cherry picked from commit bd53727)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* validate all xds resources before returning the translation result (#5148)

* validate all xds resources before returning the translation result

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* fix lint

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* Log errors when envoy rejects xDS resources

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

* remove duplicated line

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>

---------

Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
(cherry picked from commit b1bf609)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* chore: bump go 1.23.6 (#5204)

(cherry picked from commit 48459d4)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* build(deps): bump the k8s-io group (#5309)

* build(deps): bump the k8s-io group across 2 directories with 7 updates

Bumps the k8s-io group with 5 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [k8s.io/api](https://github.com/kubernetes/api) | `0.32.1` | `0.32.2` |
| [k8s.io/apiextensions-apiserver](https://github.com/kubernetes/apiextensions-apiserver) | `0.32.1` | `0.32.2` |
| [k8s.io/cli-runtime](https://github.com/kubernetes/cli-runtime) | `0.32.1` | `0.32.2` |
| [k8s.io/kubectl](https://github.com/kubernetes/kubectl) | `0.32.1` | `0.32.2` |
| [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime) | `0.20.1` | `0.20.2` |

Bumps the k8s-io group with 2 updates in the /examples/extension-server directory: [k8s.io/apimachinery](https://github.com/kubernetes/apimachinery) and [sigs.k8s.io/controller-runtime](https://github.com/kubernetes-sigs/controller-runtime).

Updates `k8s.io/api` from 0.32.1 to 0.32.2
- [Commits](kubernetes/api@v0.32.1...v0.32.2)

Updates `k8s.io/apiextensions-apiserver` from 0.32.1 to 0.32.2
- [Release notes](https://github.com/kubernetes/apiextensions-apiserver/releases)
- [Commits](kubernetes/apiextensions-apiserver@v0.32.1...v0.32.2)

Updates `k8s.io/apimachinery` from 0.32.1 to 0.32.2
- [Commits](kubernetes/apimachinery@v0.32.1...v0.32.2)

Updates `k8s.io/cli-runtime` from 0.32.1 to 0.32.2
- [Commits](kubernetes/cli-runtime@v0.32.1...v0.32.2)

Updates `k8s.io/client-go` from 0.32.1 to 0.32.2
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.32.1...v0.32.2)

Updates `k8s.io/kubectl` from 0.32.1 to 0.32.2
- [Commits](kubernetes/kubectl@v0.32.1...v0.32.2)

Updates `sigs.k8s.io/controller-runtime` from 0.20.1 to 0.20.2
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](kubernetes-sigs/controller-runtime@v0.20.1...v0.20.2)

Updates `k8s.io/apimachinery` from 0.32.1 to 0.32.2
- [Commits](kubernetes/apimachinery@v0.32.1...v0.32.2)

Updates `sigs.k8s.io/controller-runtime` from 0.20.1 to 0.20.2
- [Release notes](https://github.com/kubernetes-sigs/controller-runtime/releases)
- [Changelog](https://github.com/kubernetes-sigs/controller-runtime/blob/main/RELEASE.md)
- [Commits](kubernetes-sigs/controller-runtime@v0.20.1...v0.20.2)

---
updated-dependencies:
- dependency-name: k8s.io/api
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/apiextensions-apiserver
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/cli-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/client-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/kubectl
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: k8s.io/apimachinery
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
- dependency-name: sigs.k8s.io/controller-runtime
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: k8s-io
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore: bump k8s.io

Signed-off-by: zirain <zirain2009@gmail.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
(cherry picked from commit 3e08722)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* chore: fix CVE (#5360)

* chore: fix CVE

Signed-off-by: zirain <zirain2009@gmail.com>

* lint

Signed-off-by: zirain <zirain2009@gmail.com>

---------

Signed-off-by: zirain <zirain2009@gmail.com>
(cherry picked from commit c8f518b)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* chore: bump go 1.23.5 (#5190)

* chore: bump go

Signed-off-by: zirain <zirain2009@gmail.com>

* bump controller-gen

Signed-off-by: zirain <zirain2009@gmail.com>

* 1.23.5

Signed-off-by: zirain <zirain2009@gmail.com>

* revert

Signed-off-by: zirain <zirain2009@gmail.com>

---------

Signed-off-by: zirain <zirain2009@gmail.com>
(cherry picked from commit d50be42)
Signed-off-by: Guy Daich <guy.daich@sap.com>

* fix dependencies

Signed-off-by: Guy Daich <guy.daich@sap.com>

---------

Signed-off-by: shawnh2 <shawnhxh@outlook.com>
Signed-off-by: Guy Daich <guy.daich@sap.com>
Signed-off-by: Tim OBrien <timothy.obrien@nydig.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: tobrien-nydig <100732440+tobrien-nydig@users.noreply.github.com>
Signed-off-by: Balazs Stasz <balazs.stasz@bonrepublic.com>
Signed-off-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Signed-off-by: Arko Dasgupta <arko@tetrate.io>
Signed-off-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Co-authored-by: sh2 <shawnhxh@outlook.com>
Co-authored-by: zirain <zirain2009@gmail.com>
Co-authored-by: tobrien-nydig <100732440+tobrien-nydig@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Balazs Stasz <139752289+bstasz@users.noreply.github.com>
Co-authored-by: Arko Dasgupta <arkodg@users.noreply.github.com>
Co-authored-by: Huabing (Robin) Zhao <zhaohuabing@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic when adding healthcheck to gateway in standalone mode

5 participants