예제 #1
0
func typeForSchemaProperty(pname string, p interface{}) string {
	ptype := "unknown"
	if property, ok := p.(map[string]interface{}); ok {
		ptype = property["type"].(string)
		if ptype == "object" {
			details := property["properties"].(map[string]interface{})
			if sysDatatype, ok := details["sysDatatype"].(map[string]interface{}); ok {
				ptype = sysDatatype["pattern"].(string)
			} else if _, ok := details["sysRelationChanges"].(map[string]interface{}); ok {
				ptype = "relation"
			}
		}
	}
	if ptype == "unknown" {
		log.Warnf("Unrecognized schema for property '%s': %v. Type is %T", pname, p, p)
	}
	return ptype
}
예제 #2
0
func FilePath() string {
	dir, err := filepath.Abs(".")
	if err != nil {
		return ""
	}
	tried := make([]string, 0)
	for {
		path := filepath.Join(dir, fileName)
		tried = append(tried, path)
		_, err := os.Stat(path)
		if err == nil {
			return path
		}
		if len(dir) <= 3 {
			log.Warnf("Cound not find appstax.conf. Searched paths: %s", strings.Join(tried, ", "))
			return ""
		}
		dir = filepath.Dir(dir)
	}
}