Feat(http): accept all standard HTTP methods in the http providers
Description of your changes
#HTTPDo only allowed GET/POST/PUT/DELETE, so PATCH, HEAD and OPTIONS requests failed CUE validation even though the provider passes the method straight through to the Go client. This widens method to GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE and PATCH (default still GET) in the http provider, the legacy op.#HTTPDo provider and the request step definition in the chart, and adds #HTTPPatch, #HTTPHead and #HTTPOptions to both providers. No Go changes were needed outside tests.
The request step always ran json.Unmarshal on the response body, so a successful HEAD request (or any empty response, such as a 204) would fail the step. It now decodes only a non-empty body, and response is left unset otherwise.
Fixes #295
I have:
- Read and followed KubeVela's contribution process.
- Related Docs updated properly.
- Run
make reviewableto ensure this PR is ready for review. - Added
backport release-x.ylabels to auto-backport this PR if necessary.
How has this code been tested
The method tests for both providers send each method definition's request to an httptest.Server and check the method the server received. They now cover PATCH, HEAD and OPTIONS, and the server records r.Method instead of echoing it in the body, since a HEAD response has no body.
TestRequestStepResponseBody evaluates the chart's request template with stubbed vela imports for HEAD, 204, an empty 200 and a JSON body. The empty-body cases fail without the guard and pass with it. go test ./pkg/providers/http/... ./pkg/providers/legacy/http/..., go vet on those packages and gofmt pass. I did not run make reviewable or the envtest-based kube suites, which need etcd locally.
Special notes for your reviewer
The legacy test reads the method from each CUE definition and sends it with Do(), because calling the legacy provider directly from an uncompiled template trips over the empty response field.
🤖 Generated with Claude Code
Summary by cubic
The HTTP providers and request step now accept all standard HTTP methods, so PATCH, HEAD, OPTIONS, CONNECT, and TRACE requests no longer fail CUE validation. Adds #HTTPPatch, #HTTPHead, and #HTTPOptions definitions to both the http and legacy providers; method defaults to GET as before. Fixes #295.
The request step no longer decodes an empty response body, so HEAD requests and empty responses such as 204 no longer fail the step. response is left unset when there is no body to decode.