New static configuration loading system.

Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
This commit is contained in:
Ludovic Fernandez 2019-06-17 11:48:05 +02:00 committed by Traefiker Bot
parent d18edd6f77
commit 8d7eccad5d
165 changed files with 10894 additions and 6076 deletions

33
pkg/config/label/label.go Normal file
View file

@ -0,0 +1,33 @@
// Package label implements the decoding and encoding between flat labels and a typed Configuration.
package label
import (
"github.com/containous/traefik/pkg/config"
"github.com/containous/traefik/pkg/config/parser"
)
// DecodeConfiguration converts the labels to a configuration.
func DecodeConfiguration(labels map[string]string) (*config.Configuration, error) {
conf := &config.Configuration{
HTTP: &config.HTTPConfiguration{},
TCP: &config.TCPConfiguration{},
}
err := parser.Decode(labels, conf, "traefik.http", "traefik.tcp")
if err != nil {
return nil, err
}
return conf, nil
}
// EncodeConfiguration converts a configuration to labels.
func EncodeConfiguration(conf *config.Configuration) (map[string]string, error) {
return parser.Encode(conf)
}
// Decode converts the labels to an element.
// labels -> [ node -> node + metadata (type) ] -> element (node)
func Decode(labels map[string]string, element interface{}, filters ...string) error {
return parser.Decode(labels, element, filters...)
}