Exemple #1
0
func diff(existing mapset.Set, updated mapset.Set) (added []net.IP, removed []net.IP) {
	addSlice := updated.Difference(existing).ToSlice()
	removeSlice := existing.Difference(updated).ToSlice()
	for _, ip := range addSlice {
		added = append(added, net.ParseIP(ip.(string)))
	}
	for _, ip := range removeSlice {
		removed = append(removed, net.ParseIP(ip.(string)))
	}
	return
}
Exemple #2
0
func filesUpdated(set set.Set) {
	fmt.Println("Updated:")
	toRun.Clear()
	for file := range set.Iter() {
		fmt.Println(file)
		filestr, ok := file.(string)
		if !ok {
			fmt.Println("Error converting to string:\n", file)
			continue
		}
		for _, entry := range config {
			for _, pattern := range entry.Files {
				if toRun.Contains(entry.Name) {
					break
				}
				match, err := glob.Match(pattern, filestr)
				if err != nil {
					fmt.Println(err)
					continue
				}
				if match {
					toRun.Add(entry.Name)
				}
			}
		}
	}
	run()
}