mirror of
https://github.com/portainer/portainer.git
synced 2025-07-26 16:59:40 +02:00
feat(git): support bearer token auth for git [BE-11770] (#879)
This commit is contained in:
parent
55cc250d2e
commit
caf382b64c
20 changed files with 670 additions and 117 deletions
|
@ -19,13 +19,23 @@ var (
|
|||
func DownloadGitRepository(config gittypes.RepoConfig, gitService portainer.GitService, getProjectPath func() string) (string, error) {
|
||||
username := ""
|
||||
password := ""
|
||||
authType := gittypes.GitCredentialAuthType_Basic
|
||||
if config.Authentication != nil {
|
||||
username = config.Authentication.Username
|
||||
password = config.Authentication.Password
|
||||
authType = config.Authentication.AuthorizationType
|
||||
}
|
||||
|
||||
projectPath := getProjectPath()
|
||||
err := gitService.CloneRepository(projectPath, config.URL, config.ReferenceName, username, password, config.TLSSkipVerify)
|
||||
err := gitService.CloneRepository(
|
||||
projectPath,
|
||||
config.URL,
|
||||
config.ReferenceName,
|
||||
username,
|
||||
password,
|
||||
authType,
|
||||
config.TLSSkipVerify,
|
||||
)
|
||||
if err != nil {
|
||||
if errors.Is(err, gittypes.ErrAuthenticationFailure) {
|
||||
newErr := git.ErrInvalidGitCredential
|
||||
|
@ -36,7 +46,14 @@ func DownloadGitRepository(config gittypes.RepoConfig, gitService portainer.GitS
|
|||
return "", newErr
|
||||
}
|
||||
|
||||
commitID, err := gitService.LatestCommitID(config.URL, config.ReferenceName, username, password, config.TLSSkipVerify)
|
||||
commitID, err := gitService.LatestCommitID(
|
||||
config.URL,
|
||||
config.ReferenceName,
|
||||
username,
|
||||
password,
|
||||
authType,
|
||||
config.TLSSkipVerify,
|
||||
)
|
||||
if err != nil {
|
||||
newErr := fmt.Errorf("unable to fetch git repository id: %w", err)
|
||||
return "", newErr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue