Skip to content

Commit 93ba85c

Browse files
gtardiftdabasinskas
authored andcommitted
Better error message if Desktop not available while running using docker agent the gateway
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent ebe7f8b commit 93ba85c

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

pkg/model/provider/anthropic/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Pro
9696
// Query a fresh auth token each time the client is used
9797
authToken, _ := env.Get(ctx, environment.DockerDesktopTokenEnv)
9898
if authToken == "" {
99-
return anthropic.Client{}, errors.New("failed to get Docker Desktop token for Gateway")
99+
return anthropic.Client{}, errors.New(base.NoDesktopTokenErrorMessage)
100100
}
101101

102102
url, err := url.Parse(gateway)

pkg/model/provider/base/base.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import (
66
"github.com/docker/docker-agent/pkg/model/provider/options"
77
)
88

9+
const NoDesktopTokenErrorMessage = "failed to get Docker Desktop token for Gateway. Is Docker Desktop running and are you signed in?"
10+
911
// Config is a common base configuration shared by all provider clients.
1012
// It can be embedded in provider-specific Client structs to avoid code duplication.
1113
type Config struct {

pkg/model/provider/gemini/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Pro
130130
// Query a fresh auth token each time the client is used
131131
authToken, _ := env.Get(ctx, environment.DockerDesktopTokenEnv)
132132
if authToken == "" {
133-
return nil, errors.New("failed to get Docker Desktop token for Gateway")
133+
return nil, errors.New(base.NoDesktopTokenErrorMessage)
134134
}
135135

136136
url, err := url.Parse(gateway)

pkg/model/provider/openai/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func NewClient(ctx context.Context, cfg *latest.ModelConfig, env environment.Pro
115115
// Query a fresh auth token each time the client is used
116116
authToken, _ := env.Get(ctx, environment.DockerDesktopTokenEnv)
117117
if authToken == "" {
118-
return nil, errors.New("failed to get Docker Desktop token for Gateway")
118+
return nil, errors.New(base.NoDesktopTokenErrorMessage)
119119
}
120120

121121
url, err := url.Parse(gateway)

0 commit comments

Comments
 (0)