Skip to content

Commit 6ed61ee

Browse files
committed
add an options struct for ListCredentials
Signed-off-by: Grant Linville <[email protected]>
1 parent 5960c54 commit 6ed61ee

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

gptscript.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,19 @@ func (g *GPTScript) PromptResponse(ctx context.Context, resp PromptResponse) err
308308
return err
309309
}
310310

311-
func (g *GPTScript) ListCredentials(ctx context.Context, credCtxs []string, allContexts bool) ([]Credential, error) {
311+
type ListCredentialsOptions struct {
312+
credCtxs []string
313+
allContexts bool
314+
}
315+
316+
func (g *GPTScript) ListCredentials(ctx context.Context, opts ListCredentialsOptions) ([]Credential, error) {
312317
req := CredentialRequest{}
313-
if allContexts {
318+
if opts.allContexts {
314319
req.AllContexts = true
320+
} else if opts.credCtxs != nil && len(opts.credCtxs) > 0 {
321+
req.Context = opts.credCtxs
315322
} else {
316-
req.Context = credCtxs
323+
req.Context = []string{"default"}
317324
}
318325

319326
out, _, err := g.runBasicCommand(ctx, "credentials", req)

0 commit comments

Comments
 (0)