mirror of
https://github.com/NVIDIA/OpenShell.git
synced 2026-10-17 05:31:16 +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>
61 lines
2.6 KiB
Go
61 lines
2.6 KiB
Go
// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package v1
|
|
|
|
import (
|
|
"github.com/NVIDIA/OpenShell/sdk/go/openshell/v1/types"
|
|
)
|
|
|
|
// ErrorCode classifies SDK errors by their gRPC origin.
|
|
type ErrorCode = types.ErrorCode
|
|
|
|
// ErrorCode values for classifying gRPC errors.
|
|
const (
|
|
ErrorNotFound = types.ErrorNotFound
|
|
ErrorAlreadyExists = types.ErrorAlreadyExists
|
|
ErrorUnavailable = types.ErrorUnavailable
|
|
ErrorPermissionDenied = types.ErrorPermissionDenied
|
|
ErrorInvalidArgument = types.ErrorInvalidArgument
|
|
ErrorDeadlineExceeded = types.ErrorDeadlineExceeded
|
|
ErrorCancelled = types.ErrorCancelled
|
|
ErrorInternal = types.ErrorInternal
|
|
ErrorUnimplemented = types.ErrorUnimplemented
|
|
ErrorConflict = types.ErrorConflict
|
|
ErrorUnauthenticated = types.ErrorUnauthenticated
|
|
)
|
|
|
|
// StatusError is the typed error returned by all SDK operations.
|
|
type StatusError = types.StatusError
|
|
|
|
// IsNotFound returns true if the error indicates a resource was not found.
|
|
func IsNotFound(err error) bool { return types.IsNotFound(err) }
|
|
|
|
// IsAlreadyExists returns true if the error indicates a resource already exists.
|
|
func IsAlreadyExists(err error) bool { return types.IsAlreadyExists(err) }
|
|
|
|
// IsUnavailable returns true if the error indicates the service is unavailable.
|
|
func IsUnavailable(err error) bool { return types.IsUnavailable(err) }
|
|
|
|
// IsPermissionDenied returns true if the error indicates insufficient permissions.
|
|
func IsPermissionDenied(err error) bool { return types.IsPermissionDenied(err) }
|
|
|
|
// IsInvalidArgument returns true if the error indicates an invalid argument.
|
|
func IsInvalidArgument(err error) bool { return types.IsInvalidArgument(err) }
|
|
|
|
// IsDeadlineExceeded returns true if the error indicates a deadline was exceeded.
|
|
func IsDeadlineExceeded(err error) bool { return types.IsDeadlineExceeded(err) }
|
|
|
|
// IsCancelled returns true if the error indicates the operation was cancelled.
|
|
func IsCancelled(err error) bool { return types.IsCancelled(err) }
|
|
|
|
// IsUnimplemented returns true if the error indicates the operation is not implemented.
|
|
func IsUnimplemented(err error) bool { return types.IsUnimplemented(err) }
|
|
|
|
// IsConflict returns true if the error indicates a conflict, such as
|
|
// optimistic concurrency or an invalid state transition.
|
|
func IsConflict(err error) bool { return types.IsConflict(err) }
|
|
|
|
// IsUnauthenticated returns true if the error indicates invalid or missing credentials.
|
|
func IsUnauthenticated(err error) bool { return types.IsUnauthenticated(err) }
|