Exemple #1
0
// LoadSchemaJSON loads the formal representation of a schema
// from a JSON file and returns the more usable denormalized
// representaion (Schema) for it.
func LoadSchemaJSON(filename string) (schema *Schema, err error) {
	var source SchemaFormal
	if err := jscfg.ReadJson(filename, &source); err != nil {
		return nil, err
	}
	return BuildSchema(&source)
}
Exemple #2
0
func loadSchemaOverrides(overridesFile string) []tabletserver.SchemaOverride {
	var schemaOverrides []tabletserver.SchemaOverride
	if overridesFile == "" {
		return schemaOverrides
	}
	if err := jscfg.ReadJson(overridesFile, &schemaOverrides); err != nil {
		log.Warningf("can't read overridesFile %v: %v", overridesFile, err)
	} else {
		data, _ := json.MarshalIndent(schemaOverrides, "", "  ")
		log.Infof("schemaOverrides: %s\n", data)
	}
	return schemaOverrides
}
Exemple #3
0
func (fcs *FileCredentialsServer) GetUserAndPassword(user string) (string, string, error) {
	fcs.mu.Lock()
	defer fcs.mu.Unlock()

	if *dbCredentialsFile == "" {
		return "", "", ErrUnknownUser
	}

	// read the json file only once
	if fcs.dbCredentials == nil {
		fcs.dbCredentials = make(map[string][]string)
		if err := jscfg.ReadJson(*dbCredentialsFile, &fcs.dbCredentials); err != nil {
			log.Warningf("Failed to read dbCredentials file: %v", *dbCredentialsFile)
			return "", "", err
		}
	}

	if passwd, ok := fcs.dbCredentials[user]; !ok {
		return "", "", ErrUnknownUser
	} else {
		return user, passwd[0], nil
	}
}