Move code to external package
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
14586f0154
commit
da13cec2de
195 changed files with 56394 additions and 364 deletions
|
|
@ -22,10 +22,11 @@ import (
|
|||
"sort"
|
||||
"testing"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
garmTesting "github.com/cloudbase/garm/internal/testing"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/providers/common"
|
||||
|
||||
"gopkg.in/DATA-DOG/go-sqlmock.v1"
|
||||
|
||||
|
|
@ -109,8 +110,8 @@ func (s *InstancesTestSuite) SetupTest() {
|
|||
OSType: "linux",
|
||||
OSArch: "amd64",
|
||||
CallbackURL: "https://garm.example.com/",
|
||||
Status: common.InstanceRunning,
|
||||
RunnerStatus: common.RunnerIdle,
|
||||
Status: commonParams.InstanceRunning,
|
||||
RunnerStatus: params.RunnerIdle,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -156,18 +157,18 @@ func (s *InstancesTestSuite) SetupTest() {
|
|||
ProviderID: "update-provider-test",
|
||||
OSName: "ubuntu",
|
||||
OSVersion: "focal",
|
||||
Status: common.InstancePendingDelete,
|
||||
RunnerStatus: common.RunnerActive,
|
||||
Status: commonParams.InstancePendingDelete,
|
||||
RunnerStatus: params.RunnerActive,
|
||||
AgentID: 4,
|
||||
CreateAttempt: 3,
|
||||
Addresses: []params.Address{
|
||||
Addresses: []commonParams.Address{
|
||||
{
|
||||
Address: "12.10.12.10",
|
||||
Type: params.PublicAddress,
|
||||
Type: commonParams.PublicAddress,
|
||||
},
|
||||
{
|
||||
Address: "10.1.1.2",
|
||||
Type: params.PrivateAddress,
|
||||
Type: commonParams.PrivateAddress,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ package sql
|
|||
import (
|
||||
"time"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/providers/common"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
|
|
@ -63,8 +63,8 @@ type Pool struct {
|
|||
RunnerBootstrapTimeout uint
|
||||
Image string `gorm:"index:idx_pool_type"`
|
||||
Flavor string `gorm:"index:idx_pool_type"`
|
||||
OSType params.OSType
|
||||
OSArch params.OSArch
|
||||
OSType commonParams.OSType
|
||||
OSArch commonParams.OSArch
|
||||
Tags []*Tag `gorm:"many2many:pool_tags;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
||||
Enabled bool
|
||||
// ExtraSpecs is an opaque json that gets sent to the provider
|
||||
|
|
@ -143,13 +143,13 @@ type Instance struct {
|
|||
ProviderID *string `gorm:"uniqueIndex"`
|
||||
Name string `gorm:"uniqueIndex"`
|
||||
AgentID int64
|
||||
OSType params.OSType
|
||||
OSArch params.OSArch
|
||||
OSType commonParams.OSType
|
||||
OSArch commonParams.OSArch
|
||||
OSName string
|
||||
OSVersion string
|
||||
Addresses []Address `gorm:"foreignKey:InstanceID;constraint:OnDelete:CASCADE,OnUpdate:CASCADE;"`
|
||||
Status common.InstanceStatus
|
||||
RunnerStatus common.RunnerStatus
|
||||
Status commonParams.InstanceStatus
|
||||
RunnerStatus params.RunnerStatus
|
||||
CallbackURL string
|
||||
MetadataURL string
|
||||
ProviderFault []byte `gorm:"type:longblob"`
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"gorm.io/datatypes"
|
||||
"gorm.io/gorm"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
)
|
||||
|
||||
func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
|
||||
|
|
@ -75,10 +77,10 @@ func (s *sqlDatabase) sqlToParamsInstance(instance Instance) params.Instance {
|
|||
return ret
|
||||
}
|
||||
|
||||
func (s *sqlDatabase) sqlAddressToParamsAddress(addr Address) params.Address {
|
||||
return params.Address{
|
||||
func (s *sqlDatabase) sqlAddressToParamsAddress(addr Address) commonParams.Address {
|
||||
return commonParams.Address{
|
||||
Address: addr.Address,
|
||||
Type: params.AddressType(addr.Type),
|
||||
Type: commonParams.AddressType(addr.Type),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue