// FromFileAt creates configuration object from a file at path.
// Returns nil if it could not open the file.
FromFileAt creates configuration object from a file at path.
Returns nil if it could not open the file.
// FromFileAt creates configuration object from a file at path . // Returns nil if it could not open the file .
func FromFileAt(path *string) (*Configuration, error) {
	var config Configuration
	var labelsNames = make(map[string]bool)
	err := getData(path, &config)
	if err != nil {
		return nil, err
	}
	errorInLabels := false
	if err := validator.Validate(config); err != nil {
		fmt.Printf("Error in configuration : %v\n", err)
		errorInLabels = true
	}
	for index, label := range config.Labels {
		config.Labels[index].Information.Organisation = config.Organisation
		if err := validator.Validate(label); err != nil {
			fmt.Printf("Error in label %v : %v\n", index+1, err)
			errorInLabels = true
		}
		if labelsNames[label.Name] {
			fmt.Printf("Error in label %v : Label name already present.\n", index+1)
			errorInLabels = true
		}
		labelsNames[label.Name] = true
	}
	if errorInLabels {
		return nil, fmt.Errorf("Labels configuration is wrong.")
	}
	return &config, nil
}
func FromFileAt ( path * string ) ( * Configuration , error ) { var config Configuration var labelsNames = make ( map [ string ] bool ) err := getData ( path , & config ) if err != nil { return nil , err } errorInLabels := false if err := validator . Validate ( config ) ; err != nil { fmt . Printf ( " \n " , err ) errorInLabels = true } for index , label := range config . Labels { config . Labels [ index ] . Information . Organisation = config . Organisation if err := validator . Validate ( label ) ; err != nil { fmt . Printf ( " \n " , index + 1 , err ) errorInLabels = true } if labelsNames [ label . Name ] { fmt . Printf ( " \n " , index + 1 ) errorInLabels = true } labelsNames [ label . Name ] = true } if errorInLabels { return nil , fmt . Errorf ( " " ) } return & config , nil }
FromFileAt creates configuration object from a file at path.
FromFileAt creates configuration object from a file at path .
// Validate current JSON // Validate the JSON labels