mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-22 06:19:47 +08:00
* feat(sdk/go): complete Go SDK with domain clients, auth, and hardening Add the Go SDK implementation covering all gateway RPC services with domain-typed clients, comprehensive OIDC authentication flows, fake test doubles, and proto converters. Domain clients: Sandbox, Provider, Exec, File, TCP, SSH, Policy, Profile, Health, Service, Config, Workspace, Inference, Refresh. Each client validates inputs, resolves sandboxes by name, and converts between domain types and proto at the boundary. Auth: OIDC authorization code (PKCE), device code (RFC 8628), and client credentials (RFC 6749 Section 4.4) flows with gateway config auto-resolution. Token refresh with singleflight deduplication and exponential backoff. Edge tunnel proxy for gRPC-over-WebSocket. Gateway: On-disk gateway discovery with user/system directory precedence, lazy token loading, and auth mode mapping. Testing: In-memory fake client with deep-copy isolation, watch broadcasting with filtering, and workspace-scoped object stores. Bufconn-based gRPC tests for all domain clients. Ref: #2044 Signed-off-by: Roland Huß <rhuss@redhat.com> * feat(sdk/go): add gateway client options for logger, timeout, and retry Add WithLogger, WithTimeout, and WithRetryPolicy options to the gateway package's NewClient function. These forward the corresponding Config fields (Logger, Timeout, RetryPolicy) through to the underlying SDK client, giving callers full control over observability, connection timeouts, and retry behavior when constructing clients from on-disk gateway configurations. Also adds RetryPolicy type to types package and extends Config with the three new fields. * fix(mise): sync sccache lock entry Signed-off-by: Drew Newberry <anewberry@nvidia.com> --------- Signed-off-by: Roland Huß <rhuss@redhat.com> Signed-off-by: Drew Newberry <anewberry@nvidia.com> Co-authored-by: Drew Newberry <anewberry@nvidia.com>
58 lines
2.3 KiB
Go
58 lines
2.3 KiB
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package fake
|
|
|
|
import (
|
|
"context"
|
|
|
|
v1 "github.com/NVIDIA/OpenShell/sdk/go/openshell/v1"
|
|
"github.com/NVIDIA/OpenShell/sdk/go/openshell/v1/types"
|
|
)
|
|
|
|
var _ v1.ExecInterface = (*fakeExecClient)(nil)
|
|
|
|
// fakeExecClient implements v1.ExecInterface. All methods return
|
|
// Unimplemented because command execution requires a real sandbox runtime.
|
|
type fakeExecClient struct {
|
|
closedFunc func() bool
|
|
}
|
|
|
|
// newFakeExecClient creates a new fakeExecClient.
|
|
func newFakeExecClient(closedFunc func() bool) *fakeExecClient {
|
|
return &fakeExecClient{closedFunc: closedFunc}
|
|
}
|
|
|
|
// Run returns Unimplemented.
|
|
func (c *fakeExecClient) Run(_ context.Context, _, sandboxName string, _ []string, _ ...v1.ExecOptions) (*types.ExecResult, error) {
|
|
if c.closedFunc() {
|
|
return nil, &types.StatusError{Code: types.ErrorUnavailable, Message: "client is closed"}
|
|
}
|
|
if sandboxName == "" {
|
|
return nil, &types.StatusError{Code: types.ErrorInvalidArgument, Message: "sandbox name must not be empty"}
|
|
}
|
|
return nil, &types.StatusError{Code: types.ErrorUnimplemented, Message: "Run is not supported by the fake client"}
|
|
}
|
|
|
|
// Stream returns Unimplemented.
|
|
func (c *fakeExecClient) Stream(_ context.Context, _, sandboxName string, _ []string, _ ...v1.ExecOptions) (v1.ExecStream, error) {
|
|
if c.closedFunc() {
|
|
return nil, &types.StatusError{Code: types.ErrorUnavailable, Message: "client is closed"}
|
|
}
|
|
if sandboxName == "" {
|
|
return nil, &types.StatusError{Code: types.ErrorInvalidArgument, Message: "sandbox name must not be empty"}
|
|
}
|
|
return nil, &types.StatusError{Code: types.ErrorUnimplemented, Message: "Stream is not supported by the fake client"}
|
|
}
|
|
|
|
// Interactive returns Unimplemented.
|
|
func (c *fakeExecClient) Interactive(_ context.Context, _, sandboxName string, _ []string, _, _ uint32, _ ...v1.ExecOptions) (v1.InteractiveSession, error) {
|
|
if c.closedFunc() {
|
|
return nil, &types.StatusError{Code: types.ErrorUnavailable, Message: "client is closed"}
|
|
}
|
|
if sandboxName == "" {
|
|
return nil, &types.StatusError{Code: types.ErrorInvalidArgument, Message: "sandbox name must not be empty"}
|
|
}
|
|
return nil, &types.StatusError{Code: types.ErrorUnimplemented, Message: "Interactive is not supported by the fake client"}
|
|
}
|