Fix: read the TLS secret given as namespace/name in vela/http
Description of your changes
getTransport in the vela/http provider (and the legacy op.#HTTPDo provider) accepts a tls_config.secret given as <namespace>/<name>, but the split was off by one:
objectKey.Namespace = secretName[:index-1] // "vela-system/certs" -> "vela-syste"
objectKey.Name = secretName[index:] // -> "/certs"
So the secret lookup always failed for that form. The caller drops the error from getTransport, so the request then went out with the default transport, without the configured CA and client certificate, and usually failed later with a TLS error that didn't mention the secret.
This splits on the first / with strings.Cut in both providers. A plain secret name still uses the namespace from tls_config.namespace (or the workflow namespace), and a leading / is still ignored as before.
I found this while reading the code. I couldn't find an existing issue or PR for it.
I have:
- Read and followed KubeVela's contribution process.
- Related Docs updated properly. No docs change is needed: this makes the existing behaviour work.
- Run
make reviewableto ensure this PR is ready for review. (I ran gofmt, go vet and golangci-lint on the changed packages instead, see below.) - Added
backport release-x.ylabels to auto-backport this PR if necessary.
How has this code been tested
- New
TestGetTransportSecretKeyin bothpkg/providers/httpandpkg/providers/legacy/http. It checks the secret key used forcerts+ namespacedefaultand forvela-system/certs. On the currentmainthe second case fails withNamespace:"vela-syste", Name:"/certs". go test ./pkg/providers/http/ ./pkg/providers/legacy/http/...passes.gofmt,go vetandgolangci-lint run --new-from-rev=HEADon the changed packages are clean.
Special notes for your reviewer
getTransport errors are still ignored by the callers (err == nil && tr != nil). I left that as is, since returning the error would change behaviour for workflows that set a tls_config with a missing secret today.
I used an AI assistant to help with this change (see the Assisted-by trailer). I reviewed and tested the change.
Summary by cubic
Fixes parsing of tls_config.secret given as <namespace>/<name> in the vela/http and legacy op.#HTTPDo providers. Previously vela-system/certs was split off by one, looking up secret /certs in namespace vela-syste; the lookup failed and, because the caller dropped the error, requests went out with the default transport, without the configured CA and client certificate.
- Splits on the first
/withstrings.Cutin both providers. - Plain secret names still use the namespace from
tls_config.namespaceor the workflow namespace; a leading/is still ignored. - Adds
TestGetTransportSecretKeyin both providers covering plain and<namespace>/<name>secret references.