mirror of
https://github.com/kubescape/kubescape.git
synced 2026-04-15 06:58:11 +00:00
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:
committed by
GitHub
parent
56a9d9a7f3
commit
708bf4477a
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user