func (c *config) Validate() error {
	if c.ApiKeys.Slack == "" || c.ApiKeys.Pagerduty.Key == "" {
		return fmt.Errorf("You must provide API keys for Slack and Pagerduty")
	}

	if c.ApiKeys.Pagerduty.Org == "" {
		return fmt.Errorf("You must provide an org name for Pagerduty (<org>.pagerduty.com)")
	}

	if len(c.Groups) == 0 {
		return fmt.Errorf("You must specify at least one group")
	}

	for i, group := range c.Groups {
		if group.Name == "" {
			return fmt.Errorf("Must specify group name for group %d", i)
		}

		if len(group.Schedules) == 0 {
			return fmt.Errorf("Must specify at least one schedule for group %s", group.Name)
		}
	}

	log.WithFields(log.Fields{"groups": len(c.Groups)}).Debug("Loaded config")

	return nil
}
// Validate the configuration file for sanity
Validate the configuration file for sanity
// Validate the configuration file for sanity
func (c *config) Validate() error {
	if c.ApiKeys.Slack == "" || c.ApiKeys.Pagerduty.Key == "" {
		return fmt.Errorf("You must provide API keys for Slack and Pagerduty")
	}
	if c.ApiKeys.Pagerduty.Org == "" {
		return fmt.Errorf("You must provide an org name for Pagerduty (<org>.pagerduty.com)")
	}
	if len(c.Groups) == 0 {
		return fmt.Errorf("You must specify at least one group")
	}
	for i, group := range c.Groups {
		if group.Name == "" {
			return fmt.Errorf("Must specify group name for group %d", i)
		}
		if len(group.Schedules) == 0 {
			return fmt.Errorf("Must specify at least one schedule for group %s", group.Name)
		}
	}
	log.WithFields(log.Fields{"groups": len(c.Groups)}).Debug("Loaded config")
	return nil
}
func ( c * config ) Validate ( ) error { if c . ApiKeys . Slack == " " || c . ApiKeys . Pagerduty . Key == " " { return fmt . Errorf ( " " ) } if c . ApiKeys . Pagerduty . Org == " " { return fmt . Errorf ( " " ) } if len ( c . Groups ) == 0 { return fmt . Errorf ( " " ) } for i , group := range c . Groups { if group . Name == " " { return fmt . Errorf ( " " , i ) } if len ( group . Schedules ) == 0 { return fmt . Errorf ( " " , group . Name ) } } log . WithFields ( log . Fields { " " : len ( c . Groups ) } ) . Debug ( " " ) return nil }
Validate the configuration file for sanity
Validate the configuration file for sanity