@@ -10,24 +10,31 @@ import (
1010 "github.com/gptscript-ai/gptscript/pkg/config"
1111)
1212
13+ type CredentialStore interface {
14+ Get (toolName string ) (* Credential , bool , error )
15+ Add (cred Credential ) error
16+ Remove (toolName string ) error
17+ List () ([]Credential , error )
18+ }
19+
1320type Store struct {
1421 credCtx string
1522 credHelperDirs CredentialHelperDirs
1623 cfg * config.CLIConfig
1724}
1825
19- func NewStore (cfg * config.CLIConfig , credCtx , cacheDir string ) (* Store , error ) {
26+ func NewStore (cfg * config.CLIConfig , credCtx , cacheDir string ) (CredentialStore , error ) {
2027 if err := validateCredentialCtx (credCtx ); err != nil {
2128 return nil , err
2229 }
23- return & Store {
30+ return Store {
2431 credCtx : credCtx ,
2532 credHelperDirs : GetCredentialHelperDirs (cacheDir ),
2633 cfg : cfg ,
2734 }, nil
2835}
2936
30- func (s * Store ) Get (toolName string ) (* Credential , bool , error ) {
37+ func (s Store ) Get (toolName string ) (* Credential , bool , error ) {
3138 store , err := s .getStore ()
3239 if err != nil {
3340 return nil , false , err
@@ -50,7 +57,7 @@ func (s *Store) Get(toolName string) (*Credential, bool, error) {
5057 return & cred , true , nil
5158}
5259
53- func (s * Store ) Add (cred Credential ) error {
60+ func (s Store ) Add (cred Credential ) error {
5461 cred .Context = s .credCtx
5562 store , err := s .getStore ()
5663 if err != nil {
@@ -63,15 +70,15 @@ func (s *Store) Add(cred Credential) error {
6370 return store .Store (auth )
6471}
6572
66- func (s * Store ) Remove (toolName string ) error {
73+ func (s Store ) Remove (toolName string ) error {
6774 store , err := s .getStore ()
6875 if err != nil {
6976 return err
7077 }
7178 return store .Erase (toolNameWithCtx (toolName , s .credCtx ))
7279}
7380
74- func (s * Store ) List () ([]Credential , error ) {
81+ func (s Store ) List () ([]Credential , error ) {
7582 store , err := s .getStore ()
7683 if err != nil {
7784 return nil , err
0 commit comments