From c446451bfa39d6421a7012cdc2d46543445d0f80 Mon Sep 17 00:00:00 2001 From: Jenny Zhang Date: Fri, 2 Feb 2024 20:33:50 -0500 Subject: [PATCH] cmd/gitops-pusher: only use OAuth creds if non-empty string `os.LookupEnv` may return true if the variable is present in the environment but an empty string. We should only attempt to set OAuth Config if thsoe values are non-empty. Updates gitops-acl-action#33 Signed-off-by: Jenny Zhang --- cmd/gitops-pusher/gitops-pusher.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/gitops-pusher/gitops-pusher.go b/cmd/gitops-pusher/gitops-pusher.go index 72410fa91..60bee6064 100644 --- a/cmd/gitops-pusher/gitops-pusher.go +++ b/cmd/gitops-pusher/gitops-pusher.go @@ -162,7 +162,9 @@ func main() { log.Fatal("set either the envvar TS_API_KEY or TS_OAUTH_ID and TS_OAUTH_SECRET") } var client *http.Client - if oiok { + if oiok && (oauthId != "" || oauthSecret != "") { + // Both should ideally be set, but if either are non-empty it means the user had an intent + // to set _something_, so they should receive the oauth error flow. oauthConfig := &clientcredentials.Config{ ClientID: oauthId, ClientSecret: oauthSecret,