mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
Signed-off-by: reggie-k <regina.voloshin@codefresh.io> Co-authored-by: Pasha Kostohrys <pasha.kostohrys@gmail.com>
40 lines
984 B
Go
40 lines
984 B
Go
package util
|
|
|
|
import (
|
|
stderrors "errors"
|
|
)
|
|
|
|
var (
|
|
LogFormat string
|
|
LogLevel string
|
|
)
|
|
|
|
func ValidateBearerTokenForHTTPSRepoOnly(bearerToken string, isHTTPS bool) error {
|
|
// Bearer token is only valid for HTTPS repositories
|
|
if bearerToken != "" {
|
|
if !isHTTPS {
|
|
err := stderrors.New("--bearer-token is only supported for HTTPS repositories")
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func ValidateBearerTokenForGitOnly(bearerToken string, repoType string) error {
|
|
// Bearer token is only valid for Git repositories
|
|
if bearerToken != "" && repoType != "git" {
|
|
err := stderrors.New("--bearer-token is only supported for Git repositories")
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func ValidateBearerTokenAndPasswordCombo(bearerToken string, password string) error {
|
|
// Either the password or the bearer token must be set, but not both
|
|
if bearerToken != "" && password != "" {
|
|
err := stderrors.New("only --bearer-token or --password is allowed, not both")
|
|
return err
|
|
}
|
|
return nil
|
|
}
|