From 7f324eac8528e9af72bc4a7d560047fa119f265d Mon Sep 17 00:00:00 2001 From: Antfere <35314857+Antfere@users.noreply.github.com> Date: Sat, 11 Mar 2023 16:09:08 +0000 Subject: [PATCH] Fix Gitea tokens not being found in config.yaml file (#287) * Adds support for Gitea options in config.yaml file * Remove debug lines --------- Co-authored-by: anon --- cmd/root.go | 2 ++ configs/configs.go | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/cmd/root.go b/cmd/root.go index b5e228e..f897c75 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -238,6 +238,8 @@ func InitConfig() { getOrSetDefaults("GHORG_RECLONE_PATH") getOrSetDefaults("GHORG_QUIET") getOrSetDefaults("GHORG_GIT_FILTER") + getOrSetDefaults("GHORG_GITEA_TOKEN") + getOrSetDefaults("GHORG_INSECURE_GITEA_CLIENT") if os.Getenv("GHORG_DEBUG") != "" { viper.Debug() diff --git a/configs/configs.go b/configs/configs.go index 4c2957a..4644c4d 100644 --- a/configs/configs.go +++ b/configs/configs.go @@ -168,6 +168,8 @@ func GetOrSetToken() { getOrSetGitLabToken() case "bitbucket": getOrSetBitBucketToken() + default: + getOrSetGiteaToken() } } @@ -227,6 +229,18 @@ func getOrSetBitBucketToken() { } } +func getOrSetGiteaToken() { + var token string + token = os.Getenv("GHORG_GITEA_TOKEN") + + if isZero(token) || len(token) != 40 { + if runtime.GOOS == "windows" { + return + } + os.Setenv("GHORG_GITEA_TOKEN", token) + } +} + // VerifyTokenSet checks to make sure env is set for the correct scm provider func VerifyTokenSet() error {