mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-25 17:42:25 +01:00
feat: added modules
This commit is contained in:
36
core/utils/git.go
Normal file
36
core/utils/git.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
vcs "github.com/crawlab-team/crawlab-vcs"
|
||||
"github.com/crawlab-team/crawlab/core/constants"
|
||||
"github.com/crawlab-team/crawlab/core/interfaces"
|
||||
"github.com/crawlab-team/crawlab/core/models/models"
|
||||
)
|
||||
|
||||
func InitGitClientAuth(g interfaces.Git, gitClient *vcs.GitClient) {
|
||||
// set auth
|
||||
switch g.GetAuthType() {
|
||||
case constants.GitAuthTypeHttp:
|
||||
gitClient.SetAuthType(vcs.GitAuthTypeHTTP)
|
||||
gitClient.SetUsername(g.GetUsername())
|
||||
gitClient.SetPassword(g.GetPassword())
|
||||
case constants.GitAuthTypeSsh:
|
||||
gitClient.SetAuthType(vcs.GitAuthTypeSSH)
|
||||
gitClient.SetUsername(g.GetUsername())
|
||||
gitClient.SetPrivateKey(g.GetPassword())
|
||||
}
|
||||
}
|
||||
|
||||
func InitGitClientAuthV2(g *models.GitV2, gitClient *vcs.GitClient) {
|
||||
// set auth
|
||||
switch g.AuthType {
|
||||
case constants.GitAuthTypeHttp:
|
||||
gitClient.SetAuthType(vcs.GitAuthTypeHTTP)
|
||||
gitClient.SetUsername(g.Username)
|
||||
gitClient.SetPassword(g.Password)
|
||||
case constants.GitAuthTypeSsh:
|
||||
gitClient.SetAuthType(vcs.GitAuthTypeSSH)
|
||||
gitClient.SetUsername(g.Username)
|
||||
gitClient.SetPrivateKey(g.Password)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user