config: deal with multiple errors and their criticality
Co-authored-by: Julien Salleyron <julien.salleyron@gmail.com>
This commit is contained in:
parent
62800116d3
commit
6fdd48509e
45 changed files with 725 additions and 412 deletions
|
@ -5,7 +5,7 @@ import (
|
|||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/runtime"
|
||||
"github.com/containous/traefik/pkg/log"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
"github.com/containous/traefik/pkg/tcp"
|
||||
|
@ -13,11 +13,11 @@ import (
|
|||
|
||||
// Manager is the TCPHandlers factory
|
||||
type Manager struct {
|
||||
configs map[string]*dynamic.TCPServiceInfo
|
||||
configs map[string]*runtime.TCPServiceInfo
|
||||
}
|
||||
|
||||
// NewManager creates a new manager
|
||||
func NewManager(conf *dynamic.RuntimeConfiguration) *Manager {
|
||||
func NewManager(conf *runtime.Configuration) *Manager {
|
||||
return &Manager{
|
||||
configs: conf.TCPServices,
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/containous/traefik/pkg/config/dynamic"
|
||||
"github.com/containous/traefik/pkg/config/runtime"
|
||||
"github.com/containous/traefik/pkg/server/internal"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -14,7 +15,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
testCases := []struct {
|
||||
desc string
|
||||
serviceName string
|
||||
configs map[string]*dynamic.TCPServiceInfo
|
||||
configs map[string]*runtime.TCPServiceInfo
|
||||
providerName string
|
||||
expectedError string
|
||||
}{
|
||||
|
@ -27,7 +28,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "missing lb configuration",
|
||||
serviceName: "test",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"test": {
|
||||
TCPService: &dynamic.TCPService{},
|
||||
},
|
||||
|
@ -37,7 +38,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "no such host, server is skipped, error is logged",
|
||||
serviceName: "test",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"test": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -52,7 +53,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "invalid IP address, server is skipped, error is logged",
|
||||
serviceName: "test",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"test": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -67,7 +68,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "Simple service name",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{},
|
||||
|
@ -78,7 +79,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "Service name with provider",
|
||||
serviceName: "serviceName@provider-1",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{},
|
||||
|
@ -89,7 +90,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "Service name with provider in context",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{},
|
||||
|
@ -101,7 +102,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "Server with correct host:port as address",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -119,7 +120,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "Server with correct ip:port as address",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -137,7 +138,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "missing port in address with hostname, server is skipped, error is logged",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -155,7 +156,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
{
|
||||
desc: "missing port in address with ip, server is skipped, error is logged",
|
||||
serviceName: "serviceName",
|
||||
configs: map[string]*dynamic.TCPServiceInfo{
|
||||
configs: map[string]*runtime.TCPServiceInfo{
|
||||
"serviceName@provider-1": {
|
||||
TCPService: &dynamic.TCPService{
|
||||
LoadBalancer: &dynamic.TCPLoadBalancerService{
|
||||
|
@ -177,7 +178,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
|||
t.Run(test.desc, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
manager := NewManager(&dynamic.RuntimeConfiguration{
|
||||
manager := NewManager(&runtime.Configuration{
|
||||
TCPServices: test.configs,
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue