Exemplo n.º 1
0
func validateRawJson(rawJson []byte, fileName string) []error {
	var f interface{}
	err := json.Unmarshal(rawJson, &f)
	if err != nil {
		log.Printf("ERROR (%s): invalid json!", fileName)
		printErrorDetails(rawJson, err)
		return []error{err}
	}
	var errs []error
	m := f.(map[string]interface{})
	rejectOldTaskDefinitions := false
	//it was known as 'FormatVersion' until v0.9
	if fv, keyExists := m["FormatVersion"]; keyExists {
		m["ConfigVersion"] = fv
	}
	if fv, keyExists := m["ConfigVersion"]; keyExists {
		configVersion := fv.(string)
		if -1 == typeutils.StringSlicePos(GOXC_CONFIG_SUPPORTED, configVersion) {
			log.Printf("WARNING (%s): is an old config file. File version: %s. Current version %v", fileName, configVersion, GOXC_CONFIG_VERSION)
			rejectOldTaskDefinitions = true
		}
	} else {
		log.Printf("WARNING (%s): format version not specified. Please ensure this file format is up to date.", fileName)
		rejectOldTaskDefinitions = true
	}
	if s, keyExists := m["Settings"]; keyExists {
		settings := s.(map[string]interface{})
		errs = validateSettingsSection(settings, fileName, rejectOldTaskDefinitions)
	} else {
		errs = validateSettingsSection(m, fileName, rejectOldTaskDefinitions)
	}
	return errs
}
Exemplo n.º 2
0
// check if a string is a valid OS name
func IsOs(part string) bool {
	return typeutils.StringSlicePos(OSES, part) > -1
}
Exemplo n.º 3
0
// check if a string is a valid architecture name
func IsArch(part string) bool {
	return typeutils.StringSlicePos(ARCHS, part) > -1
}