Take into account legacy config

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-04-17 13:45:56 +00:00
parent 4610f83209
commit 257fb0b09a
2 changed files with 14 additions and 3 deletions

View file

@ -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,
}
}