Repository navigation
Description
Bug Description
devops tls enable-k8s --context <name> refuses a valid kubeconfig context name that is not an RFC 1123 name, such as an EKS ARN. enable_k8s_cmd in src/devops_cli/commands/tls.py checks the context with validate_k8s_name(context, "context"), which accepts only RFC 1123 names. The other k8s commands (switch-context, deploy-stack, argo, volume, tunnel) check the context with validate_k8s_context_name, which accepts ARN, GKE and user-account names and refuses shell metacharacters.
#4091 fixes the same defect in the Secret read of the credential sync.
Steps to Reproduce
- Run
devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run. - See
Invalid context: 'arn:aws:eks:us-east-1:123456789012:cluster/prod'. Must be a valid RFC 1123 name.
Expected Behavior
devops tls enable-k8s accepts every context name that deploy-stack accepts, and checks it with validate_k8s_context_name.
Existing Tool Considered
No new tool is needed. The fix calls validate_k8s_context_name, which exists in devops_cli.core.validation.
Source: #4091
Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found no external package that validates kubeconfig context names in ARN, GKE or user-account form while refusing shell metacharacters; the Kubernetes Python client validates config files, not names, so the in-repo validator swap stands.
Lacks:
- No public context-name validator accepting EKS ARN, GKE or user-account forms
- No refusal of shell metacharacters in context names
- No reusable check that other commands could share instead of the in-repo validator
Proposed design
Problem statement
The devops tls enable-k8s --context command refuses a valid kubeconfig context name. It checks the context with validate_k8s_name, which accepts only RFC 1123 names. An EKS ARN such as arn:aws:eks:us-east-1:123456789012:cluster/prod is such a name. The other k8s commands accept it with validate_k8s_context_name. The change swaps the validator in enable_k8s_cmd.
Acceptance criteria
Requirement: EKS ARN context accepted
devops tls enable-k8s SHALL accept each kubeconfig context name that deploy-stack accepts, including an EKS ARN.
Scenario: Dry run with an EKS ARN context
- WHEN the user runs
devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run - THEN the command exits with status 0 and prints no RFC 1123 context error.
Requirement: Context validator parity
enable_k8s_cmd SHALL check the context with validate_k8s_context_name.
Scenario: The command calls the context validator
- WHEN a test patches
validate_k8s_context_nameindevops_cli.commands.tlsand runsenable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --dry-run - THEN the patch records one call with that context and
validate_k8s_namereceives no call with the labelcontext.
Requirement: Shell metacharacters refused
devops tls enable-k8s MUST refuse a context name that contains a shell metacharacter.
Scenario: Context with a shell metacharacter
- WHEN the user runs
devops tls enable-k8s --context 'prod;whoami' --dry-run - THEN the command exits with a non-zero status and prints an invalid context error.
Requirement: Namespace names stay RFC 1123
devops tls enable-k8s SHALL keep the RFC 1123 check on each namespace name.
Scenario: Invalid namespace with a valid ARN context
- WHEN the user runs
devops tls enable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prod --namespace Bad_NS --dry-run - THEN the command exits with a non-zero status and prints an invalid namespace error.
Requirement: ARN context reaches kubectl
devops tls enable-k8s SHALL pass the accepted context to each kubectl call.
Scenario: The secret apply gets the ARN context
- WHEN a test patches
run_subprocessand runsenable-k8s --context arn:aws:eks:us-east-1:123456789012:cluster/prodwith existing certificates - THEN each recorded argv contains
arn:aws:eks:us-east-1:123456789012:cluster/prod.
Existing Tool Considered
No external tool or library covers this need. The alternatives check of 2026-11-14 found no package that validates kubeconfig context names in the ARN, GKE and user-account forms. The fix reuses the in-repo validator validate_k8s_context_name (src/devops_cli/core/validation.py:560), which the other k8s commands already call. It adds no code that the project must keep: the change swaps one import and one call, about two lines.
Key questions
- Which validator must
enable_k8s_cmduse for the--contextvalue?: Usevalidate_k8s_context_namefromdevops_cli.core.validation. It accepts ARN, GKE and user-account names, and it refuses shell metacharacters. (best practice) [sources: src/devops_cli/core/validation.py:560, src/devops_cli/commands/tls.py:420, src/devops_cli/commands/k8s/cluster_runtime.py, src/devops_cli/commands/argo.py, src/devops_cli/commands/k8s/volume.py, src/devops_cli/commands/k8s/tunnel.py, src/devops_cli/k8s/credentials.py, openspec/changes/archive/2026-11-12-4091-credential-sync-refuses-a-context-that/design.md:12]- Chosen: Reuse
validate_k8s_context_name. It already accepts the kubeconfig name forms and refuses shell metacharacters. Every other k8s command uses it, andtests/core/test_validation.pytests it. - Rejected: Write a new context validator. A second validator duplicates the tested one, as the archived design of fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091 states.
- Rejected: Relax
validate_k8s_name. The same function checks namespace names and other RFC 1123 names, so a relaxation weakens those checks.
- Chosen: Reuse
- Does the context check cover the dry-run path and the real run?: Yes.
enable_k8s_cmdchecks the context before the dry-run branch, so both paths use the same check. [sources: src/devops_cli/commands/tls.py] - Does the fix change the namespace check?: No. The loop keeps
validate_k8s_name(ns, "namespace", namespace=True)for each namespace. [sources: src/devops_cli/commands/tls.py] - Does the command pass the context to the kubectl argv builders?: Yes.
plan_enable_k8s,namespace_check_argv,namespace_create_argv,secret_render_argvandsecret_apply_argvtake the context and place it in the argv. [sources: src/devops_cli/crypto/tls_plans.py, src/devops_cli/commands/tls.py, openspec/changes/archive/2026-11-01-2258-repos-branches-ssh-and-tls-commands/design.md:9] - Where do the tests of
enable_k8s_cmdlive?:tests/commands/test_tls_cmd.py. The test patchesrun_subprocess, so it can record thekubectlargv offline. [sources: tests/commands/test_tls_cmd.py, openspec/changes/archive/2026-11-01-2258-repos-branches-ssh-and-tls-commands/design.md:9] - Does this item depend on fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091?: No. fix(k8s): credential sync refuses a context that is no RFC 1123 name #4091 changed
fetch_secret_datainsrc/devops_cli/k8s/credentials.py, and its change is archived. This fix changessrc/devops_cli/commands/tls.pyonly. [sources: openspec/changes/archive/2026-11-12-4091-credential-sync-refuses-a-context-that/proposal.md, src/devops_cli/k8s/credentials.py, src/devops_cli/commands/tls.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
fixprefix of the title gives the type.tls, and .github/labels.yml declares no scope/tls label. Add the label to the file to give the scope to this item.It blocks a valid workflow for users with EKS ARN context names, but other commands already work.Users with non-RFC 1123 context names cannot run tls enable-k8s until this is fixed.The fix replaces one function call with an existing validator already used by other commands.devops-cli-service commentedon Nov 12, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
tls, and .github/labels.yml declares no scope/tls label. Add the label to the file to give the scope to this item.The bug blocks a documented workflow for EKS users, but it affects one command only.Users with ARN or GKE context names cannot run enable-k8s until the fix lands.The fix replaces one validation call with an existing function.Both items touch the tls command, but #961 fixes state handling and the candidate fixes context-name validation.devops-cli-service commentedon Nov 14, 2026
Alternatives check: none
Reason: Searches for a Kubernetes context-name validation library returned only unrelated generic validation pages (MDN), no tool that validates kubeconfig context names such as EKS ARNs. The issue itself asks for no new dependency: it is an internal one-line fix that swaps
validate_k8s_namefor the existingvalidate_k8s_context_nameindevops_cli.core.validation, which the other k8s commands already use.Tool: none found
Lacks:
validate_k8s_context_namevalidatorSearches run:
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Status set to Ready at ca62d6a (see proposed design in issue body).
devops-cli-service commentedon Nov 29, 2026
Released in v0.247.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.247.0
devops-cli-service commentedon Nov 29, 2026
Live since 2026-11-29 16:17 UTC