Skip to content

Commit

Permalink
fall back to token field if error occurs when reading file
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-breen committed Jan 20, 2025
1 parent f26c45e commit 371c72b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions internal/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,11 @@ func addPerRPCCredentials(agentConfig *config.Config, resourceID string, opts []
token := agentConfig.Command.Auth.Token

if agentConfig.Command.Auth.TokenPath != "" {
var err error
token, err = retrieveTokenFromFile(agentConfig.Command.Auth.TokenPath)
if err != nil {
slog.Error("Unable to add token to gRPC dial options, token will be empty", "error", err)
tk, err := retrieveTokenFromFile(agentConfig.Command.Auth.TokenPath)
if err == nil {
token = tk
} else {
slog.Error("Unable to add token to gRPC dial options", "error", err)
}
}

Expand Down
3 changes: 2 additions & 1 deletion test/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ func AgentConfig() *config.Config {
Type: config.Grpc,
},
Auth: &config.AuthConfig{
Token: "1234",
Token: "1234",
TokenPath: "",
},
TLS: &config.TLSConfig{
Cert: "cert.pem",
Expand Down

0 comments on commit 371c72b

Please sign in to comment.