Skip to content

Commit bc5fb88

Browse files
committed
fix: allow listing of credentials in all contexts
Signed-off-by: Donnie Adams <[email protected]>
1 parent 51c4b5b commit bc5fb88

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

pkg/cli/credential.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
cmd2 "github.com/gptscript-ai/cmd"
12+
"github.com/gptscript-ai/gptscript/pkg/credentials"
1213
"github.com/gptscript-ai/gptscript/pkg/gptscript"
1314
"github.com/spf13/cobra"
1415
)
@@ -44,7 +45,12 @@ func (c *Credential) Run(cmd *cobra.Command, _ []string) error {
4445
}
4546
defer gptScript.Close(true)
4647

47-
store, err := gptScript.CredentialStoreFactory.NewStore(gptScript.DefaultCredentialContexts)
48+
credCtxs := gptScript.DefaultCredentialContexts
49+
if c.AllContexts {
50+
credCtxs = []string{credentials.AllCredentialContexts}
51+
}
52+
53+
store, err := gptScript.CredentialStoreFactory.NewStore(credCtxs)
4854
if err != nil {
4955
return err
5056
}

pkg/credentials/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func (s Store) List(_ context.Context) ([]Credential, error) {
140140
}
141141

142142
if len(s.credCtxs) > 0 && s.credCtxs[0] == AllCredentialContexts {
143-
allCreds := make([]Credential, len(list))
143+
allCreds := make([]Credential, 0, len(list))
144144
for serverAddress := range list {
145145
ac, err := store.Get(serverAddress)
146146
if err != nil {

0 commit comments

Comments
 (0)