forked from rai-project/model
/
build_spec.go
83 lines (69 loc) · 2.67 KB
/
build_spec.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package model
import time "time"
// easyjson:json
type BuildCommands []string
// easyjson:json
type Push struct {
Push bool `json:"push" yaml:"push"`
ImageName string `json:"image_name" yaml:"image_name"`
Registry string `json:"registry" yaml:"registry"`
Credentials DockerHubCredentials `json:"credentials" yaml:"credentials"`
}
// easyjson:json
type BuildImageSpecification struct {
ImageName string `json:"image_name" yaml:"image_name"`
Dockerfile string `json:"dockerfile" yaml:"dockerfile"`
Push *Push `json:"push" yaml:"push"`
NoCache bool `json:"no_cache" yaml:"no_cache"`
}
// easyjson:json
type RAIBuildSpecification struct {
Version string `json:"version" yaml:"version"`
ContainerImage string `json:"image" yaml:"image"`
}
// easyjson:json
type CommandsBuildSpecification struct {
BuildImage *BuildImageSpecification `json:"build_image,omitempty" yaml:"build_image,omitempty"`
Build BuildCommands `json:"build" yaml:"build"`
}
// easyjson:json
type BuildSpecification struct {
RAI RAIBuildSpecification `json:"rai" yaml:"rai" validate:"required"`
Resources Resources `json:"resources" yaml:"resources" validate:"required"`
Commands CommandsBuildSpecification `json:"commands" yaml:"commands" validate:"required"`
}
// easyjson:json
type Resources struct {
CPU CPUResources `json:"cpu" yaml:"cpu" validate:"required,dive,required"`
GPU *GPUResources `json:"gpu,omitempty" yaml:"gpu"`
DataResources *DataResources `json:"dataresources,omitempty" yaml:"dataresources"`
Limits Limits `json:"limits" yaml:"limits"`
}
// easyjson:json
type Limits struct {
Network bool `json:"network" yaml:"network"`
Time time.Duration `json:"time" yaml:"time"`
DataSize uint64 `json:"datasize" yaml:"datasize"`
}
// easyjson:json
type CPUResources struct {
Architecture string `json:"architecture" yaml:"architecture" validate:"required"`
}
// easyjson:json
type GPUResources struct {
Architecture string `json:"architecture" yaml:"architecture" validate:"required"`
Count int `json:"count" yaml:"count" validate:"required"`
Memory int64 `json:"memory" yaml:"memory" validate:"required"`
}
type MountSource struct {
URL string `json:"url" yaml:"url" validate:"required"`
Extract bool `json:"extract" yaml:"extract"`
}
// easyjson:json
type MountResource struct {
Mount string `json:"mount" yaml:"mount" validate:"required"` // mount location
Source MountSource `json:"source" yaml:"source"`
Cache bool `json:"cache" yaml:"cache"`
}
// easyjson:json
type DataResources []MountResource