Skip to content

Commit 7177105

Browse files
authored
Merge pull request #275 from joe0BAB/fix/sm
fix(secret management): fix/workaround to make things work with both API versions temporarily
2 parents 6cd46b5 + bbb9e18 commit 7177105

File tree

1 file changed

+13
-3
lines changed
  • src/extension/host-binary/cmd

1 file changed

+13
-3
lines changed

src/extension/host-binary/cmd/main.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
"fmt"
88
"os"
9+
"os/exec"
910
"os/signal"
1011
"slices"
1112
"syscall"
@@ -228,10 +229,14 @@ func runAddSecret(ctx context.Context, opts addOptions) error {
228229
if err != nil {
229230
return err
230231
}
231-
if err := assertMcpPolicyExists(ctx, c); err != nil {
232-
return err
232+
if isOldVersion(ctx, c) {
233+
if err := assertMcpPolicyExists(ctx, c); err != nil {
234+
return err
235+
}
236+
} else {
237+
cmd := exec.Command("docker", "mcp", "policy", "set", "* allows any-process")
238+
_ = cmd.Run()
233239
}
234-
235240
value := opts.Value
236241
if opts.Base64 {
237242
decodedValue, err := base64.StdEncoding.DecodeString(value)
@@ -244,6 +249,11 @@ func runAddSecret(ctx context.Context, opts addOptions) error {
244249
return c.SetSecret(ctx, secretsapi.Secret{Name: opts.Name, Value: value, Policies: []string{mcpPolicyName}})
245250
}
246251

252+
func isOldVersion(ctx context.Context, apiClient client.ApiClient) bool {
253+
_, err := apiClient.ListPolicies(ctx) // This endpoint has been removed on the new API -> if it exists, it must be the old
254+
return err == nil
255+
}
256+
247257
func runListSecrets(ctx context.Context) error {
248258
c, err := newApiClient()
249259
if err != nil {

0 commit comments

Comments
 (0)