Deny deleting the default github.com endpoint

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2024-04-19 10:19:23 +00:00
parent 208a4eea37
commit eb1456479b

View file

@ -214,6 +214,10 @@ func (s *sqlDatabase) DeleteGithubEndpoint(_ context.Context, name string) error
return errors.Wrap(err, "fetching github endpoint")
}
if endpoint.Name == "github.com" {
return errors.New("cannot delete default github endpoint")
}
var credsCount int64
if err := tx.Model(&GithubCredentials{}).Where("endpoint_name = ?", endpoint.Name).Count(&credsCount).Error; err != nil {
if !errors.Is(err, gorm.ErrRecordNotFound) {