-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge new spiff to spiff++ release 1.0.8-ms.6
- Loading branch information
Showing
29 changed files
with
2,936 additions
and
1,216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dynaml | ||
|
||
import ( | ||
"github.com/cloudfoundry-incubator/spiff/yaml" | ||
) | ||
|
||
func func_compact(arguments []interface{}, binding Binding) (interface{}, EvaluationInfo, bool) { | ||
info := DefaultInfo() | ||
|
||
if len(arguments) != 1 { | ||
return info.Error("compact takes exactly 1 argument") | ||
} | ||
|
||
list, ok := arguments[0].([]yaml.Node) | ||
if !ok { | ||
return info.Error("invalid type for function compact") | ||
} | ||
|
||
var newList []yaml.Node | ||
|
||
for _, v := range list { | ||
found := true | ||
|
||
if v != nil && v.Value() != nil { | ||
switch elem := v.Value().(type) { | ||
case string: | ||
found = len(elem) > 0 | ||
case int64: | ||
case map[string]yaml.Node: | ||
found = len(elem) > 0 | ||
case []yaml.Node: | ||
found = len(elem) > 0 | ||
} | ||
if found { | ||
newList = append(newList, v) | ||
} | ||
} | ||
} | ||
return newList, info, true | ||
} |
Oops, something went wrong.