From 1f9f987b4aef2aed8795719827675f0f092b8803 Mon Sep 17 00:00:00 2001 From: Jeongwon Song Date: Sat, 17 Feb 2024 15:24:11 -0500 Subject: [PATCH 1/3] check for git authentication Signed-off-by: Jeongwon Song --- pkg/github/githubutil.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/github/githubutil.go b/pkg/github/githubutil.go index 2d72b67a..8d830fd7 100644 --- a/pkg/github/githubutil.go +++ b/pkg/github/githubutil.go @@ -231,7 +231,11 @@ func GetGHRepoService() GHRepoService { gh = github.NewClient(oauth2.NewClient(context.Background(), oauth2.StaticTokenSource( &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ))) - } else { + if _, err := ListReleases(flyte, gh.Repositories); err != nil { + gh = nil + } + } + if gh == nil { gh = github.NewClient(&http.Client{}) } return gh.Repositories From 6a3f11ab5ea78194e17245ff03d88dfdf274332a Mon Sep 17 00:00:00 2001 From: Jeongwon Song Date: Sat, 17 Feb 2024 15:34:34 -0500 Subject: [PATCH 2/3] added warning logs Signed-off-by: Jeongwon Song --- pkg/github/githubutil.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/github/githubutil.go b/pkg/github/githubutil.go index 8d830fd7..eaeac3c8 100644 --- a/pkg/github/githubutil.go +++ b/pkg/github/githubutil.go @@ -232,6 +232,7 @@ func GetGHRepoService() GHRepoService { &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ))) if _, err := ListReleases(flyte, gh.Repositories); err != nil { + logger.Warnf(context.Background(), "GITHUB_TOKEN exists failed to fetch releases, using empty http.Client: %s.", err) gh = nil } } From af6308bfbe903536f95e7c7680d8e2a700098283 Mon Sep 17 00:00:00 2001 From: Jeongwon Song Date: Sat, 17 Feb 2024 15:36:45 -0500 Subject: [PATCH 3/3] updated warning logs Signed-off-by: Jeongwon Song --- pkg/github/githubutil.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/github/githubutil.go b/pkg/github/githubutil.go index eaeac3c8..68008537 100644 --- a/pkg/github/githubutil.go +++ b/pkg/github/githubutil.go @@ -232,7 +232,7 @@ func GetGHRepoService() GHRepoService { &oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")}, ))) if _, err := ListReleases(flyte, gh.Repositories); err != nil { - logger.Warnf(context.Background(), "GITHUB_TOKEN exists failed to fetch releases, using empty http.Client: %s.", err) + logger.Warnf(context.Background(), "Found GITHUB_TOKEN but failed to fetch releases. Using empty http.Client: %s.", err) gh = nil } }