Added more CLI commands and API endpoints

This commit is contained in:
Gabriel Adrian Samfira 2022-05-05 13:07:06 +00:00
parent 1e2e96ccb5
commit d9c65872e8
24 changed files with 901 additions and 116 deletions

View file

@ -1,9 +1,11 @@
package sql
import (
"fmt"
"garm/params"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"gorm.io/gorm"
)
@ -73,6 +75,18 @@ func (s *sqlDatabase) sqlToCommonPool(pool Pool) params.Pool {
Instances: make([]params.Instance, len(pool.Instances)),
}
if pool.RepoID != uuid.Nil {
ret.RepoID = pool.RepoID.String()
if pool.Repository.Owner != "" && pool.Repository.Name != "" {
ret.RepoName = fmt.Sprintf("%s/%s", pool.Repository.Owner, pool.Repository.Name)
}
}
if pool.OrgID != uuid.Nil && pool.Organization.Name != "" {
ret.OrgID = pool.OrgID.String()
ret.OrgName = pool.Organization.Name
}
for idx, val := range pool.Tags {
ret.Tags[idx] = s.sqlToCommonTags(*val)
}