Fix gitlab (#1639)

* always use git token if we provide one

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>

* bump go-git-url for gitlab fix

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>

* fix action permissions for cosign signature

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>

---------

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
This commit is contained in:
Matthias Bertschy
2024-03-18 10:02:39 +01:00
committed by GitHub
parent 56a9d9a7f3
commit 708bf4477a
6 changed files with 19 additions and 17 deletions

View File

@@ -65,24 +65,23 @@ func cloneRepo(gitURL giturl.IGitAPI) (string, error) {
// Get the URL to clone
cloneURL := gitURL.GetHttpCloneURL()
isGitRepoPublic := isGitRepoPublic(cloneURL)
isGitTokenPresent := isGitTokenPresent(gitURL)
// Declare the authentication variable required for cloneOptions
var auth transport.AuthMethod
if isGitRepoPublic {
// No authentication needed if repository is public
auth = nil
} else {
// Return Error if the AUTH_TOKEN is not present
if isGitTokenPresent := isGitTokenPresent(gitURL); !isGitTokenPresent {
return "", getProviderError(gitURL)
}
if isGitTokenPresent {
auth = &http.BasicAuth{
Username: "x-token-auth",
Password: gitURL.GetToken(),
}
} else {
// If the repository is public, no authentication is needed
if isGitRepoPublic(cloneURL) {
auth = nil
} else {
return "", getProviderError(gitURL)
}
}
// For Azure repo cloning