-
Notifications
You must be signed in to change notification settings - Fork 7
/
requirement.go
160 lines (144 loc) · 4.2 KB
/
requirement.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package cwl
// Requirement represent an element of "requirements".
type Requirement struct {
Class string
InlineJavascriptRequirement
SchemaDefRequirement
DockerRequirement
SoftwareRequirement
InitialWorkDirRequirement
EnvVarRequirement
ShellCommandRequirement
ResourceRequirement
Import string
}
// New constructs "Requirement" struct from interface.
func (_ Requirement) New(i interface{}) Requirement {
dest := Requirement{}
switch x := i.(type) {
case map[string]interface{}:
for key, v := range x {
switch key {
case "class":
dest.Class = v.(string)
case "dockerPull":
dest.DockerPull = v.(string)
case "dockerOutputDirectory":
dest.DockerOutputDirectory = v.(string)
case "types":
dest.Types = Type{}.NewList(v)
case "expressionLib":
dest.ExpressionLib = JavascriptExpression{}.NewList(v)
case "envDef":
dest.EnvDef = EnvDef{}.NewList(v)
case "listing":
dest.Listing = Entry{}.NewList(v)
case "$import":
dest.Import = v.(string)
}
}
}
return dest
}
// Requirements represents "requirements" field in CWL.
type Requirements []Requirement
// New constructs "Requirements" struct from interface.
func (_ Requirements) New(i interface{}) Requirements {
dest := Requirements{}
switch x := i.(type) {
case []interface{}:
for _, r := range x {
dest = append(dest, Requirement{}.New(r))
}
case map[string]interface{}:
for key, v := range x {
r := Requirement{}.New(v)
r.Class = key
dest = append(dest, r)
}
}
return dest
}
// InlineJavascriptRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#InlineJavascriptRequirement
type InlineJavascriptRequirement struct {
ExpressionLib []JavascriptExpression
}
// JavascriptExpression represents an element of "expressionLib" of InlineJavascriptRequirement.
type JavascriptExpression struct {
Kind string // could be "" or "$include"
Value string
}
func (_ JavascriptExpression) NewList(i interface{}) []JavascriptExpression {
dest := []JavascriptExpression{}
switch x := i.(type) {
case []interface{}:
for _, v := range x {
dest = append(dest, JavascriptExpression{}.New(v))
}
}
return dest
}
func (_ JavascriptExpression) New(i interface{}) JavascriptExpression {
dest := JavascriptExpression{}
switch x := i.(type) {
case string:
dest.Kind = "$execute"
dest.Value = x
case map[string]interface{}:
for key, v := range x {
switch key {
case "$include":
dest.Kind = key
dest.Value = v.(string)
}
}
}
return dest
}
// SchemaDefRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#SchemaDefRequirement
type SchemaDefRequirement struct {
Types []Type
}
// DockerRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#DockerRequirement
type DockerRequirement struct {
DockerPull string
DockerLoad string
DockerFile string
DockerImport string
DockerImageID string
DockerOutputDirectory string
}
// SoftwareRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#SoftwareRequirement
type SoftwareRequirement struct {
Packages []SoftwarePackage
}
// SoftwarePackage represents an element of SoftwarePackage.Packages
type SoftwarePackage struct {
Package string
Versions []string
Specs []string
}
// InitialWorkDirRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#InitialWorkDirRequirement
type InitialWorkDirRequirement struct {
Listing []Entry
}
// EnvVarRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#EnvVarRequirement
type EnvVarRequirement struct {
EnvDef []EnvDef
}
// ShellCommandRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#ShellCommandRequirement
type ShellCommandRequirement struct {
}
// ResourceRequirement is supposed to be embeded to Requirement.
// @see http://www.commonwl.org/v1.0/CommandLineTool.html#ResourceRequirement
type ResourceRequirement struct {
CoresMin int
CoresMax int
}