MCPcopy Create free account
hub / github.com/cloudbase/garm / getOrCreateTag

Method getOrCreateTag

database/sql/util.go:560–577  ·  view source on GitHub ↗
(tx *gorm.DB, tagName string)

Source from the content-addressed store, hash-verified

558}
559
560func (s *sqlDatabase) getOrCreateTag(tx *gorm.DB, tagName string) (Tag, error) {
561 var tag Tag
562 q := tx.Where("name = ? COLLATE NOCASE", tagName).First(&tag)
563 if q.Error == nil {
564 return tag, nil
565 }
566 if !errors.Is(q.Error, gorm.ErrRecordNotFound) {
567 return Tag{}, fmt.Errorf("error fetching tag from database: %w", q.Error)
568 }
569 newTag := Tag{
570 Name: tagName,
571 }
572
573 if err := tx.Create(&newTag).Error; err != nil {
574 return Tag{}, fmt.Errorf("error creating tag: %w", err)
575 }
576 return newTag, nil
577}
578
579// nolint:gocyclo
580func (s *sqlDatabase) updatePool(tx *gorm.DB, pool Pool, param params.UpdatePoolParams) (params.Pool, int64, error) {

Callers 3

CreateEntityPoolMethod · 0.95
CreateEntityScaleSetMethod · 0.95
updatePoolMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected