Fix: kube.#List reads the resource its schema declares
Description of your changes
kube.#List declares $params.resource, but the provider decoded its parameters into
ResourceVars, where the resource is read from value. A call written to the schema reached
List with a nil resource and panicked on GetKind, and so did a call that left out the
optional filter.
List now decodes its own ListVars, reading resource, returns an error when it is missing,
and treats a missing filter as no filter. #263 fixed the same bug in the legacy vela/op
provider; this is the vela/kube one, which it left as it was.
Fixes #
I have:
- Read and followed KubeVela's contribution process.
- Related Docs updated properly. Not needed: the documented schema was already right; the provider now follows it.
- Run
make reviewableto ensure this PR is ready for review. Ran gofmt, golangci-lint v2.14.0 and staticcheck v0.8.1 on the changed packages; not the full target. - Added
backport release-x.ylabels to auto-backport this PR if necessary.
How has this code been tested
New pkg/providers/kube/list_cue_test.go calls #List through its CUE, the way a template
does, with and without a filter. The existing tests called
List with Go structs directly, so they never went through the schema. They are updated to
the new parameter type.
Special notes for your reviewer
Unlike #263's legacy fix, there is no fallback to value here: vela/kube's #List schema is
closed under $params, so no caller can have passed the resource there.
Summary by cubic
Fixes kube.#List so it decodes its own ListVars and reads resource from $params.resource, matching its schema. Previously calls written to the schema reached List with a nil resource and panicked, and so did calls that omitted the optional filter. List now returns an error when resource is missing or has an empty apiVersion or kind, and treats an absent filter as no filter.
- Adds CUE-level tests that call
#Listthe way a template does, with and without a filter, and for an empty apiVersion.