From 6ce46ad3f75199a3e79a436df1773b483cae602c Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Tue, 6 Aug 2024 16:18:44 -0400 Subject: [PATCH] fix: always set GPTSCRIPT_CREDENTIAL_EXPIRATION env var when credentials are used Signed-off-by: Grant Linville --- pkg/runner/runner.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index c2137bea..a8d88fee 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -968,19 +968,19 @@ func (r *Runner) handleCredentials(callCtx engine.Context, monitor Monitor, env } else { log.Warnf("Not saving credential for tool %s - credentials will only be saved for tools from GitHub, or tools that use aliases.", toolName) } + } - if c.ExpiresAt != nil && (nearestExpiration == nil || nearestExpiration.After(*c.ExpiresAt)) { - nearestExpiration = c.ExpiresAt - } + if c.ExpiresAt != nil && (nearestExpiration == nil || nearestExpiration.After(*c.ExpiresAt)) { + nearestExpiration = c.ExpiresAt } for k, v := range c.Env { env = append(env, fmt.Sprintf("%s=%s", k, v)) } + } - if nearestExpiration != nil { - env = append(env, fmt.Sprintf("%s=%s", credentials.CredentialExpiration, nearestExpiration.Format(time.RFC3339))) - } + if nearestExpiration != nil { + env = append(env, fmt.Sprintf("%s=%s", credentials.CredentialExpiration, nearestExpiration.Format(time.RFC3339))) } return env, nil