Add backwards compatibility
Signed-off-by: Emile Vauge <emile@vauge.com>
This commit is contained in:
parent
8737530a7d
commit
bb072a1f8f
4 changed files with 32 additions and 9 deletions
|
@ -152,12 +152,6 @@ func containerFilter(container docker.Container) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// labels, err := getLabels(container, []string{"traefik.frontend.rule"})
|
|
||||||
// if len(labels) != 0 && err != nil {
|
|
||||||
// log.Debugf("Filtering bad labeled container %s", container.Name)
|
|
||||||
// return false
|
|
||||||
// }
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +163,15 @@ func (provider *Docker) getFrontendName(container docker.Container) string {
|
||||||
// GetFrontendRule returns the frontend rule for the specified container, using
|
// GetFrontendRule returns the frontend rule for the specified container, using
|
||||||
// it's label. It returns a default one (Host) if the label is not present.
|
// it's label. It returns a default one (Host) if the label is not present.
|
||||||
func (provider *Docker) getFrontendRule(container docker.Container) string {
|
func (provider *Docker) getFrontendRule(container docker.Container) string {
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
// TODO: backwards compatibility with DEPRECATED rule.Value
|
||||||
|
if value, ok := container.Config.Labels["traefik.frontend.value"]; ok {
|
||||||
|
log.Warnf("Label traefik.frontend.value=%s is DEPRECATED, please refer to the rule label: https://github.com/containous/traefik/blob/master/docs/index.md#docker", value)
|
||||||
|
rule, _ := container.Config.Labels["traefik.frontend.rule"]
|
||||||
|
return rule + ":" + value
|
||||||
|
}
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
|
||||||
if label, err := getLabel(container, "traefik.frontend.rule"); err == nil {
|
if label, err := getLabel(container, "traefik.frontend.rule"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,6 +311,14 @@ func (provider *Marathon) getEntryPoints(application marathon.Application) []str
|
||||||
// getFrontendRule returns the frontend rule for the specified application, using
|
// getFrontendRule returns the frontend rule for the specified application, using
|
||||||
// it's label. It returns a default one (Host) if the label is not present.
|
// it's label. It returns a default one (Host) if the label is not present.
|
||||||
func (provider *Marathon) getFrontendRule(application marathon.Application) string {
|
func (provider *Marathon) getFrontendRule(application marathon.Application) string {
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
// TODO: backwards compatibility with DEPRECATED rule.Value
|
||||||
|
if value, err := provider.getLabel(application, "traefik.frontend.value"); err == nil {
|
||||||
|
log.Warnf("Label traefik.frontend.value=%s is DEPRECATED, please refer to the rule label: https://github.com/containous/traefik/blob/master/docs/index.md#marathon", value)
|
||||||
|
rule, _ := provider.getLabel(application, "traefik.frontend.rule")
|
||||||
|
return rule + ":" + value
|
||||||
|
}
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
if label, err := provider.getLabel(application, "traefik.frontend.rule"); err == nil {
|
if label, err := provider.getLabel(application, "traefik.frontend.rule"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
14
server.go
14
server.go
|
@ -361,11 +361,11 @@ func (server *Server) loadConfig(configurations configs, globalConfiguration Glo
|
||||||
}
|
}
|
||||||
newServerRoute := &serverRoute{route: serverEntryPoints[entryPointName].httpRouter.GetHandler().NewRoute().Name(frontendName)}
|
newServerRoute := &serverRoute{route: serverEntryPoints[entryPointName].httpRouter.GetHandler().NewRoute().Name(frontendName)}
|
||||||
for routeName, route := range frontend.Routes {
|
for routeName, route := range frontend.Routes {
|
||||||
log.Debugf("Creating route %s %s", routeName, route.Rule)
|
err := getRoute(newServerRoute, &route)
|
||||||
err := getRoute(newServerRoute, route)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
log.Debugf("Creating route %s %s", routeName, route.Rule)
|
||||||
}
|
}
|
||||||
entryPoint := globalConfiguration.EntryPoints[entryPointName]
|
entryPoint := globalConfiguration.EntryPoints[entryPointName]
|
||||||
if entryPoint.Redirect != nil {
|
if entryPoint.Redirect != nil {
|
||||||
|
@ -512,7 +512,15 @@ func (server *Server) buildDefaultHTTPRouter() *mux.Router {
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
func getRoute(serverRoute *serverRoute, route types.Route) error {
|
func getRoute(serverRoute *serverRoute, route *types.Route) error {
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
// TODO: backwards compatibility with DEPRECATED rule.Value
|
||||||
|
if len(route.Value) > 0 {
|
||||||
|
route.Rule += ":" + route.Value
|
||||||
|
log.Warnf("Value %s is DEPRECATED, please refer to the new frontend notation: https://github.com/containous/traefik/blob/master/docs/index.md#-frontends", route.Value)
|
||||||
|
}
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
|
||||||
rules := Rules{route: serverRoute}
|
rules := Rules{route: serverRoute}
|
||||||
newRoute, err := rules.Parse(route.Rule)
|
newRoute, err := rules.Parse(route.Rule)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -31,6 +31,10 @@ type Server struct {
|
||||||
// Route holds route configuration.
|
// Route holds route configuration.
|
||||||
type Route struct {
|
type Route struct {
|
||||||
Rule string `json:"rule,omitempty"`
|
Rule string `json:"rule,omitempty"`
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
|
// TODO: backwards compatibility with DEPRECATED rule.Value
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
// ⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠⚠
|
||||||
}
|
}
|
||||||
|
|
||||||
// Frontend holds frontend configuration.
|
// Frontend holds frontend configuration.
|
||||||
|
|
Loading…
Reference in a new issue