forked from otiai10/cwl.go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput_default.go
More file actions
35 lines (31 loc) · 811 Bytes
/
Copy pathinput_default.go
File metadata and controls
35 lines (31 loc) · 811 Bytes
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
package cwl
import (
"fmt"
"reflect"
)
// InputDefault represents "default" field in an element of "inputs".
type InputDefault struct {
Self interface{}
Kind reflect.Kind
}
// New constructs new "InputDefault".
func (_ InputDefault) New(i interface{}) *InputDefault {
dest := &InputDefault{Self: i, Kind: reflect.TypeOf(i).Kind()}
return dest
}
// Flatten ...
func (d *InputDefault) Flatten(binding *Binding) []string {
flattened := []string{}
switch v := d.Self.(type) {
case map[string]interface{}:
// TODO: more strict type casting ;(
class, ok := v["class"]
if ok && class == "File" {
flattened = append(flattened, fmt.Sprintf("%v", v["location"]))
}
}
if binding != nil && binding.Prefix != "" {
flattened = append([]string{binding.Prefix}, flattened...)
}
return flattened
}