// FromConfig creates the struct representation of a step watching a file for a certain string
FromConfig creates the struct representation of a step watching a file for a certain string
// FromConfig creates the struct representation of a step watching a file for a certain string
func (watch *Watch) FromConfig(configYaml map[string]interface{}) error {
	watch.Kind = KindWatch
	if description, ok := configYaml["Description"]; ok {
		watch.Description = description.(string)
	}
	if preferencesYaml, ok := configYaml["Preferences"].(map[string]interface{}); ok {
		if path, ok := preferencesYaml["Path"].(string); ok {
			watch.Path = path
		} else {
			return fmt.Errorf("preference \"Path\" (string) must be set for %s step", watch.GetKind())
		}
		if message, ok := preferencesYaml["Message"].(string); ok {
			watch.Message = message
		} else {
			return fmt.Errorf("preference \"Message\" (string) must be set for %s step", watch.GetKind())
		}
		if timeout, ok := preferencesYaml["Timeout"].(int); ok {
			watch.Timeout = timeout
		} else {
			watch.Timeout = 300
		}
	} else {
		return fmt.Errorf("preferences must be set for %s step", watch.GetKind())
	}
	return nil
}
func ( watch * Watch ) FromConfig ( configYaml map [ string ] interface { } ) error { watch . Kind = KindWatch if description , ok := configYaml [ " " ] ; ok { watch . Description = description . ( string ) } if preferencesYaml , ok := configYaml [ " " ] . ( map [ string ] interface { } ) ; ok { if path , ok := preferencesYaml [ " " ] . ( string ) ; ok { watch . Path = path } else { return fmt . Errorf ( " \" \" " , watch . GetKind ( ) ) } if message , ok := preferencesYaml [ " " ] . ( string ) ; ok { watch . Message = message } else { return fmt . Errorf ( " \" \" " , watch . GetKind ( ) ) } if timeout , ok := preferencesYaml [ " " ] . ( int ) ; ok { watch . Timeout = timeout } else { watch . Timeout = 300 } } else { return fmt . Errorf ( " " , watch . GetKind ( ) ) } return nil }
FromConfig creates the struct representation of a step watching a file for a certain string
FromConfig creates the struct representation of a step watching a file for a certain string
// Read path preference // Read message preference // Read timeout preference // Default timeout is 300s