Example #1
0
func (c *Config) validate() (err error) {
	if c.MaxRetainedLogMessages == 0 {
		return errors.New("Need max number of log messages to retain per application")
	}

	if c.BlackListIps != nil {
		err = iprange.ValidateIpAddresses(c.BlackListIps)
		if err != nil {
			return err
		}
	}

	if c.EnableTLSTransport {
		if c.TLSListenerConfig.CertFile == "" || c.TLSListenerConfig.KeyFile == "" || c.TLSListenerConfig.Port == 0 {
			return errors.New("invalid TLS listener configuration")
		}
	}

	if c.EtcdRequireTLS {
		if c.EtcdTLSClientConfig.CertFile == "" || c.EtcdTLSClientConfig.KeyFile == "" || c.EtcdTLSClientConfig.CAFile == "" {
			return errors.New("invalid etcd TLS client configuration")
		}
	}

	if c.GRPCPort == 0 {
		return errors.New("invalid doppler config, no GRPCPort provided")
	}

	return nil
}
Example #2
0
func (c *Config) validate() (err error) {
	if c.MaxRetainedLogMessages == 0 {
		return errors.New("Need max number of log messages to retain per application")
	}

	if c.BlackListIps != nil {
		err = iprange.ValidateIpAddresses(c.BlackListIps)
		if err != nil {
			return err
		}
	}

	if c.EnableTLSTransport {
		if c.TLSListenerConfig.CrtFile == "" || c.TLSListenerConfig.KeyFile == "" || c.TLSListenerConfig.Port == 0 {
			return errors.New("invalid TLS listener configuration")
		}
	}

	return err
}
Example #3
0
func (c *Config) Validate(logger *gosteno.Logger) (err error) {
	if c.MaxRetainedLogMessages == 0 {
		return errors.New("Need max number of log messages to retain per application")
	}

	if c.BlackListIps != nil {
		err = iprange.ValidateIpAddresses(c.BlackListIps)
		if err != nil {
			return err
		}
	}

	if c.UnmarshallerCount == 0 {
		c.UnmarshallerCount = 1
	}

	if c.EtcdMaxConcurrentRequests < 1 {
		c.EtcdMaxConcurrentRequests = 1
	}

	return err
}
Example #4
0
package iprange_test

import (
	"doppler/iprange"
	"fmt"
	"net/url"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("IPRange", func() {
	Describe("ValidateIpAddresses", func() {
		It("recognizes a valid IP address range", func() {
			ranges := []iprange.IPRange{iprange.IPRange{Start: "127.0.2.2", End: "127.0.2.4"}}
			err := iprange.ValidateIpAddresses(ranges)
			Expect(err).NotTo(HaveOccurred())
		})

		It("validates the start address", func() {
			ranges := []iprange.IPRange{iprange.IPRange{Start: "127.0.2.2.1", End: "127.0.2.4"}}
			err := iprange.ValidateIpAddresses(ranges)
			Expect(err).To(MatchError("Invalid IP Address for Blacklist IP Range: 127.0.2.2.1"))
		})

		It("validates the end address", func() {
			ranges := []iprange.IPRange{iprange.IPRange{Start: "127.0.2.2", End: "127.0.2.4.3"}}
			err := iprange.ValidateIpAddresses(ranges)
			Expect(err).To(HaveOccurred())
		})