示例#1
0
func jsonFilter(list interface{}, filter func(i, v interface{}) bool, unpack interface{}) (err error) {
	var idx interface{}

	if o := itertools.Filter(list, filter); len(o) > 0 {
		itertools.PairUnPack(<-o, &idx, unpack)

	} else {
		err = fmt.Errorf("no matches in list for filter")
	}
	return
}
func getYamlFilename(filelist []os.FileInfo) (filename string) {
	var (
		file os.FileInfo
		idx  int
	)

	if out := itertools.Filter(filelist, namefilter); len(out) > 0 {
		itertools.PairUnPack(<-out, &idx, &file)
		filename = file.Name()
	}
	return
}
示例#3
0
//GetDeploymentName - returns the name of the deployment
func GetDeploymentName(jsonObj InstallationCompareObject) (deploymentName string, err error) {

	if o := itertools.Filter(jsonObj.Products, filterERProducts); len(o) > 0 {
		var (
			idx  interface{}
			prod productCompareObject
		)
		itertools.PairUnPack(<-o, &idx, &prod)
		deploymentName = prod.Installation_name

	} else {
		err = fmt.Errorf("could not find a cf install to pull name from")
	}
	return
}