feat: cert based git auth - #7653
Conversation
Signed-off-by: Abhishek Dhiman <abhi2002dhiman@gmail.com>
Signed-off-by: Abhishek Dhiman <abhi2002dhiman@gmail.com>
* feat: cert_based_git_auth Signed-off-by: Abhishek Dhiman <abhi2002dhiman@gmail.com> * feat/cert_based_git_auth Signed-off-by: Abhishek Dhiman <abhi2002dhiman@gmail.com> --------- Signed-off-by: Abhishek Dhiman <abhi2002dhiman@gmail.com> Co-authored-by: Abhishek Dhiman <abhi2002dhiman@gmail.com>
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io> # Conflicts: # cmd/testworkflow-toolkit/commands/clone.go # k8s/helm/testkube-operator/templates/testworkflows.testkube.io_testworkflows.yaml # k8s/helm/testkube-operator/templates/testworkflows.testkube.io_testworkflowtemplates.yaml
Greptile SummaryThis PR adds certificate-based git authentication to TestWorkflow content fetching, allowing users to supply a CA certificate, client certificate, and client private key for mutual TLS when cloning repositories. All three new fields follow the established
Confidence Score: 5/5Safe to merge — the new cert auth path is self-contained, follows established patterns, and is exercised by new unit tests. All changed layers (API types, deep-copy, CRD YAML, bidirectional mappers, secrets resolver, CLI processor, and clone runtime) are updated consistently and correctly. The setupCertAuth implementation writes PEM content to restricted temp files, passes the paths via git config overrides, and cleans up on both the happy path and error paths. The utils.go concat function properly flattens []string slices, so cert args reach git correctly. No functional defects were identified. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Spec as Workflow Spec
participant Proc as operations.go
participant Clone as clone command
participant CertSetup as clone_cert.go
participant Git as git
Spec->>Proc: ContentGit with cert fields (plain or From variant)
Proc->>Proc: From variant: inject env var reference into args
Proc->>Proc: Plain variant: embed cert data in args
Proc->>Clone: Execute binary with cert flags
Clone->>CertSetup: setupCertAuth(opts)
CertSetup->>CertSetup: writeTempCertFile per cert field (mode 0400)
CertSetup-->>Clone: git config args + cleanup funcs
Clone->>Git: git with http.sslCAInfo, http.sslCert, http.sslKey overrides
Git-->>Clone: result
Clone->>CertSetup: defer RunCleanupFuncs removes temp files
Reviews (4): Last reviewed commit: "fix: use os.TempDir() in writeTempCertFi..." | Re-trigger Greptile |
There was a problem hiding this comment.
Pull request overview
This PR extends TestWorkflow Git content handling to support TLS certificate-based access to Git repositories (custom CA, client certificate, and client key) across the API, CRDs, workflow processing, and the toolkit clone command.
Changes:
- Added
caCert/clientCert/clientKey(and*Fromvariants) to TestWorkflow Git content types and API models, including OpenAPI + CRD schema updates. - Extended workflow secret externalization and processing to pass the new Git TLS materials into the toolkit clone invocation (env/args).
- Marked new Git TLS env vars as sensitive in the init/orchestration layer.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/testworkflows/testworkflowresolver/secrets.go | Externalizes computed CA/client cert/key values into Secrets. |
| pkg/testworkflows/testworkflowprocessor/operations.go | Passes CA/client cert/key into /toolkit clone via args/env. |
| pkg/mapper/testworkflows/openapi_kube.go | Maps new Git TLS fields from API → kube types. |
| pkg/mapper/testworkflows/kube_openapi.go | Maps new Git TLS fields from kube → API types. |
| pkg/api/v1/testkube/model_test_workflow_content_git.go | Adds new Git TLS fields to generated API model struct + docs. |
| api/testworkflows/v1/content_types.go | Adds new Git TLS fields to ContentGit. |
| api/testworkflows/v1/zz_generated.deepcopy.go | Deep-copies the new *From EnvVarSource pointers. |
| api/v1/testkube.yaml | Exposes new Git TLS fields in OpenAPI schema. |
| k8s/crd/testworkflows.testkube.io_testworkflowtemplates.yaml | CRD schema updated to include new Git TLS fields. |
| k8s/crd/testworkflows.testkube.io_testworkflows.yaml | CRD schema updated to include new Git TLS fields. |
| cmd/testworkflow-toolkit/commands/clone.go | Adds CLI flags/options for CA/client cert/key and wires into clone flow. |
| cmd/testworkflow-init/orchestration/setup.go | Treats new Git TLS env vars as sensitive for redaction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot implemented missed methods, generate crd, check open api spec setupCertAuth and RunCleanupFuncs are called here but no implementations exist in the repository, which will break compilation of the toolkit binary. Please add these helper functions (or remove the calls) and ensure they’re wired into the clone flow correctly (e.g., writing cert/key/CA data to temp files and configuring git to use them). |
…auth Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/54c2ce3f-1528-4f63-b512-265cf30f527f Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Implemented the missing functions in commit
Added comprehensive unit tests in The CRD and OpenAPI spec were already updated in a previous commit and confirmed to contain the new fields ( |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot fix note and add unit tests The clientCert/clientCertFrom descriptions say "verify client (testkube) TLS connection", but this field is used for git's http.sslCert (client certificate for mutual TLS) and is primarily about authenticating the client to the Git server. Please update the OpenAPI description to reflect client authentication (and keep it consistent with the Go model/CRD docs). |
…regenerate CRDs, add secrets tests Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/744d7dae-3882-425c-9dc4-110cbf1e8ad6 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Fixed in commit
|
|
@copilot validate crds using make verify-crds-generated |
|
|
@copilot are crds beow 256KB annotation limit? |
The TestWorkflow CRDs were already well above the 256KB annotation limit before this PR —
|
…liases, fix TMPDIR in tests Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/4141db10-1537-42ca-8515-23194a2f9a03 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
…mp files Agent-Logs-Url: https://github.com/kubeshop/testkube/sessions/bddafd2a-19cd-437f-bd06-139d5dc65a48 Co-authored-by: vsukhin <5984962+vsukhin@users.noreply.github.com>
Signed-off-by: Vladislav Sukhin <vladislav@kubeshop.io> # Conflicts: # go.sum
Pull request description
Checklist (choose whats happened)
Breaking changes
Changes
Fixes