v1.2.1
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create CD-ROM image
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for create image
|
||||
|
||||
69
pkg/cloudbroker/image/filter.go
Normal file
69
pkg/cloudbroker/image/filter.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package image
|
||||
|
||||
// FilterById returns ListImages with specified ID.
|
||||
func (li ListImages) FilterById(id uint64) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.ID == id
|
||||
}
|
||||
|
||||
return li.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByName returns ListImages with specified Name.
|
||||
func (li ListImages) FilterByName(name string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.Name == name
|
||||
}
|
||||
|
||||
return li.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByStatus returns ListImages with specified Status.
|
||||
func (li ListImages) FilterByStatus(status string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.Status == status
|
||||
}
|
||||
|
||||
return li.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByTechStatus returns ListImages with specified TechStatus.
|
||||
func (li ListImages) FilterByTechStatus(techStatus string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.TechStatus == techStatus
|
||||
}
|
||||
|
||||
return li.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterByBootType returns ListImages with specified BootType.
|
||||
func (li ListImages) FilterByBootType(bootType string) ListImages {
|
||||
predicate := func(ri RecordImage) bool {
|
||||
return ri.BootType == bootType
|
||||
}
|
||||
|
||||
return li.FilterFunc(predicate)
|
||||
}
|
||||
|
||||
// FilterFunc allows filtering ListImages based on a user-specified predicate.
|
||||
func (li ListImages) FilterFunc(predicate func(RecordImage) bool) ListImages {
|
||||
var result ListImages
|
||||
|
||||
for _, item := range li {
|
||||
if predicate(item) {
|
||||
result = append(result, item)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FindOne returns first found RecordImage
|
||||
// If none was found, returns an empty struct.
|
||||
func (li ListImages) FindOne() RecordImage {
|
||||
if len(li) == 0 {
|
||||
return RecordImage{}
|
||||
}
|
||||
|
||||
return li[0]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Lists all the images. A image is a template which can be used to deploy machines
|
||||
package image
|
||||
|
||||
import "github.com/rudecs/decort-sdk/interfaces"
|
||||
import "repos.digitalenergy.online/BASIS/decort-golang-sdk/interfaces"
|
||||
|
||||
// Structure for creating request to image
|
||||
type Image struct {
|
||||
|
||||
43
pkg/cloudbroker/image/serialize.go
Normal file
43
pkg/cloudbroker/image/serialize.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package image
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/serialization"
|
||||
)
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (li ListImages) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(li) == 0 {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(li, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(li)
|
||||
}
|
||||
|
||||
// Serialize returns JSON-serialized []byte. Used as a wrapper over json.Marshal and json.MarshalIndent functions.
|
||||
//
|
||||
// In order to serialize with indent make sure to follow these guidelines:
|
||||
// - First argument -> prefix
|
||||
// - Second argument -> indent
|
||||
func (ri RecordImage) Serialize(params ...string) (serialization.Serialized, error) {
|
||||
if len(params) > 1 {
|
||||
prefix := params[0]
|
||||
indent := params[1]
|
||||
|
||||
return json.MarshalIndent(ri, prefix, indent)
|
||||
}
|
||||
|
||||
return json.Marshal(ri)
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/rudecs/decort-sdk/internal/validators"
|
||||
"repos.digitalenergy.online/BASIS/decort-golang-sdk/internal/validators"
|
||||
)
|
||||
|
||||
// Request struct for sync create image
|
||||
|
||||
Reference in New Issue
Block a user