Skip to content

Commit 77e65c5

Browse files
committed
feat(sdk/go): sync proto bindings and add credential handle support
Regenerate Go proto bindings after rebase to pick up new CredentialHandle message and Provider.credential_handles and profile_workspace fields from upstream. Add domain types, converter support, and proto field coverage tests for Provider and CredentialHandle. Signed-off-by: Roland Huß <rhuss@redhat.com>
1 parent efb78b4 commit 77e65c5

4 files changed

Lines changed: 190 additions & 38 deletions

File tree

‎sdk/go/openshell/v1/internal/converter/coverage_test.go‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package converter
66
import (
77
"testing"
88

9+
dm "github.com/NVIDIA/OpenShell/sdk/go/proto/datamodelv1"
910
pb "github.com/NVIDIA/OpenShell/sdk/go/proto/openshellv1"
1011
sandboxpb "github.com/NVIDIA/OpenShell/sdk/go/proto/sandboxv1"
1112
"google.golang.org/protobuf/reflect/protoreflect"
@@ -153,6 +154,30 @@ func TestConverterCoversAllProtoFields_L7DenyRule(t *testing.T) {
153154
assertAllFieldsCovered(t, (&sandboxpb.L7DenyRule{}).ProtoReflect().Descriptor(), handled, nil)
154155
}
155156

157+
func TestConverterCoversAllProtoFields_Provider(t *testing.T) {
158+
handled := fieldSet{
159+
"metadata": true,
160+
"type": true,
161+
"credentials": true,
162+
"config": true,
163+
"credential_expires_at_ms": true,
164+
"profile_workspace": true,
165+
"credential_handles": true,
166+
}
167+
168+
assertAllFieldsCovered(t, (&dm.Provider{}).ProtoReflect().Descriptor(), handled, nil)
169+
}
170+
171+
func TestConverterCoversAllProtoFields_CredentialHandle(t *testing.T) {
172+
handled := fieldSet{
173+
"driver": true,
174+
"handle": true,
175+
"metadata": true,
176+
}
177+
178+
assertAllFieldsCovered(t, (&dm.CredentialHandle{}).ProtoReflect().Descriptor(), handled, nil)
179+
}
180+
156181
func TestConverterCoversAllProtoFields_McpOptions(t *testing.T) {
157182
handled := fieldSet{
158183
"strict_tool_names": true,

‎sdk/go/openshell/v1/internal/converter/provider.go‎

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ func ProviderFromProto(p *dm.Provider) *types.Provider {
1919
result := &types.Provider{
2020
Type: p.GetType(),
2121
Spec: types.ProviderSpec{
22-
Config: CopyStringMap(p.GetConfig()),
22+
Config: CopyStringMap(p.GetConfig()),
23+
ProfileWorkspace: p.GetProfileWorkspace(),
2324
},
2425
}
2526

@@ -41,6 +42,17 @@ func ProviderFromProto(p *dm.Provider) *types.Provider {
4142
}
4243
}
4344

45+
if handles := p.GetCredentialHandles(); len(handles) > 0 {
46+
result.Spec.CredentialHandles = make(map[string]types.CredentialHandle, len(handles))
47+
for k, h := range handles {
48+
result.Spec.CredentialHandles[k] = types.CredentialHandle{
49+
Driver: h.GetDriver(),
50+
Handle: h.GetHandle(),
51+
Metadata: CopyStringMap(h.GetMetadata()),
52+
}
53+
}
54+
}
55+
4456
return result
4557
}
4658

@@ -61,9 +73,10 @@ func ProviderToProto(p *types.Provider) *dm.Provider {
6173
Workspace: p.Workspace,
6274
DeletionTimestampMs: MillisFromTimePtr(p.DeletionTimestamp),
6375
},
64-
Type: p.Type,
65-
Credentials: CopyStringMap(p.Spec.Credentials),
66-
Config: CopyStringMap(p.Spec.Config),
76+
Type: p.Type,
77+
Credentials: CopyStringMap(p.Spec.Credentials),
78+
Config: CopyStringMap(p.Spec.Config),
79+
ProfileWorkspace: p.Spec.ProfileWorkspace,
6780
}
6881

6982
if len(p.Spec.CredentialExpiresAt) > 0 {
@@ -73,5 +86,16 @@ func ProviderToProto(p *types.Provider) *dm.Provider {
7386
}
7487
}
7588

89+
if len(p.Spec.CredentialHandles) > 0 {
90+
result.CredentialHandles = make(map[string]*dm.CredentialHandle, len(p.Spec.CredentialHandles))
91+
for k, h := range p.Spec.CredentialHandles {
92+
result.CredentialHandles[k] = &dm.CredentialHandle{
93+
Driver: h.Driver,
94+
Handle: h.Handle,
95+
Metadata: CopyStringMap(h.Metadata),
96+
}
97+
}
98+
}
99+
76100
return result
77101
}

‎sdk/go/openshell/v1/types/provider.go‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,15 @@ type ProviderSpec struct {
2424
Credentials map[string]string
2525
Config map[string]string
2626
CredentialExpiresAt map[string]time.Time
27+
ProfileWorkspace string
28+
CredentialHandles map[string]CredentialHandle
29+
}
30+
31+
// CredentialHandle is an opaque handle for a provider credential stored by
32+
// gateway credential storage. Handles are created by OpenShell and are not
33+
// accepted as user-authored input.
34+
type CredentialHandle struct {
35+
Driver string
36+
Handle string
37+
Metadata map[string]string
2738
}

‎sdk/go/proto/datamodelv1/datamodel.pb.go‎

Lines changed: 126 additions & 34 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)