Merge v1.2.1-master
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
a590155b0b
commit
aeb17182b4
396 changed files with 27271 additions and 9969 deletions
20
vendor/github.com/JamesClonk/vultr/lib/iso.go
generated
vendored
20
vendor/github.com/JamesClonk/vultr/lib/iso.go
generated
vendored
|
@ -1,5 +1,10 @@
|
|||
package lib
|
||||
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ISO image on Vultr
|
||||
type ISO struct {
|
||||
ID int `json:"ISOID"`
|
||||
|
@ -9,6 +14,20 @@ type ISO struct {
|
|||
MD5sum string `json:"md5sum"`
|
||||
}
|
||||
|
||||
type isos []ISO
|
||||
|
||||
func (s isos) Len() int { return len(s) }
|
||||
func (s isos) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
func (s isos) Less(i, j int) bool {
|
||||
// sort order: filename, created
|
||||
if strings.ToLower(s[i].Filename) < strings.ToLower(s[j].Filename) {
|
||||
return true
|
||||
} else if strings.ToLower(s[i].Filename) > strings.ToLower(s[j].Filename) {
|
||||
return false
|
||||
}
|
||||
return s[i].Created < s[j].Created
|
||||
}
|
||||
|
||||
// GetISO returns a list of all ISO images on Vultr account
|
||||
func (c *Client) GetISO() ([]ISO, error) {
|
||||
var isoMap map[string]ISO
|
||||
|
@ -20,5 +39,6 @@ func (c *Client) GetISO() ([]ISO, error) {
|
|||
for _, iso := range isoMap {
|
||||
isoList = append(isoList, iso)
|
||||
}
|
||||
sort.Sort(isos(isoList))
|
||||
return isoList, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue