func (c *Config) Validate() error {
	if c.Addr == "" {
		return errors.New("missing Addr")
	}
	if c.shouldUseTLS() && c.CertFile == "" {
		return errors.New("missing CertFile")
	}
	if c.shouldUseTLS() && c.KeyFile == "" {
		return errors.New("missing KeyFile")
	}
	if c.FrontAddr == "" {
		return errors.New("missing FrontAddr")
	}
	if c.Logger == nil {
		return errors.New("missing Logger")
	}
	return nil
}
Validate checks if the supplied config is valid.
package registry
import (
	"errors"
	log "github.com/Sirupsen/logrus"
)
type Config struct {
	StorageDir   string
	UpstreamURL  string
	ShaCacheSize int
	Addr         string
	CertFile     string
	KeyFile      string
	FrontAddr    string
	Logger       *log.Logger `json:"-"`
}
func DefaultConfig() *Config {
	return &Config{
		StorageDir:   "./packages",
		UpstreamURL:  "http://registry.npmjs.com",
		ShaCacheSize: 500,
		Addr:         ":8200",
		CertFile:     "",
		KeyFile:      "",
		FrontAddr:    "http://127.0.0.1:8200",
		Logger:       log.StandardLogger(),
	}
}
func (c *Config) shouldUseTLS() bool {
	return c.CertFile != "" || c.KeyFile != ""
}