-
Notifications
You must be signed in to change notification settings - Fork 1
/
disk.go
61 lines (47 loc) · 1.47 KB
/
disk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package storix
import (
"strings"
"machinerun.io/disko"
)
// For YAML parsing as disko types dont support YAML
type DiskType disko.DiskType
func ToDiskType(d disko.DiskType) DiskType {
return DiskType(d)
}
func (d DiskType) String() string {
return disko.DiskType(d).String()
}
func (d DiskType) MarshalText() ([]byte, error) {
return []byte(d.String()), nil
}
func (d *DiskType) UnmarshalText(text []byte) error {
s := strings.ToUpper(string(text))
*d = ToDiskType(disko.StringToDiskType(s))
return nil
}
// For YAML parsing as disko types dont support YAML
type AttachmentType disko.AttachmentType
func ToAttachment(a disko.AttachmentType) AttachmentType {
return AttachmentType(a)
}
func (a AttachmentType) String() string {
return disko.AttachmentType(a).String()
}
func (a AttachmentType) MarshalText() ([]byte, error) {
return []byte(a.String()), nil
}
func (a *AttachmentType) UnmarshalText(text []byte) error {
s := strings.ToUpper(string(text))
*a = ToAttachment(disko.StringToAttachmentType(s))
return nil
}
type DiskProfile struct {
Pool string `json:"disk-pool" yaml:"disk-pool"`
Match []DiskMatch `json:"match" yaml:"match"`
}
type DiskMatch struct {
Type DiskType `json:"type,omitempty" yaml:"type,omitempty"`
Attachment AttachmentType `json:"attachment,omitempty" yaml:"attachment,omitempty"`
MinSize ByteSize `json:"min,omitempty" yaml:"min,omitempty"`
MaxSize ByteSize `json:"max,omitempty" yaml:"max,omitempty"`
}