Take into account legacy config
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
4610f83209
commit
257fb0b09a
2 changed files with 14 additions and 3 deletions
|
|
@ -299,6 +299,13 @@ type Github struct {
|
|||
App GithubApp `toml:"app" json:"app"`
|
||||
}
|
||||
|
||||
func (g *Github) GetAuthType() GithubAuthType {
|
||||
if g.AuthType == "" {
|
||||
return GithubAuthTypePAT
|
||||
}
|
||||
return g.AuthType
|
||||
}
|
||||
|
||||
func (g *Github) APIEndpoint() string {
|
||||
if g.APIBaseURL != "" {
|
||||
return g.APIBaseURL
|
||||
|
|
|
|||
|
|
@ -297,7 +297,7 @@ func (s *sqlDatabase) migrateCredentialsToDB() (err error) {
|
|||
credParams := params.CreateGithubCredentialsParams{
|
||||
Name: cred.Name,
|
||||
Description: cred.Description,
|
||||
AuthType: params.GithubAuthType(cred.AuthType),
|
||||
AuthType: params.GithubAuthType(cred.GetAuthType()),
|
||||
}
|
||||
switch credParams.AuthType {
|
||||
case params.GithubAuthTypeApp:
|
||||
|
|
@ -315,11 +315,15 @@ func (s *sqlDatabase) migrateCredentialsToDB() (err error) {
|
|||
return errors.Wrap(err, "validating app credentials")
|
||||
}
|
||||
case params.GithubAuthTypePAT:
|
||||
if cred.PAT.OAuth2Token == "" {
|
||||
token := cred.PAT.OAuth2Token
|
||||
if token == "" {
|
||||
token = cred.OAuth2Token
|
||||
}
|
||||
if token == "" {
|
||||
return errors.New("missing OAuth2 token")
|
||||
}
|
||||
credParams.PAT = params.GithubPAT{
|
||||
OAuth2Token: cred.PAT.OAuth2Token,
|
||||
OAuth2Token: token,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue