Skip to content

Commit 371c72b

Browse files
committed
fall back to token field if error occurs when reading file
1 parent f26c45e commit 371c72b

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

internal/grpc/grpc.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,11 @@ func addPerRPCCredentials(agentConfig *config.Config, resourceID string, opts []
241241
token := agentConfig.Command.Auth.Token
242242

243243
if agentConfig.Command.Auth.TokenPath != "" {
244-
var err error
245-
token, err = retrieveTokenFromFile(agentConfig.Command.Auth.TokenPath)
246-
if err != nil {
247-
slog.Error("Unable to add token to gRPC dial options, token will be empty", "error", err)
244+
tk, err := retrieveTokenFromFile(agentConfig.Command.Auth.TokenPath)
245+
if err == nil {
246+
token = tk
247+
} else {
248+
slog.Error("Unable to add token to gRPC dial options", "error", err)
248249
}
249250
}
250251

test/types/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ func AgentConfig() *config.Config {
133133
Type: config.Grpc,
134134
},
135135
Auth: &config.AuthConfig{
136-
Token: "1234",
136+
Token: "1234",
137+
TokenPath: "",
137138
},
138139
TLS: &config.TLSConfig{
139140
Cert: "cert.pem",

0 commit comments

Comments
 (0)