feat(python): add from_env configuration - #2646
Draft
dhirajsb wants to merge 1 commit into
Draft
Conversation
Add SandboxClient.from_env(), a disk-free constructor that builds a client entirely from OPENSHELL_* environment variables. It complements the existing $OPENSHELL_GATEWAY + XDG gateway-directory discovery used by from_active_cluster() for callers (CI runners, containers, serverless functions) that inject configuration through the environment rather than the CLI's on-disk gateway directory. Environment variables (all follow the existing OPENSHELL_* convention): - OPENSHELL_ENDPOINT (required): host:port or URL; https selects TLS - OPENSHELL_TOKEN: OIDC access token attached as Bearer to every RPC - OPENSHELL_TLS: force TLS on/off, overriding scheme inference - OPENSHELL_TLS_CA / OPENSHELL_TLS_CERT / OPENSHELL_TLS_KEY: TLS material - OPENSHELL_TIMEOUT: per-call gRPC timeout in seconds - OPENSHELL_CLUSTER_NAME: friendly name for error messages The TLS trust profile mirrors from_active_cluster (full mTLS, CA-only, or system roots). Uses only stdlib os.environ parsing plus the existing TlsConfig validation; no new dependencies. Upstreamed from the internal Astra Sandbox SDK (config.py); contribution O2. Adds unit tests mirroring the existing *_test.py patterns and documents the variables under docs/sandboxes/manage-sandboxes.mdx. Signed-off-by: Dhiraj Bokde <dbokde@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
SandboxClient.from_env()as a disk-free configuration path for CI jobs, containers, serverless applications, and other environments that inject gateway settings directly instead of mounting the OpenShell CLI gateway directory.Related Issue
Closes #1817
Changes
OPENSHELL_*variables.host:port, HTTP, and HTTPS endpoint forms with explicit TLS override precedence.from_active_cluster()path for CLI-managed state and refreshable OIDC sessions.Testing
mise run pre-commitpassesmise run python:typecheckpassesmise run test:python(103 tests)Checklist