Fix lint errors
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
a4ac85aa4a
commit
884be62a4d
32 changed files with 127 additions and 161 deletions
|
|
@ -101,13 +101,13 @@ func (s *sqlDatabase) getEntityPool(tx *gorm.DB, entityType params.GithubEntityT
|
|||
switch entityType {
|
||||
case params.GithubEntityTypeRepository:
|
||||
fieldName = entityTypeRepoName
|
||||
entityField = "Repository"
|
||||
entityField = repositoryFieldName
|
||||
case params.GithubEntityTypeOrganization:
|
||||
fieldName = entityTypeOrgName
|
||||
entityField = "Organization"
|
||||
entityField = organizationFieldName
|
||||
case params.GithubEntityTypeEnterprise:
|
||||
fieldName = entityTypeEnterpriseName
|
||||
entityField = "Enterprise"
|
||||
entityField = enterpriseFieldName
|
||||
default:
|
||||
return Pool{}, fmt.Errorf("invalid entityType: %v", entityType)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package sql
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func (s *sqlDatabase) CreateScaleSetInstance(_ context.Context, scaleSetID uint, param params.CreateInstanceParams) (instance params.Instance, err error) {
|
||||
|
|
|
|||
|
|
@ -18,13 +18,14 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
func (s *sqlDatabase) ListAllScaleSets(_ context.Context) ([]params.ScaleSet, error) {
|
||||
|
|
@ -136,13 +137,13 @@ func (s *sqlDatabase) listEntityScaleSets(tx *gorm.DB, entityType params.GithubE
|
|||
switch entityType {
|
||||
case params.GithubEntityTypeRepository:
|
||||
fieldName = entityTypeRepoName
|
||||
preloadEntity = "Repository"
|
||||
preloadEntity = repositoryFieldName
|
||||
case params.GithubEntityTypeOrganization:
|
||||
fieldName = entityTypeOrgName
|
||||
preloadEntity = "Organization"
|
||||
preloadEntity = organizationFieldName
|
||||
case params.GithubEntityTypeEnterprise:
|
||||
fieldName = entityTypeEnterpriseName
|
||||
preloadEntity = "Enterprise"
|
||||
preloadEntity = enterpriseFieldName
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid entityType: %v", entityType)
|
||||
}
|
||||
|
|
@ -189,7 +190,7 @@ func (s *sqlDatabase) ListEntityScaleSets(_ context.Context, entity params.Githu
|
|||
return ret, nil
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) UpdateEntityScaleSet(_ context.Context, entity params.GithubEntity, scaleSetID uint, param params.UpdateScaleSetParams, callback func(old, new params.ScaleSet) error) (updatedScaleSet params.ScaleSet, err error) {
|
||||
func (s *sqlDatabase) UpdateEntityScaleSet(_ context.Context, entity params.GithubEntity, scaleSetID uint, param params.UpdateScaleSetParams, callback func(old, newSet params.ScaleSet) error) (updatedScaleSet params.ScaleSet, err error) {
|
||||
defer func() {
|
||||
if err == nil {
|
||||
s.sendNotify(common.ScaleSetEntityType, common.UpdateOperation, updatedScaleSet)
|
||||
|
|
@ -348,7 +349,7 @@ func (s *sqlDatabase) GetScaleSetByID(_ context.Context, scaleSet uint) (params.
|
|||
return s.sqlToCommonScaleSet(set)
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) DeleteScaleSetByID(ctx context.Context, scaleSetID uint) (err error) {
|
||||
func (s *sqlDatabase) DeleteScaleSetByID(_ context.Context, scaleSetID uint) (err error) {
|
||||
var scaleSet params.ScaleSet
|
||||
defer func() {
|
||||
if err == nil && scaleSet.ID != 0 {
|
||||
|
|
@ -380,7 +381,7 @@ func (s *sqlDatabase) DeleteScaleSetByID(ctx context.Context, scaleSetID uint) (
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) SetScaleSetLastMessageID(ctx context.Context, scaleSetID uint, lastMessageID int64) (err error) {
|
||||
func (s *sqlDatabase) SetScaleSetLastMessageID(_ context.Context, scaleSetID uint, lastMessageID int64) (err error) {
|
||||
var scaleSet params.ScaleSet
|
||||
defer func() {
|
||||
if err == nil && scaleSet.ID != 0 {
|
||||
|
|
@ -407,7 +408,7 @@ func (s *sqlDatabase) SetScaleSetLastMessageID(ctx context.Context, scaleSetID u
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) SetScaleSetDesiredRunnerCount(ctx context.Context, scaleSetID uint, desiredRunnerCount int) (err error) {
|
||||
func (s *sqlDatabase) SetScaleSetDesiredRunnerCount(_ context.Context, scaleSetID uint, desiredRunnerCount int) (err error) {
|
||||
var scaleSet params.ScaleSet
|
||||
defer func() {
|
||||
if err == nil && scaleSet.ID != 0 {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ import (
|
|||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
)
|
||||
|
||||
const (
|
||||
repositoryFieldName string = "Repository"
|
||||
organizationFieldName string = "Organization"
|
||||
enterpriseFieldName string = "Enterprise"
|
||||
)
|
||||
|
||||
// newDBConn returns a new gorm db connection, given the config
|
||||
func newDBConn(dbCfg config.Database) (conn *gorm.DB, err error) {
|
||||
dbType, connURI, err := dbCfg.GormParams()
|
||||
|
|
|
|||
|
|
@ -753,8 +753,7 @@ func (s *sqlDatabase) AddEntityEvent(ctx context.Context, entity params.GithubEn
|
|||
if maxEvents == 0 {
|
||||
return errors.Wrap(runnerErrors.ErrBadRequest, "max events cannot be 0")
|
||||
}
|
||||
// TODO(gabriel-samfira): Should we send watcher notifications for events?
|
||||
// Not sure it's of any value.
|
||||
|
||||
switch entity.EntityType {
|
||||
case params.GithubEntityTypeRepository:
|
||||
return s.addRepositoryEvent(ctx, entity.ID, event, eventLevel, statusMessage, maxEvents)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue