update go.mod and imports
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create CD-ROM image
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create image
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package image
|
||||
|
||||
// FilterById returns ListImages with specified ID.
|
||||
func (li ListImages) FilterById(id uint64) ListImages {
|
||||
func (li ListImages) FilterByID(id uint64) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.ID == id
|
||||
}
|
||||
|
||||
214
pkg/cloudbroker/image/filter_test.go
Normal file
214
pkg/cloudbroker/image/filter_test.go
Normal file
@@ -0,0 +1,214 @@
|
||||
package image
|
||||
|
||||
import "testing"
|
||||
|
||||
var images = ListImages{
|
||||
RecordImage{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
AccountID: 0,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
ComputeCIID: 0,
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
Enabled: true,
|
||||
GID: 212,
|
||||
GUID: 9882,
|
||||
History: []History{},
|
||||
HotResize: true,
|
||||
ID: 9882,
|
||||
LastModified: 0,
|
||||
LinkTo: 0,
|
||||
Milestones: 363491,
|
||||
Name: "u16",
|
||||
Password: "",
|
||||
Pool: "vmstor",
|
||||
PresentTo: []uint64{},
|
||||
ProviderName: "",
|
||||
PurgeAttempts: 0,
|
||||
ReferenceID: "sample_reference_id_u16",
|
||||
ResID: "b321318-3214as-324-213-fdas",
|
||||
ResName: "templates/image_9882",
|
||||
RescueCD: false,
|
||||
SEPID: 2504,
|
||||
SharedWith: []uint64{},
|
||||
Size: 5,
|
||||
Status: "CREATED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "linux",
|
||||
URL: "http://sample_url:8000/u16",
|
||||
Username: "",
|
||||
Version: "",
|
||||
Virtual: false,
|
||||
},
|
||||
RecordImage{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
AccountID: 0,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
BootType: "bois",
|
||||
Bootable: true,
|
||||
ComputeCIID: 0,
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
Enabled: false,
|
||||
GID: 212,
|
||||
GUID: 9884,
|
||||
History: []History{},
|
||||
HotResize: false,
|
||||
ID: 9884,
|
||||
LastModified: 0,
|
||||
LinkTo: 0,
|
||||
Milestones: 363499,
|
||||
Name: "alpine-virt-3.17",
|
||||
Password: "",
|
||||
Pool: "vmstor",
|
||||
PresentTo: []uint64{},
|
||||
ProviderName: "",
|
||||
PurgeAttempts: 0,
|
||||
ReferenceID: "sample_reference_id_alpine",
|
||||
ResID: "31d1d410-74f1-4e09-866b-046a5a8433c3",
|
||||
ResName: "templates/image_9884",
|
||||
RescueCD: false,
|
||||
SEPID: 2504,
|
||||
SharedWith: []uint64{},
|
||||
Size: 1,
|
||||
Status: "CREATED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "linux",
|
||||
URL: "http://sample_url:8000/alpine-virt-3",
|
||||
Username: "",
|
||||
Version: "",
|
||||
Virtual: true,
|
||||
},
|
||||
RecordImage{
|
||||
UNCPath: "",
|
||||
CKey: "",
|
||||
Meta: []interface{}{
|
||||
"osismodel",
|
||||
"cloudbroker",
|
||||
"image",
|
||||
1,
|
||||
},
|
||||
AccountID: 1,
|
||||
ACL: []ACL{},
|
||||
Architecture: "X86_64",
|
||||
BootType: "bios",
|
||||
Bootable: true,
|
||||
ComputeCIID: 0,
|
||||
DeletedTime: 0,
|
||||
Description: "",
|
||||
Drivers: []string{
|
||||
"KVM_X86",
|
||||
},
|
||||
Enabled: true,
|
||||
GID: 212,
|
||||
GUID: 9885,
|
||||
History: []History{},
|
||||
HotResize: true,
|
||||
ID: 9885,
|
||||
LastModified: 0,
|
||||
LinkTo: 0,
|
||||
Milestones: 363513,
|
||||
Name: "test",
|
||||
Password: "",
|
||||
Pool: "vmstor",
|
||||
PresentTo: []uint64{},
|
||||
ProviderName: "",
|
||||
PurgeAttempts: 0,
|
||||
ReferenceID: "sample_reference_id_test",
|
||||
ResID: "1f53b815-1ac9-4a4b-af98-a0a3b69a34bb",
|
||||
ResName: "templates/image_9885",
|
||||
RescueCD: false,
|
||||
SEPID: 2505,
|
||||
SharedWith: []uint64{},
|
||||
Size: 4,
|
||||
Status: "DESTROYED",
|
||||
TechStatus: "ALLOCATED",
|
||||
Type: "linux",
|
||||
URL: "http://sample_url:8000/test",
|
||||
Username: "",
|
||||
Version: "",
|
||||
Virtual: false,
|
||||
},
|
||||
}
|
||||
|
||||
func TestFilterByID(t *testing.T) {
|
||||
actual := images.FilterByID(9885).FindOne()
|
||||
|
||||
if actual.ID != 9885 {
|
||||
t.Fatal("expected ID 9885, found: ", actual.ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByName(t *testing.T) {
|
||||
actual := images.FilterByName("u16").FindOne()
|
||||
|
||||
if actual.Name != "u16" {
|
||||
t.Fatal("expected Name 'u16', found: ", actual.Name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByStatus(t *testing.T) {
|
||||
actual := images.FilterByStatus("CREATED")
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.Status != "CREATED" {
|
||||
t.Fatal("expected Status 'CREATED', found: ", item.Status)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterByBootType(t *testing.T) {
|
||||
actual := images.FilterByBootType("bios")
|
||||
|
||||
if len(actual) != 2 {
|
||||
t.Fatal("expected 2 found, actual: ", len(actual))
|
||||
}
|
||||
|
||||
for _, item := range actual {
|
||||
if item.BootType != "bios" {
|
||||
t.Fatal("expected BootType 'bios', found: ", item.BootType)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterFunc(t *testing.T) {
|
||||
actual := images.FilterFunc(func(ri RecordImage) bool {
|
||||
return ri.Virtual == true
|
||||
})
|
||||
|
||||
if len(actual) != 1 {
|
||||
t.Fatal("expected 1 found, actual: ", len(actual))
|
||||
}
|
||||
|
||||
if actual[0].Virtual != true {
|
||||
t.Fatal("expected Virtual true, found false")
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Lists all the images. A image is a template which can be used to deploy machines
|
||||
package image
|
||||
|
||||
import "repos.digitalenergy.online/BASIS/decort-golang-sdk/interfaces"
|
||||
import "repository.basistech.ru/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to image
|
||||
type Image struct {
|
||||
|
||||
@@ -3,7 +3,7 @@ package image
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/serialization"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for sync create image
|
||||
|
||||
Reference in New Issue
Block a user