Пример #1
0
Файл: run.go Проект: pulcy/j2
// isModifiedPredicate creates a predicate that returns true when the given unit file is modified
func (d *Deployment) isModifiedPredicate(sg scalingGroupUnits, f scheduler.Scheduler, ui *stateUI) func(string) bool {
	return func(unitName string) bool {
		if d.force {
			return true
		}
		ui.MessageSink <- fmt.Sprintf("Checking %s for modifications", unitName)
		cat, err := f.Cat(unitName)
		if err != nil {
			ui.Verbosef("Failed to cat '%s': %#v\n", unitName, err)
			return true // Assume it is modified
		}
		newUnit, err := sg.get(unitName)
		if err != nil {
			ui.Verbosef("Failed to read new '%s' unit: %#v\n", unitName, err)
			return true // Assume it is modified
		}
		if !compareUnitContent(unitName, cat, newUnit.Content(), ui) {
			return true
		}
		ui.Verbosef("Unit '%s' has not changed\n", unitName)
		return false
	}
}