Skip to content

Commit 42ced63

Browse files
committed
WIP
Signed-off-by: Grant Linville <grant@acorn.io>
1 parent fd91f37 commit 42ced63

File tree

5 files changed

+25
-14
lines changed

5 files changed

+25
-14
lines changed

pkg/config/cliconfig.go

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,22 @@ import (
1515
"github.com/docker/cli/cli/config/types"
1616
)
1717

18-
var (
19-
darwinHelpers = []string{"osxkeychain", "file"}
20-
windowsHelpers = []string{"wincred", "file"}
21-
linuxHelpers = []string{"secretservice", "pass", "file"}
18+
const (
19+
Wincred = "wincred"
20+
Osxkeychain = "osxkeychain"
21+
Secretservice = "secretservice"
22+
Pass = "pass"
23+
File = "file"
24+
Sqlite = "sqlite"
25+
26+
GPTScriptHelperPrefix = "gptscript-credential-"
2227
)
2328

24-
const GPTScriptHelperPrefix = "gptscript-credential-"
29+
var (
30+
darwinHelpers = []string{Osxkeychain, File, Sqlite}
31+
windowsHelpers = []string{Wincred, File, Sqlite}
32+
linuxHelpers = []string{Secretservice, Pass, File, Sqlite}
33+
)
2534

2635
type AuthConfig types.AuthConfig
2736

@@ -169,11 +178,11 @@ func ReadCLIConfig(gptscriptConfigFile string) (*CLIConfig, error) {
169178
func (c *CLIConfig) setDefaultCredentialsStore() error {
170179
switch runtime.GOOS {
171180
case "darwin":
172-
c.CredentialsStore = "osxkeychain"
181+
c.CredentialsStore = Osxkeychain
173182
case "windows":
174-
c.CredentialsStore = "wincred"
183+
c.CredentialsStore = Wincred
175184
default:
176-
c.CredentialsStore = "file"
185+
c.CredentialsStore = File
177186
}
178187
return c.Save()
179188
}
@@ -187,7 +196,7 @@ func isValidCredentialHelper(helper string) bool {
187196
case "linux":
188197
return slices.Contains(linuxHelpers, helper)
189198
default:
190-
return helper == "file"
199+
return helper == File || helper == Sqlite
191200
}
192201
}
193202

pkg/credentials/store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func (s *Store) getStore(ctx context.Context) (credentials.Store, error) {
178178
}
179179

180180
func (s *Store) getStoreByHelper(ctx context.Context, helper string) (credentials.Store, error) {
181-
if helper == "" || helper == config.GPTScriptHelperPrefix+"file" {
181+
if helper == "" || helper == config.GPTScriptHelperPrefix+config.File {
182182
return credentials.NewFileStore(s.cfg), nil
183183
}
184184

pkg/credentials/util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"path/filepath"
66

7+
"github.com/gptscript-ai/gptscript/pkg/config"
78
runtimeEnv "github.com/gptscript-ai/gptscript/pkg/env"
89
)
910

@@ -13,7 +14,7 @@ type CredentialHelperDirs struct {
1314

1415
func RepoNameForCredentialStore(store string) string {
1516
switch store {
16-
case "sqlite":
17+
case config.Sqlite:
1718
return "gptscript-credential-sqlite"
1819
default:
1920
return "gptscript-credential-helpers"

pkg/repos/get.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ func (m *Manager) deferredSetUpCredentialHelpers(ctx context.Context, cliCfg *co
109109
distInfo, suffix string
110110
)
111111
// The file helper is built-in and does not need to be downloaded.
112-
if helperName == "file" {
112+
if helperName == config.File {
113113
return nil
114114
}
115115
switch helperName {
116-
case "wincred":
116+
case config.Wincred:
117117
suffix = ".exe"
118118
default:
119119
distInfo = fmt.Sprintf("-%s-%s", runtime.GOOS, runtime.GOARCH)

pkg/repos/runtimes/golang/golang.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"runtime"
1919
"strings"
2020

21+
"github.com/gptscript-ai/gptscript/pkg/config"
2122
"github.com/gptscript-ai/gptscript/pkg/debugcmd"
2223
runtimeEnv "github.com/gptscript-ai/gptscript/pkg/env"
2324
"github.com/gptscript-ai/gptscript/pkg/hash"
@@ -286,7 +287,7 @@ func (r *Runtime) Setup(ctx context.Context, _ types.Tool, dataRoot, toolSource
286287
}
287288

288289
func (r *Runtime) DownloadCredentialHelper(ctx context.Context, tool types.Tool, helperName, distInfo, suffix string, binDir string) error {
289-
if helperName == "file" {
290+
if helperName == config.File {
290291
return nil
291292
}
292293

0 commit comments

Comments
 (0)