Rename NameProvider to Name
Because golint is gonna cry at some point otherwise. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
de0a57ec76
commit
cdade5f649
10 changed files with 50 additions and 50 deletions
|
@ -15,14 +15,14 @@ type GlobalConfiguration struct {
|
||||||
CertFile, KeyFile string
|
CertFile, KeyFile string
|
||||||
LogLevel string
|
LogLevel string
|
||||||
ProvidersThrottleDuration time.Duration
|
ProvidersThrottleDuration time.Duration
|
||||||
Docker *provider.DockerProvider
|
Docker *provider.Docker
|
||||||
File *provider.FileProvider
|
File *provider.File
|
||||||
Web *WebProvider
|
Web *WebProvider
|
||||||
Marathon *provider.MarathonProvider
|
Marathon *provider.Marathon
|
||||||
Consul *provider.ConsulProvider
|
Consul *provider.Consul
|
||||||
Etcd *provider.EtcdProvider
|
Etcd *provider.Etcd
|
||||||
Zookeeper *provider.ZookepperProvider
|
Zookeeper *provider.Zookepper
|
||||||
Boltdb *provider.BoltDbProvider
|
Boltdb *provider.BoltDb
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewGlobalConfiguration() *GlobalConfiguration {
|
func NewGlobalConfiguration() *GlobalConfiguration {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Copyright
|
Copyright
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//go:generate rm -vf gen.go
|
//go:generate rm -vf autogen/gen.go
|
||||||
//go:generate go-bindata -pkg autogen -o autogen/gen.go ./static/... ./templates/...
|
//go:generate go-bindata -pkg autogen -o autogen/gen.go ./static/... ./templates/...
|
||||||
|
|
||||||
//go:generate mkdir -p vendor/github.com/docker/docker/autogen/dockerversion
|
//go:generate mkdir -p vendor/github.com/docker/docker/autogen/dockerversion
|
||||||
|
|
|
@ -2,15 +2,15 @@ package provider
|
||||||
|
|
||||||
import "github.com/emilevauge/traefik/types"
|
import "github.com/emilevauge/traefik/types"
|
||||||
|
|
||||||
type BoltDbProvider struct {
|
type BoltDb struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Prefix string
|
Prefix string
|
||||||
Filename string
|
Filename string
|
||||||
KvProvider *KvProvider
|
KvProvider *Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *BoltDbProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *BoltDb) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
provider.KvProvider = NewBoltDbProvider(provider)
|
provider.KvProvider = NewBoltDbProvider(provider)
|
||||||
return provider.KvProvider.provide(configurationChan)
|
return provider.KvProvider.provide(configurationChan)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ package provider
|
||||||
|
|
||||||
import "github.com/emilevauge/traefik/types"
|
import "github.com/emilevauge/traefik/types"
|
||||||
|
|
||||||
type ConsulProvider struct {
|
type Consul struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Prefix string
|
Prefix string
|
||||||
Filename string
|
Filename string
|
||||||
KvProvider *KvProvider
|
KvProvider *Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *ConsulProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Consul) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
provider.KvProvider = NewConsulProvider(provider)
|
provider.KvProvider = NewConsulProvider(provider)
|
||||||
return provider.KvProvider.provide(configurationChan)
|
return provider.KvProvider.provide(configurationChan)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,14 +18,14 @@ import (
|
||||||
"github.com/fsouza/go-dockerclient"
|
"github.com/fsouza/go-dockerclient"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DockerProvider struct {
|
type Docker struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Filename string
|
Filename string
|
||||||
Domain string
|
Domain string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Docker) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
if dockerClient, err := docker.NewClient(provider.Endpoint); err != nil {
|
if dockerClient, err := docker.NewClient(provider.Endpoint); err != nil {
|
||||||
log.Errorf("Failed to create a client for docker, error: %s", err)
|
log.Errorf("Failed to create a client for docker, error: %s", err)
|
||||||
return err
|
return err
|
||||||
|
@ -73,7 +73,7 @@ func (provider *DockerProvider) Provide(configurationChan chan<- types.ConfigMes
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *types.Configuration {
|
func (provider *Docker) loadDockerConfig(dockerClient *docker.Client) *types.Configuration {
|
||||||
var DockerFuncMap = template.FuncMap{
|
var DockerFuncMap = template.FuncMap{
|
||||||
"getBackend": func(container docker.Container) string {
|
"getBackend": func(container docker.Container) string {
|
||||||
if label, err := provider.getLabel(container, "traefik.backend"); err == nil {
|
if label, err := provider.getLabel(container, "traefik.backend"); err == nil {
|
||||||
|
@ -201,17 +201,17 @@ func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *t
|
||||||
return configuration
|
return configuration
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) getFrontendName(container docker.Container) string {
|
func (provider *Docker) getFrontendName(container docker.Container) string {
|
||||||
// Replace '.' with '-' in quoted keys because of this issue https://github.com/BurntSushi/toml/issues/78
|
// Replace '.' with '-' in quoted keys because of this issue https://github.com/BurntSushi/toml/issues/78
|
||||||
frontendName := fmt.Sprintf("%s-%s", provider.GetFrontendRule(container), provider.GetFrontendValue(container))
|
frontendName := fmt.Sprintf("%s-%s", provider.GetFrontendRule(container), provider.GetFrontendValue(container))
|
||||||
return strings.Replace(frontendName, ".", "-", -1)
|
return strings.Replace(frontendName, ".", "-", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) getEscapedName(name string) string {
|
func (provider *Docker) getEscapedName(name string) string {
|
||||||
return strings.Replace(name, "/", "", -1)
|
return strings.Replace(name, "/", "", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) getLabel(container docker.Container, label string) (string, error) {
|
func (provider *Docker) getLabel(container docker.Container, label string) (string, error) {
|
||||||
for key, value := range container.Config.Labels {
|
for key, value := range container.Config.Labels {
|
||||||
if key == label {
|
if key == label {
|
||||||
return value, nil
|
return value, nil
|
||||||
|
@ -220,7 +220,7 @@ func (provider *DockerProvider) getLabel(container docker.Container, label strin
|
||||||
return "", errors.New("Label not found:" + label)
|
return "", errors.New("Label not found:" + label)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) getLabels(container docker.Container, labels []string) (map[string]string, error) {
|
func (provider *Docker) getLabels(container docker.Container, labels []string) (map[string]string, error) {
|
||||||
foundLabels := map[string]string{}
|
foundLabels := map[string]string{}
|
||||||
for _, label := range labels {
|
for _, label := range labels {
|
||||||
if foundLabel, err := provider.getLabel(container, label); err != nil {
|
if foundLabel, err := provider.getLabel(container, label); err != nil {
|
||||||
|
@ -232,14 +232,14 @@ func (provider *DockerProvider) getLabels(container docker.Container, labels []s
|
||||||
return foundLabels, nil
|
return foundLabels, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) GetFrontendValue(container docker.Container) string {
|
func (provider *Docker) GetFrontendValue(container docker.Container) string {
|
||||||
if label, err := provider.getLabel(container, "traefik.frontend.value"); err == nil {
|
if label, err := provider.getLabel(container, "traefik.frontend.value"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
return provider.getEscapedName(container.Name) + "." + provider.Domain
|
return provider.getEscapedName(container.Name) + "." + provider.Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *DockerProvider) GetFrontendRule(container docker.Container) string {
|
func (provider *Docker) GetFrontendRule(container docker.Container) string {
|
||||||
if label, err := provider.getLabel(container, "traefik.frontend.rule"); err == nil {
|
if label, err := provider.getLabel(container, "traefik.frontend.rule"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ package provider
|
||||||
|
|
||||||
import "github.com/emilevauge/traefik/types"
|
import "github.com/emilevauge/traefik/types"
|
||||||
|
|
||||||
type EtcdProvider struct {
|
type Etcd struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Prefix string
|
Prefix string
|
||||||
Filename string
|
Filename string
|
||||||
KvProvider *KvProvider
|
KvProvider *Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *EtcdProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Etcd) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
provider.KvProvider = NewEtcdProvider(provider)
|
provider.KvProvider = NewEtcdProvider(provider)
|
||||||
return provider.KvProvider.provide(configurationChan)
|
return provider.KvProvider.provide(configurationChan)
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ import (
|
||||||
"gopkg.in/fsnotify.v1"
|
"gopkg.in/fsnotify.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FileProvider struct {
|
type File struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Filename string
|
Filename string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *FileProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *File) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
watcher, err := fsnotify.NewWatcher()
|
watcher, err := fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Error creating file watcher", err)
|
log.Error("Error creating file watcher", err)
|
||||||
|
@ -61,7 +61,7 @@ func (provider *FileProvider) Provide(configurationChan chan<- types.ConfigMessa
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *FileProvider) LoadFileConfig(filename string) *types.Configuration {
|
func (provider *File) LoadFileConfig(filename string) *types.Configuration {
|
||||||
configuration := new(types.Configuration)
|
configuration := new(types.Configuration)
|
||||||
if _, err := toml.DecodeFile(filename, configuration); err != nil {
|
if _, err := toml.DecodeFile(filename, configuration); err != nil {
|
||||||
log.Error("Error reading file:", err)
|
log.Error("Error reading file:", err)
|
||||||
|
|
|
@ -23,7 +23,7 @@ import (
|
||||||
"github.com/emilevauge/traefik/types"
|
"github.com/emilevauge/traefik/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KvProvider struct {
|
type Kv struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Prefix string
|
Prefix string
|
||||||
|
@ -32,8 +32,8 @@ type KvProvider struct {
|
||||||
kvclient store.Store
|
kvclient store.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConsulProvider(provider *ConsulProvider) *KvProvider {
|
func NewConsulProvider(provider *Consul) *Kv {
|
||||||
kvProvider := new(KvProvider)
|
kvProvider := new(Kv)
|
||||||
kvProvider.Watch = provider.Watch
|
kvProvider.Watch = provider.Watch
|
||||||
kvProvider.Endpoint = provider.Endpoint
|
kvProvider.Endpoint = provider.Endpoint
|
||||||
kvProvider.Prefix = provider.Prefix
|
kvProvider.Prefix = provider.Prefix
|
||||||
|
@ -42,8 +42,8 @@ func NewConsulProvider(provider *ConsulProvider) *KvProvider {
|
||||||
return kvProvider
|
return kvProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEtcdProvider(provider *EtcdProvider) *KvProvider {
|
func NewEtcdProvider(provider *Etcd) *Kv {
|
||||||
kvProvider := new(KvProvider)
|
kvProvider := new(Kv)
|
||||||
kvProvider.Watch = provider.Watch
|
kvProvider.Watch = provider.Watch
|
||||||
kvProvider.Endpoint = provider.Endpoint
|
kvProvider.Endpoint = provider.Endpoint
|
||||||
kvProvider.Prefix = provider.Prefix
|
kvProvider.Prefix = provider.Prefix
|
||||||
|
@ -52,8 +52,8 @@ func NewEtcdProvider(provider *EtcdProvider) *KvProvider {
|
||||||
return kvProvider
|
return kvProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewZkProvider(provider *ZookepperProvider) *KvProvider {
|
func NewZkProvider(provider *Zookepper) *Kv {
|
||||||
kvProvider := new(KvProvider)
|
kvProvider := new(Kv)
|
||||||
kvProvider.Watch = provider.Watch
|
kvProvider.Watch = provider.Watch
|
||||||
kvProvider.Endpoint = provider.Endpoint
|
kvProvider.Endpoint = provider.Endpoint
|
||||||
kvProvider.Prefix = provider.Prefix
|
kvProvider.Prefix = provider.Prefix
|
||||||
|
@ -62,8 +62,8 @@ func NewZkProvider(provider *ZookepperProvider) *KvProvider {
|
||||||
return kvProvider
|
return kvProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBoltDbProvider(provider *BoltDbProvider) *KvProvider {
|
func NewBoltDbProvider(provider *BoltDb) *Kv {
|
||||||
kvProvider := new(KvProvider)
|
kvProvider := new(Kv)
|
||||||
kvProvider.Watch = provider.Watch
|
kvProvider.Watch = provider.Watch
|
||||||
kvProvider.Endpoint = provider.Endpoint
|
kvProvider.Endpoint = provider.Endpoint
|
||||||
kvProvider.Prefix = provider.Prefix
|
kvProvider.Prefix = provider.Prefix
|
||||||
|
@ -72,7 +72,7 @@ func NewBoltDbProvider(provider *BoltDbProvider) *KvProvider {
|
||||||
return kvProvider
|
return kvProvider
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *KvProvider) provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Kv) provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
switch provider.StoreType {
|
switch provider.StoreType {
|
||||||
case store.CONSUL:
|
case store.CONSUL:
|
||||||
consul.Register()
|
consul.Register()
|
||||||
|
@ -122,7 +122,7 @@ func (provider *KvProvider) provide(configurationChan chan<- types.ConfigMessage
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *KvProvider) loadConfig() *types.Configuration {
|
func (provider *Kv) loadConfig() *types.Configuration {
|
||||||
configuration := new(types.Configuration)
|
configuration := new(types.Configuration)
|
||||||
templateObjects := struct {
|
templateObjects := struct {
|
||||||
Prefix string
|
Prefix string
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/gambol99/go-marathon"
|
"github.com/gambol99/go-marathon"
|
||||||
)
|
)
|
||||||
|
|
||||||
type MarathonProvider struct {
|
type Marathon struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
marathonClient marathon.Marathon
|
marathonClient marathon.Marathon
|
||||||
|
@ -24,7 +24,7 @@ type MarathonProvider struct {
|
||||||
NetworkInterface string
|
NetworkInterface string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
config := marathon.NewDefaultConfig()
|
config := marathon.NewDefaultConfig()
|
||||||
config.URL = provider.Endpoint
|
config.URL = provider.Endpoint
|
||||||
config.EventsInterface = provider.NetworkInterface
|
config.EventsInterface = provider.NetworkInterface
|
||||||
|
@ -57,7 +57,7 @@ func (provider *MarathonProvider) Provide(configurationChan chan<- types.ConfigM
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) loadMarathonConfig() *types.Configuration {
|
func (provider *Marathon) loadMarathonConfig() *types.Configuration {
|
||||||
var MarathonFuncMap = template.FuncMap{
|
var MarathonFuncMap = template.FuncMap{
|
||||||
"getPort": func(task marathon.Task) string {
|
"getPort": func(task marathon.Task) string {
|
||||||
for _, port := range task.Ports {
|
for _, port := range task.Ports {
|
||||||
|
@ -225,7 +225,7 @@ func getApplication(task marathon.Task, apps []marathon.Application) (marathon.A
|
||||||
return marathon.Application{}, errors.New("Application not found: " + task.AppID)
|
return marathon.Application{}, errors.New("Application not found: " + task.AppID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) getLabel(application marathon.Application, label string) (string, error) {
|
func (provider *Marathon) getLabel(application marathon.Application, label string) (string, error) {
|
||||||
for key, value := range application.Labels {
|
for key, value := range application.Labels {
|
||||||
if key == label {
|
if key == label {
|
||||||
return value, nil
|
return value, nil
|
||||||
|
@ -234,18 +234,18 @@ func (provider *MarathonProvider) getLabel(application marathon.Application, lab
|
||||||
return "", errors.New("Label not found:" + label)
|
return "", errors.New("Label not found:" + label)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) getEscapedName(name string) string {
|
func (provider *Marathon) getEscapedName(name string) string {
|
||||||
return strings.Replace(name, "/", "", -1)
|
return strings.Replace(name, "/", "", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) GetFrontendValue(application marathon.Application) string {
|
func (provider *Marathon) GetFrontendValue(application marathon.Application) string {
|
||||||
if label, err := provider.getLabel(application, "traefik.frontend.value"); err == nil {
|
if label, err := provider.getLabel(application, "traefik.frontend.value"); err == nil {
|
||||||
return label
|
return label
|
||||||
}
|
}
|
||||||
return provider.getEscapedName(application.ID) + "." + provider.Domain
|
return provider.getEscapedName(application.ID) + "." + provider.Domain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *MarathonProvider) GetFrontendRule(application marathon.Application) string {
|
func (provider *Marathon) GetFrontendRule(application marathon.Application) string {
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,15 @@ package provider
|
||||||
|
|
||||||
import "github.com/emilevauge/traefik/types"
|
import "github.com/emilevauge/traefik/types"
|
||||||
|
|
||||||
type ZookepperProvider struct {
|
type Zookepper struct {
|
||||||
Watch bool
|
Watch bool
|
||||||
Endpoint string
|
Endpoint string
|
||||||
Prefix string
|
Prefix string
|
||||||
Filename string
|
Filename string
|
||||||
KvProvider *KvProvider
|
KvProvider *Kv
|
||||||
}
|
}
|
||||||
|
|
||||||
func (provider *ZookepperProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
|
func (provider *Zookepper) Provide(configurationChan chan<- types.ConfigMessage) error {
|
||||||
provider.KvProvider = NewZkProvider(provider)
|
provider.KvProvider = NewZkProvider(provider)
|
||||||
return provider.KvProvider.provide(configurationChan)
|
return provider.KvProvider.provide(configurationChan)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue