-
Notifications
You must be signed in to change notification settings - Fork 195
/
fnsplit.go
24 lines (18 loc) · 716 Bytes
/
fnsplit.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
package intrinsics
import "strings"
// FnSplit resolves the 'Fn::Split' AWS CloudFormation intrinsic function.
// See: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-split.html
func FnSplit(name string, input interface{}, template interface{}) interface{} {
// { "Fn::Split" : [ "delimiter", "source string" ] }
// Check that the input is an array
if arr, ok := input.([]interface{}); ok {
// The first element should be a string (the delimiter)
if delim, ok := arr[0].(string); ok {
// The second element should be a string (the content to join)
if str, ok := arr[1].(string); ok {
return strings.Split(str, delim)
}
}
}
return []string{}
}