Split consul and consul catalog.
This commit is contained in:
parent
06d528a2bd
commit
61ecb4cd18
7 changed files with 89 additions and 86 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/containous/traefik/provider"
|
||||
"github.com/containous/traefik/provider/boltdb"
|
||||
"github.com/containous/traefik/provider/consul"
|
||||
"github.com/containous/traefik/provider/consulcatalog"
|
||||
"github.com/containous/traefik/provider/docker"
|
||||
"github.com/containous/traefik/provider/dynamodb"
|
||||
"github.com/containous/traefik/provider/ecs"
|
||||
|
@ -333,7 +334,7 @@ func TestDo_globalConfiguration(t *testing.T) {
|
|||
},
|
||||
RespectReadinessChecks: true,
|
||||
}
|
||||
config.ConsulCatalog = &consul.CatalogProvider{
|
||||
config.ConsulCatalog = &consulcatalog.Provider{
|
||||
BaseProvider: provider.BaseProvider{
|
||||
Watch: true,
|
||||
Filename: "ConsulCatalog Filename",
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/containous/traefik/ping"
|
||||
"github.com/containous/traefik/provider/boltdb"
|
||||
"github.com/containous/traefik/provider/consul"
|
||||
"github.com/containous/traefik/provider/consulcatalog"
|
||||
"github.com/containous/traefik/provider/docker"
|
||||
"github.com/containous/traefik/provider/dynamodb"
|
||||
"github.com/containous/traefik/provider/ecs"
|
||||
|
@ -94,7 +95,7 @@ func NewTraefikDefaultPointersConfiguration() *TraefikConfiguration {
|
|||
defaultConsul.Constraints = types.Constraints{}
|
||||
|
||||
// default CatalogProvider
|
||||
var defaultConsulCatalog consul.CatalogProvider
|
||||
var defaultConsulCatalog consulcatalog.Provider
|
||||
defaultConsulCatalog.Endpoint = "127.0.0.1:8500"
|
||||
defaultConsulCatalog.ExposedByDefault = true
|
||||
defaultConsulCatalog.Constraints = types.Constraints{}
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/containous/traefik/ping"
|
||||
"github.com/containous/traefik/provider/boltdb"
|
||||
"github.com/containous/traefik/provider/consul"
|
||||
"github.com/containous/traefik/provider/consulcatalog"
|
||||
"github.com/containous/traefik/provider/docker"
|
||||
"github.com/containous/traefik/provider/dynamodb"
|
||||
"github.com/containous/traefik/provider/ecs"
|
||||
|
@ -79,7 +80,7 @@ type GlobalConfiguration struct {
|
|||
File *file.Provider `description:"Enable File backend with default settings" export:"true"`
|
||||
Marathon *marathon.Provider `description:"Enable Marathon backend with default settings" export:"true"`
|
||||
Consul *consul.Provider `description:"Enable Consul backend with default settings" export:"true"`
|
||||
ConsulCatalog *consul.CatalogProvider `description:"Enable Consul catalog backend with default settings" export:"true"`
|
||||
ConsulCatalog *consulcatalog.Provider `description:"Enable Consul catalog backend with default settings" export:"true"`
|
||||
Etcd *etcd.Provider `description:"Enable Etcd backend with default settings" export:"true"`
|
||||
Zookeeper *zk.Provider `description:"Enable Zookeeper backend with default settings" export:"true"`
|
||||
Boltdb *boltdb.Provider `description:"Enable Boltdb backend with default settings" export:"true"`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package consul
|
||||
package consulcatalog
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
@ -22,10 +22,10 @@ const (
|
|||
DefaultWatchWaitTime = 15 * time.Second
|
||||
)
|
||||
|
||||
var _ provider.Provider = (*CatalogProvider)(nil)
|
||||
var _ provider.Provider = (*Provider)(nil)
|
||||
|
||||
// CatalogProvider holds configurations of the Consul catalog provider.
|
||||
type CatalogProvider struct {
|
||||
// Provider holds configurations of the Consul catalog provider.
|
||||
type Provider struct {
|
||||
provider.BaseProvider `mapstructure:",squash" export:"true"`
|
||||
Endpoint string `description:"Consul server endpoint"`
|
||||
Domain string `description:"Default domain used"`
|
||||
|
@ -85,7 +85,7 @@ func (a nodeSorter) Less(i int, j int) bool {
|
|||
|
||||
// Provide allows the consul catalog provider to provide configurations to traefik
|
||||
// using the given configuration channel.
|
||||
func (p *CatalogProvider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error {
|
||||
func (p *Provider) Provide(configurationChan chan<- types.ConfigMessage, pool *safe.Pool, constraints types.Constraints) error {
|
||||
config := api.DefaultConfig()
|
||||
config.Address = p.Endpoint
|
||||
client, err := api.NewClient(config)
|
||||
|
@ -112,7 +112,7 @@ func (p *CatalogProvider) Provide(configurationChan chan<- types.ConfigMessage,
|
|||
return err
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) watch(configurationChan chan<- types.ConfigMessage, stop chan bool) error {
|
||||
func (p *Provider) watch(configurationChan chan<- types.ConfigMessage, stop chan bool) error {
|
||||
stopCh := make(chan struct{})
|
||||
watchCh := make(chan map[string][]string)
|
||||
errorCh := make(chan error)
|
||||
|
@ -147,7 +147,7 @@ func (p *CatalogProvider) watch(configurationChan chan<- types.ConfigMessage, st
|
|||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) watchCatalogServices(stopCh <-chan struct{}, watchCh chan<- map[string][]string, errorCh chan<- error) {
|
||||
func (p *Provider) watchCatalogServices(stopCh <-chan struct{}, watchCh chan<- map[string][]string, errorCh chan<- error) {
|
||||
catalog := p.client.Catalog()
|
||||
|
||||
safe.Go(func() {
|
||||
|
@ -216,7 +216,7 @@ func (p *CatalogProvider) watchCatalogServices(stopCh <-chan struct{}, watchCh c
|
|||
})
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) watchHealthState(stopCh <-chan struct{}, watchCh chan<- map[string][]string, errorCh chan<- error) {
|
||||
func (p *Provider) watchHealthState(stopCh <-chan struct{}, watchCh chan<- map[string][]string, errorCh chan<- error) {
|
||||
health := p.client.Health()
|
||||
catalog := p.client.Catalog()
|
||||
|
||||
|
@ -287,7 +287,7 @@ func (p *CatalogProvider) watchHealthState(stopCh <-chan struct{}, watchCh chan<
|
|||
})
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getNodes(index map[string][]string) ([]catalogUpdate, error) {
|
||||
func (p *Provider) getNodes(index map[string][]string) ([]catalogUpdate, error) {
|
||||
visited := make(map[string]bool)
|
||||
|
||||
var nodes []catalogUpdate
|
||||
|
@ -383,7 +383,7 @@ func getServicePorts(services []*api.CatalogService) []int {
|
|||
return servicePorts
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) healthyNodes(service string) (catalogUpdate, error) {
|
||||
func (p *Provider) healthyNodes(service string) (catalogUpdate, error) {
|
||||
health := p.client.Health()
|
||||
data, _, err := health.Service(service, "", true, &api.QueryOptions{})
|
||||
if err != nil {
|
||||
|
@ -412,7 +412,7 @@ func (p *CatalogProvider) healthyNodes(service string) (catalogUpdate, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) nodeFilter(service string, node *api.ServiceEntry) bool {
|
||||
func (p *Provider) nodeFilter(service string, node *api.ServiceEntry) bool {
|
||||
// Filter disabled application.
|
||||
if !p.isServiceEnabled(node) {
|
||||
log.Debugf("Filtering disabled Consul service %s", service)
|
||||
|
@ -429,11 +429,11 @@ func (p *CatalogProvider) nodeFilter(service string, node *api.ServiceEntry) boo
|
|||
return true
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) isServiceEnabled(node *api.ServiceEntry) bool {
|
||||
func (p *Provider) isServiceEnabled(node *api.ServiceEntry) bool {
|
||||
return p.getBoolAttribute(label.SuffixEnable, node.Service.Tags, p.ExposedByDefault)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getConstraintTags(tags []string) []string {
|
||||
func (p *Provider) getConstraintTags(tags []string) []string {
|
||||
var values []string
|
||||
|
||||
prefix := p.getPrefixedName("tags=")
|
|
@ -1,4 +1,4 @@
|
|||
package consul
|
||||
package consulcatalog
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
"github.com/hashicorp/consul/api"
|
||||
)
|
||||
|
||||
func (p *CatalogProvider) buildConfiguration(catalog []catalogUpdate) *types.Configuration {
|
||||
func (p *Provider) buildConfiguration(catalog []catalogUpdate) *types.Configuration {
|
||||
var FuncMap = template.FuncMap{
|
||||
"getAttribute": p.getAttribute,
|
||||
"getTag": getTag,
|
||||
|
@ -85,7 +85,7 @@ func (p *CatalogProvider) buildConfiguration(catalog []catalogUpdate) *types.Con
|
|||
return configuration
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) setupFrontEndRuleTemplate() {
|
||||
func (p *Provider) setupFrontEndRuleTemplate() {
|
||||
var FuncMap = template.FuncMap{
|
||||
"getAttribute": p.getAttribute,
|
||||
"getTag": getTag,
|
||||
|
@ -97,7 +97,7 @@ func (p *CatalogProvider) setupFrontEndRuleTemplate() {
|
|||
|
||||
// Specific functions
|
||||
|
||||
func (p *CatalogProvider) getFrontendRule(service serviceUpdate) string {
|
||||
func (p *Provider) getFrontendRule(service serviceUpdate) string {
|
||||
customFrontendRule := p.getAttribute(label.SuffixFrontendRule, service.Attributes, "")
|
||||
if customFrontendRule == "" {
|
||||
customFrontendRule = p.FrontEndRule
|
||||
|
@ -131,7 +131,7 @@ func (p *CatalogProvider) getFrontendRule(service serviceUpdate) string {
|
|||
}
|
||||
|
||||
// Deprecated
|
||||
func (p *CatalogProvider) hasMaxConnAttributes(attributes []string) bool {
|
||||
func (p *Provider) hasMaxConnAttributes(attributes []string) bool {
|
||||
amount := p.getAttribute(label.SuffixBackendMaxConnAmount, attributes, "")
|
||||
extractorFunc := p.getAttribute(label.SuffixBackendMaxConnExtractorFunc, attributes, "")
|
||||
return amount != "" && extractorFunc != ""
|
||||
|
@ -178,7 +178,7 @@ func getServerName(node *api.ServiceEntry, index int) string {
|
|||
// TODO: Deprecated
|
||||
// replaced by Stickiness
|
||||
// Deprecated
|
||||
func (p *CatalogProvider) getSticky(tags []string) string {
|
||||
func (p *Provider) getSticky(tags []string) string {
|
||||
stickyTag := p.getAttribute(label.SuffixBackendLoadBalancerSticky, tags, "")
|
||||
if len(stickyTag) > 0 {
|
||||
log.Warnf("Deprecated configuration found: %s. Please use %s.", label.TraefikBackendLoadBalancerSticky, label.TraefikBackendLoadBalancerStickiness)
|
||||
|
@ -189,18 +189,18 @@ func (p *CatalogProvider) getSticky(tags []string) string {
|
|||
}
|
||||
|
||||
// Deprecated
|
||||
func (p *CatalogProvider) hasStickinessLabel(tags []string) bool {
|
||||
func (p *Provider) hasStickinessLabel(tags []string) bool {
|
||||
stickinessTag := p.getAttribute(label.SuffixBackendLoadBalancerStickiness, tags, "")
|
||||
return len(stickinessTag) > 0 && strings.EqualFold(strings.TrimSpace(stickinessTag), "true")
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
func (p *CatalogProvider) getStickinessCookieName(tags []string) string {
|
||||
func (p *Provider) getStickinessCookieName(tags []string) string {
|
||||
return p.getAttribute(label.SuffixBackendLoadBalancerStickinessCookieName, tags, "")
|
||||
}
|
||||
|
||||
// Deprecated
|
||||
func (p *CatalogProvider) getWeight(tags []string) int {
|
||||
func (p *Provider) getWeight(tags []string) int {
|
||||
weight := p.getIntAttribute(label.SuffixWeight, tags, 0)
|
||||
|
||||
// Deprecated
|
||||
|
@ -215,7 +215,7 @@ func (p *CatalogProvider) getWeight(tags []string) int {
|
|||
return weight
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getCircuitBreaker(tags []string) *types.CircuitBreaker {
|
||||
func (p *Provider) getCircuitBreaker(tags []string) *types.CircuitBreaker {
|
||||
circuitBreaker := p.getAttribute(label.SuffixBackendCircuitBreakerExpression, tags, "")
|
||||
|
||||
if p.hasAttribute(label.SuffixBackendCircuitBreaker, tags) {
|
||||
|
@ -232,7 +232,7 @@ func (p *CatalogProvider) getCircuitBreaker(tags []string) *types.CircuitBreaker
|
|||
return &types.CircuitBreaker{Expression: circuitBreaker}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getLoadBalancer(tags []string) *types.LoadBalancer {
|
||||
func (p *Provider) getLoadBalancer(tags []string) *types.LoadBalancer {
|
||||
rawSticky := p.getSticky(tags)
|
||||
sticky, err := strconv.ParseBool(rawSticky)
|
||||
if err != nil {
|
||||
|
@ -265,7 +265,7 @@ func (p *CatalogProvider) getLoadBalancer(tags []string) *types.LoadBalancer {
|
|||
return lb
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getMaxConn(tags []string) *types.MaxConn {
|
||||
func (p *Provider) getMaxConn(tags []string) *types.MaxConn {
|
||||
amount := p.getInt64Attribute(label.SuffixBackendMaxConnAmount, tags, math.MinInt64)
|
||||
extractorFunc := p.getAttribute(label.SuffixBackendMaxConnExtractorFunc, tags, label.DefaultBackendMaxconnExtractorFunc)
|
||||
|
||||
|
@ -279,7 +279,7 @@ func (p *CatalogProvider) getMaxConn(tags []string) *types.MaxConn {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getHealthCheck(tags []string) *types.HealthCheck {
|
||||
func (p *Provider) getHealthCheck(tags []string) *types.HealthCheck {
|
||||
path := p.getAttribute(label.SuffixBackendHealthCheckPath, tags, "")
|
||||
|
||||
if len(path) == 0 {
|
||||
|
@ -296,7 +296,7 @@ func (p *CatalogProvider) getHealthCheck(tags []string) *types.HealthCheck {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getRedirect(tags []string) *types.Redirect {
|
||||
func (p *Provider) getRedirect(tags []string) *types.Redirect {
|
||||
if p.hasAttribute(label.SuffixFrontendRedirectEntryPoint, tags) {
|
||||
return &types.Redirect{
|
||||
EntryPoint: p.getAttribute(label.SuffixFrontendRedirectEntryPoint, tags, ""),
|
||||
|
@ -313,14 +313,14 @@ func (p *CatalogProvider) getRedirect(tags []string) *types.Redirect {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getErrorPages(tags []string) map[string]*types.ErrorPage {
|
||||
func (p *Provider) getErrorPages(tags []string) map[string]*types.ErrorPage {
|
||||
labels := p.parseTagsToNeutralLabels(tags)
|
||||
|
||||
prefix := label.Prefix + label.BaseFrontendErrorPage
|
||||
return label.ParseErrorPages(labels, prefix, label.RegexpFrontendErrorPage)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getRateLimit(tags []string) *types.RateLimit {
|
||||
func (p *Provider) getRateLimit(tags []string) *types.RateLimit {
|
||||
extractorFunc := p.getAttribute(label.SuffixFrontendRateLimitExtractorFunc, tags, "")
|
||||
if len(extractorFunc) == 0 {
|
||||
return nil
|
||||
|
@ -337,7 +337,7 @@ func (p *CatalogProvider) getRateLimit(tags []string) *types.RateLimit {
|
|||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getHeaders(tags []string) *types.Headers {
|
||||
func (p *Provider) getHeaders(tags []string) *types.Headers {
|
||||
headers := &types.Headers{
|
||||
CustomRequestHeaders: p.getMapAttribute(label.SuffixFrontendRequestHeaders, tags),
|
||||
CustomResponseHeaders: p.getMapAttribute(label.SuffixFrontendResponseHeaders, tags),
|
||||
|
@ -370,7 +370,7 @@ func (p *CatalogProvider) getHeaders(tags []string) *types.Headers {
|
|||
|
||||
// Base functions
|
||||
|
||||
func (p *CatalogProvider) parseTagsToNeutralLabels(tags []string) map[string]string {
|
||||
func (p *Provider) parseTagsToNeutralLabels(tags []string) map[string]string {
|
||||
var labels map[string]string
|
||||
|
||||
for _, tag := range tags {
|
||||
|
@ -392,19 +392,19 @@ func (p *CatalogProvider) parseTagsToNeutralLabels(tags []string) map[string]str
|
|||
return labels
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getFuncStringAttribute(name string, defaultValue string) func(tags []string) string {
|
||||
func (p *Provider) getFuncStringAttribute(name string, defaultValue string) func(tags []string) string {
|
||||
return func(tags []string) string {
|
||||
return p.getAttribute(name, tags, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getFuncSliceAttribute(name string) func(tags []string) []string {
|
||||
func (p *Provider) getFuncSliceAttribute(name string) func(tags []string) []string {
|
||||
return func(tags []string) []string {
|
||||
return p.getSliceAttribute(name, tags)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getMapAttribute(name string, tags []string) map[string]string {
|
||||
func (p *Provider) getMapAttribute(name string, tags []string) map[string]string {
|
||||
rawValue := getTag(p.getPrefixedName(name), tags, "")
|
||||
|
||||
if len(rawValue) == 0 {
|
||||
|
@ -414,25 +414,25 @@ func (p *CatalogProvider) getMapAttribute(name string, tags []string) map[string
|
|||
return label.ParseMapValue(p.getPrefixedName(name), rawValue)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getFuncIntAttribute(name string, defaultValue int) func(tags []string) int {
|
||||
func (p *Provider) getFuncIntAttribute(name string, defaultValue int) func(tags []string) int {
|
||||
return func(tags []string) int {
|
||||
return p.getIntAttribute(name, tags, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getFuncBoolAttribute(name string, defaultValue bool) func(tags []string) bool {
|
||||
func (p *Provider) getFuncBoolAttribute(name string, defaultValue bool) func(tags []string) bool {
|
||||
return func(tags []string) bool {
|
||||
return p.getBoolAttribute(name, tags, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getFuncHasAttributePrefix(name string) func(tags []string) bool {
|
||||
func (p *Provider) getFuncHasAttributePrefix(name string) func(tags []string) bool {
|
||||
return func(tags []string) bool {
|
||||
return p.hasAttributePrefix(name, tags)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getInt64Attribute(name string, tags []string, defaultValue int64) int64 {
|
||||
func (p *Provider) getInt64Attribute(name string, tags []string, defaultValue int64) int64 {
|
||||
rawValue := getTag(p.getPrefixedName(name), tags, "")
|
||||
|
||||
if len(rawValue) == 0 {
|
||||
|
@ -447,7 +447,7 @@ func (p *CatalogProvider) getInt64Attribute(name string, tags []string, defaultV
|
|||
return value
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getIntAttribute(name string, tags []string, defaultValue int) int {
|
||||
func (p *Provider) getIntAttribute(name string, tags []string, defaultValue int) int {
|
||||
rawValue := getTag(p.getPrefixedName(name), tags, "")
|
||||
|
||||
if len(rawValue) == 0 {
|
||||
|
@ -462,7 +462,7 @@ func (p *CatalogProvider) getIntAttribute(name string, tags []string, defaultVal
|
|||
return value
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getSliceAttribute(name string, tags []string) []string {
|
||||
func (p *Provider) getSliceAttribute(name string, tags []string) []string {
|
||||
rawValue := getTag(p.getPrefixedName(name), tags, "")
|
||||
|
||||
if len(rawValue) == 0 {
|
||||
|
@ -471,7 +471,7 @@ func (p *CatalogProvider) getSliceAttribute(name string, tags []string) []string
|
|||
return label.SplitAndTrimString(rawValue, ",")
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getBoolAttribute(name string, tags []string, defaultValue bool) bool {
|
||||
func (p *Provider) getBoolAttribute(name string, tags []string, defaultValue bool) bool {
|
||||
rawValue := getTag(p.getPrefixedName(name), tags, "")
|
||||
|
||||
if len(rawValue) == 0 {
|
||||
|
@ -486,19 +486,19 @@ func (p *CatalogProvider) getBoolAttribute(name string, tags []string, defaultVa
|
|||
return value
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) hasAttribute(name string, tags []string) bool {
|
||||
func (p *Provider) hasAttribute(name string, tags []string) bool {
|
||||
return hasTag(p.getPrefixedName(name), tags)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) hasAttributePrefix(name string, tags []string) bool {
|
||||
func (p *Provider) hasAttributePrefix(name string, tags []string) bool {
|
||||
return hasTagPrefix(p.getPrefixedName(name), tags)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getAttribute(name string, tags []string, defaultValue string) string {
|
||||
func (p *Provider) getAttribute(name string, tags []string, defaultValue string) string {
|
||||
return getTag(p.getPrefixedName(name), tags, defaultValue)
|
||||
}
|
||||
|
||||
func (p *CatalogProvider) getPrefixedName(name string) string {
|
||||
func (p *Provider) getPrefixedName(name string) string {
|
||||
if len(p.Prefix) > 0 && len(name) > 0 {
|
||||
return p.Prefix + "." + name
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package consul
|
||||
package consulcatalog
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestCatalogProviderBuildConfiguration(t *testing.T) {
|
||||
provider := &CatalogProvider{
|
||||
func TestProviderBuildConfiguration(t *testing.T) {
|
||||
provider := &Provider{
|
||||
Domain: "localhost",
|
||||
Prefix: "traefik",
|
||||
ExposedByDefault: false,
|
||||
|
@ -211,7 +211,7 @@ func TestHasTag(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetPrefixedName(t *testing.T) {
|
||||
func TestProviderGetPrefixedName(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
name string
|
||||
|
@ -249,7 +249,7 @@ func TestCatalogProviderGetPrefixedName(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
pro := &CatalogProvider{Prefix: test.prefix}
|
||||
pro := &Provider{Prefix: test.prefix}
|
||||
|
||||
actual := pro.getPrefixedName(test.name)
|
||||
assert.Equal(t, test.expected, actual)
|
||||
|
@ -258,7 +258,7 @@ func TestCatalogProviderGetPrefixedName(t *testing.T) {
|
|||
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetAttribute(t *testing.T) {
|
||||
func TestProviderGetAttribute(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
tags []string
|
||||
|
@ -326,7 +326,7 @@ func TestCatalogProviderGetAttribute(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
p := &CatalogProvider{
|
||||
p := &Provider{
|
||||
Domain: "localhost",
|
||||
Prefix: test.prefix,
|
||||
}
|
||||
|
@ -337,8 +337,8 @@ func TestCatalogProviderGetAttribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetIntAttribute(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetIntAttribute(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -388,8 +388,8 @@ func TestCatalogProviderGetIntAttribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetInt64Attribute(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetInt64Attribute(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -439,8 +439,8 @@ func TestCatalogProviderGetInt64Attribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetBoolAttribute(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetBoolAttribute(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -490,8 +490,8 @@ func TestCatalogProviderGetBoolAttribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetSliceAttribute(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetSliceAttribute(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -545,7 +545,7 @@ func TestCatalogProviderGetSliceAttribute(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetFrontendRule(t *testing.T) {
|
||||
func TestProviderGetFrontendRule(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
service serviceUpdate
|
||||
|
@ -597,7 +597,7 @@ func TestCatalogProviderGetFrontendRule(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
p := &CatalogProvider{
|
||||
p := &Provider{
|
||||
Domain: "localhost",
|
||||
Prefix: "traefik",
|
||||
FrontEndRule: "Host:{{.ServiceName}}.{{.Domain}}",
|
||||
|
@ -654,7 +654,7 @@ func TestGetBackendAddress(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetServerName(t *testing.T) {
|
||||
func TestProviderGetServerName(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
node *api.ServiceEntry
|
||||
|
@ -711,7 +711,7 @@ func TestCatalogProviderGetServerName(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestHasStickinessLabel(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -752,8 +752,8 @@ func TestHasStickinessLabel(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetCircuitBreaker(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetCircuitBreaker(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -788,8 +788,8 @@ func TestCatalogProviderGetCircuitBreaker(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetLoadBalancer(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetLoadBalancer(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -887,8 +887,8 @@ func TestCatalogProviderGetLoadBalancer(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetMaxConn(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetMaxConn(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -952,8 +952,8 @@ func TestCatalogProviderGetMaxConn(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetHealthCheck(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetHealthCheck(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -1002,8 +1002,8 @@ func TestCatalogProviderGetHealthCheck(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetRedirect(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetRedirect(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -1062,8 +1062,8 @@ func TestCatalogProviderGetRedirect(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetErrorPages(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetErrorPages(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -1114,8 +1114,8 @@ func TestCatalogProviderGetErrorPages(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetRateLimit(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetRateLimit(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
||||
|
@ -1170,8 +1170,8 @@ func TestCatalogProviderGetRateLimit(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalogProviderGetHeaders(t *testing.T) {
|
||||
p := &CatalogProvider{
|
||||
func TestProviderGetHeaders(t *testing.T) {
|
||||
p := &Provider{
|
||||
Prefix: "traefik",
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package consul
|
||||
package consulcatalog
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
@ -446,7 +446,7 @@ func TestFilterEnabled(t *testing.T) {
|
|||
test := test
|
||||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
provider := &CatalogProvider{
|
||||
provider := &Provider{
|
||||
Domain: "localhost",
|
||||
Prefix: "traefik",
|
||||
ExposedByDefault: test.exposedByDefault,
|
||||
|
@ -787,7 +787,7 @@ func TestHasChanged(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestGetConstraintTags(t *testing.T) {
|
||||
provider := &CatalogProvider{
|
||||
provider := &Provider{
|
||||
Domain: "localhost",
|
||||
Prefix: "traefik",
|
||||
}
|
Loading…
Reference in a new issue