Skip to content

Commit

Permalink
Deny deleting the default github.com endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Apr 19, 2024
1 parent e829aa5 commit 5e513cf
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions database/sql/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 5e513cf

Please sign in to comment.