/
formula.go
119 lines (100 loc) · 2.51 KB
/
formula.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
package wfapi
type FormulaCapsule struct {
Formula *Formula
}
type Formula struct {
Inputs struct {
Keys []SandboxPort
Values map[SandboxPort]FormulaInput
}
Action Action
Outputs struct {
Keys []OutputName
Values map[OutputName]GatherDirective
}
}
type SandboxPort struct {
// FIXME: although golang has permitted us to use this as a map key... we shouldn't; it's trouble.
// The pointers here mean that constructing an equal value is nearly possible, which is unintended and unpleasant to use.
// Fixing this may require some work upstream in go-ipld-prime's bindnode package:
// in order to stop using pointers here, it will need to support integer indicators instead.
SandboxPath *SandboxPath
SandboxVar *SandboxVar
}
type SandboxPath string
type SandboxVar string
type FormulaInput struct {
FormulaInputSimple *FormulaInputSimple
FormulaInputComplex *FormulaInputComplex
}
func (fi *FormulaInput) Basis() *FormulaInputSimple {
switch {
case fi.FormulaInputSimple != nil:
return fi.FormulaInputSimple
case fi.FormulaInputComplex != nil:
return &fi.FormulaInputComplex.Basis
default:
panic("unreachable")
}
}
type Literal string
type FormulaInputSimple struct {
WareID *WareID
Mount *Mount
Literal *Literal
}
type FormulaInputComplex struct {
Basis FormulaInputSimple
Filters FilterMap
}
type OutputName string
type GatherDirective struct {
From SandboxPort
Packtype *Packtype // 'optional': should be absent iff SandboxPort is a SandboxVar.
Filters *FilterMap // 'optional': must be absent if SandboxPort is a SandboxVar.
}
// Action is a union (aka sum type). Exactly one of its fields will be set.
type Action struct {
Echo *Action_Echo
Exec *Action_Exec
Script *Action_Script
}
type Action_Echo struct {
// Nothing here. This is just a debug action, and needs no detailed configuration.
}
type Action_Exec struct {
Command []string
Network *bool
}
type Action_Script struct {
Interpreter string
Contents []string
Network *bool
}
type FormulaContextCapsule struct {
FormulaContext *FormulaContext
}
type FormulaContext struct {
Warehouses struct {
Keys []WareID
Values map[WareID]WarehouseAddr
}
}
type FormulaAndContext struct {
Formula FormulaCapsule
Context *FormulaContextCapsule
}
type RunRecord struct {
Guid string
Time int64
FormulaID string
Exitcode int
Results struct {
Keys []OutputName
Values map[OutputName]FormulaInputSimple
}
}
type FormulaExecConfig struct {
Interactive bool
DisableMemoization bool
}