@@ -478,27 +478,22 @@ func updateInitScript(resourceData *schema.ResourceData, i interface{}) diag.Dia
478478}
479479
480480func agentAuthToken (ctx context.Context , agentID string ) string {
481- // Most of the time, we will generate a new token for the agent.
482- // In the case of a prebuilt workspace being claimed, we will override with
483- // an existing token provided below.
484- token := uuid .NewString ()
485-
486481 existingToken := helpers .OptionalEnv (RunningAgentTokenEnvironmentVariable (agentID ))
487- logFields := map [string ]interface {}{
488- "agent_id" : agentID ,
489- "token_provided" : existingToken != "" ,
490- }
491- if existingToken != "" {
492- // An existing token was provided for this agent. That means that this
493- // is a prebuilt workspace in the process of being claimed.
494- // We should reuse the token.
495- tflog .Info (ctx , "using provided agent token for prebuild" , logFields )
496- token = existingToken
497- } else {
498- tflog .Info (ctx , "using a new agent token" , logFields )
482+ if existingToken == "" {
483+ // Most of the time, we will generate a new token for the agent.
484+ // In the case of a prebuilt workspace being claimed, we will override with
485+ // an existing token provided below.
486+ token := uuid .NewString ()
487+ return token
499488 }
500489
501- return token
490+ // An existing token was provided for this agent. That means that this
491+ // is a prebuilt workspace in the process of being claimed.
492+ // We should reuse the token.
493+ tflog .Info (ctx , "using provided agent token for prebuild" , map [string ]interface {}{
494+ "agent_id" : agentID ,
495+ })
496+ return existingToken
502497}
503498
504499// RunningAgentTokenEnvironmentVariable returns the name of an environment variable
0 commit comments