func (c *Config) Validate() error {
	if c == nil {
		return errors.New("nil config object")
	}
	if err := c.Docker.Validate(); err != nil {
		return err
	}
	if len(c.Backends) == 0 {
		return errors.New("no backends configured")
	}
	for _, backend := range c.Backends {
		if err := backend.Validate(); err != nil {
			return err
		}
	}
	return nil
}
Validate the Beacon configuration.
package main
import (
	"flag"
	"github.com/pkg/errors"
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"os"
)
const (
	DefaultConfigFile = "/etc/beacon.yml"
	DefaultDockerSocket = "unix:///var/run/docker.sock"
	DefaultDockerHostIP = "127.0.0.1"
	DefaultDockerStopOnExit = false
)
const (
	envDockerSocket = "DOCKER_HOST"
	envDockerHostIP = "DOCKER_IP"
)
type Docker struct {
	Socket     string
	HostIP     string `yaml:"host-ip"`
	Label      string
	StopOnExit bool `yaml:"stop-on-exit"`
}
func (c *Docker) Validate() error {
	if c == nil {
		return errors.New("missing Docker config object")
	}
	if c.Socket == "" {
		return errors.New("Docker.Socket may not be empty")
	}
	if c.HostIP == "" {
		return errors.New("Docker.HostIP may not be empty")
	}
	if c.Label == "" {
		return errors.New("Docker.Label may not be empty")
	}
	return nil
}
type Debug struct{}
func (c *Debug) Validate() error {
	return nil
}
type SNS struct {
	Region string
	Topic  string
}
func (c *SNS) Validate() error {
	if c == nil {
		return errors.New("missing SNS config object")
	}
	if c.Region == "" {
		return errors.New("SNS.Region may not be empty")
	}
	if c.Topic == "" {
		return errors.New("SNS.Topic may not be empty")
	}
	return nil
}
type Backend struct {
	Debug  *Debug
	SNS    *SNS
	Filter map[string]string
}
func (c *Backend) Validate() error {
	if c.SNS != nil {
		return c.SNS.Validate()
	} else if c.Debug != nil {
		return c.Debug.Validate()
	}
	return errors.New("backend not supported")
}
type Config struct {
	Backends []Backend
	Docker   Docker
}