From 532eda190344f92f9f70f29ad28d770e51f483c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alain=20H=C3=A9la=C3=AFli?= Date: Wed, 14 Jun 2023 13:43:53 +0200 Subject: [PATCH] it works better with auth --- entitlementConfig.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/entitlementConfig.go b/entitlementConfig.go index 9f354e6..b3abbe4 100644 --- a/entitlementConfig.go +++ b/entitlementConfig.go @@ -14,6 +14,7 @@ import ( "github.com/bradleyfalzon/ghinstallation/v2" "github.com/go-git/go-git/v5" + githttp "github.com/go-git/go-git/v5/plumbing/transport/http" "github.com/golang-jwt/jwt/v5" "github.com/google/go-github/v53/github" "golang.org/x/text/cases" @@ -68,8 +69,16 @@ func (config *EntitlementConfig) load(appTransport *ghinstallation.AppsTransport // Need to clean up the download directory before cloning the repo os.RemoveAll(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo)) - _, err := git.PlainClone(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo), false, &git.CloneOptions{ + token, err := itr.Token(context.Background()) + if err != nil { + log.Printf("couldn't get token for installation %d on org %s", config.InstallationId, config.Login) + return err + } + + log.Println(token) + _, err = git.PlainClone(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo), false, &git.CloneOptions{ URL: fmt.Sprintf("%s/%s/%s", config.GitUrl, config.Login, config.Repo), + Auth: &githttp.BasicAuth{Username: "username", Password: token}, Progress: os.Stdout, }) if err != nil {