...
 
Commits (2)
......@@ -177,7 +177,10 @@ func loadConfig() (*Config, error) {
return nil, err
}
if config.SchedFile != "" {
schedules.addFromFile(config.SchedFile)
err := schedules.addFromFile(config.SchedFile)
if err != nil {
return nil, err
}
}
if _, ok := schedules[config.Schedule]; ok == false {
return nil, fmt.Errorf("no such schedule: %s\n", config.Schedule)
......@@ -223,7 +226,10 @@ func loadConfig() (*Config, error) {
return nil, err
}
if config.SchedFile != "" {
schedules.addFromFile(config.SchedFile)
err := schedules.addFromFile(config.SchedFile)
if err != nil {
return nil, err
}
}
err := config.ReadCache()
if err != nil {
......
......@@ -64,30 +64,24 @@ var schedules = scheduleList{
}
// addFromFile adds an external JSON file to the list of available scheds
func (schl scheduleList) addFromFile(file string) {
func (schl scheduleList) addFromFile(file string) error {
// If we are using the default file name, and it doesn't exist, no problem, just return
if _, err := os.Stat(file); os.IsNotExist(err) && file == defaultSchedFileName {
return
return nil
}
schedFile, err := ioutil.ReadFile(file)
if err != nil {
fmt.Printf("Error opening schedule file: %v\n", err)
return
return fmt.Errorf("Error opening schedule file: %v", err)
}
var readData map[string]jsonInterval
err = json.Unmarshal(schedFile, &readData)
if err != nil {
fmt.Printf("Error parsing data: %v\n", err)
return
return fmt.Errorf("Error parsing schedule file: %v", err)
}
for k, v := range readData {
schl[k] = v.intervalList()
}
return nil
}
// list prints the stored schedules in the list
......
......@@ -19,4 +19,4 @@ then
print "fix version.go first"
exit 1
fi
echo git tag -s v$v
echo git tag -s v$v -m \"tag snaprd v$v\"