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:
Vincent Demeester 2015-11-02 19:48:34 +01:00
parent de0a57ec76
commit cdade5f649
10 changed files with 50 additions and 50 deletions

View file

@ -15,14 +15,14 @@ type GlobalConfiguration struct {
CertFile, KeyFile string
LogLevel string
ProvidersThrottleDuration time.Duration
Docker *provider.DockerProvider
File *provider.FileProvider
Docker *provider.Docker
File *provider.File
Web *WebProvider
Marathon *provider.MarathonProvider
Consul *provider.ConsulProvider
Etcd *provider.EtcdProvider
Zookeeper *provider.ZookepperProvider
Boltdb *provider.BoltDbProvider
Marathon *provider.Marathon
Consul *provider.Consul
Etcd *provider.Etcd
Zookeeper *provider.Zookepper
Boltdb *provider.BoltDb
}
func NewGlobalConfiguration() *GlobalConfiguration {

View file

@ -2,7 +2,7 @@
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 mkdir -p vendor/github.com/docker/docker/autogen/dockerversion

View file

@ -2,15 +2,15 @@ package provider
import "github.com/emilevauge/traefik/types"
type BoltDbProvider struct {
type BoltDb struct {
Watch bool
Endpoint string
Prefix 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)
return provider.KvProvider.provide(configurationChan)
}

View file

@ -2,15 +2,15 @@ package provider
import "github.com/emilevauge/traefik/types"
type ConsulProvider struct {
type Consul struct {
Watch bool
Endpoint string
Prefix 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)
return provider.KvProvider.provide(configurationChan)
}

View file

@ -18,14 +18,14 @@ import (
"github.com/fsouza/go-dockerclient"
)
type DockerProvider struct {
type Docker struct {
Watch bool
Endpoint string
Filename 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 {
log.Errorf("Failed to create a client for docker, error: %s", err)
return err
@ -73,7 +73,7 @@ func (provider *DockerProvider) Provide(configurationChan chan<- types.ConfigMes
return nil
}
func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *types.Configuration {
func (provider *Docker) loadDockerConfig(dockerClient *docker.Client) *types.Configuration {
var DockerFuncMap = template.FuncMap{
"getBackend": func(container docker.Container) string {
if label, err := provider.getLabel(container, "traefik.backend"); err == nil {
@ -201,17 +201,17 @@ func (provider *DockerProvider) loadDockerConfig(dockerClient *docker.Client) *t
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
frontendName := fmt.Sprintf("%s-%s", provider.GetFrontendRule(container), provider.GetFrontendValue(container))
return strings.Replace(frontendName, ".", "-", -1)
}
func (provider *DockerProvider) getEscapedName(name string) string {
func (provider *Docker) getEscapedName(name string) string {
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 {
if key == label {
return value, nil
@ -220,7 +220,7 @@ func (provider *DockerProvider) getLabel(container docker.Container, label strin
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{}
for _, label := range labels {
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
}
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 {
return label
}
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 {
return label
}

View file

@ -2,15 +2,15 @@ package provider
import "github.com/emilevauge/traefik/types"
type EtcdProvider struct {
type Etcd struct {
Watch bool
Endpoint string
Prefix 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)
return provider.KvProvider.provide(configurationChan)
}

View file

@ -11,12 +11,12 @@ import (
"gopkg.in/fsnotify.v1"
)
type FileProvider struct {
type File struct {
Watch bool
Filename string
}
func (provider *FileProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
func (provider *File) Provide(configurationChan chan<- types.ConfigMessage) error {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Error("Error creating file watcher", err)
@ -61,7 +61,7 @@ func (provider *FileProvider) Provide(configurationChan chan<- types.ConfigMessa
return nil
}
func (provider *FileProvider) LoadFileConfig(filename string) *types.Configuration {
func (provider *File) LoadFileConfig(filename string) *types.Configuration {
configuration := new(types.Configuration)
if _, err := toml.DecodeFile(filename, configuration); err != nil {
log.Error("Error reading file:", err)

View file

@ -23,7 +23,7 @@ import (
"github.com/emilevauge/traefik/types"
)
type KvProvider struct {
type Kv struct {
Watch bool
Endpoint string
Prefix string
@ -32,8 +32,8 @@ type KvProvider struct {
kvclient store.Store
}
func NewConsulProvider(provider *ConsulProvider) *KvProvider {
kvProvider := new(KvProvider)
func NewConsulProvider(provider *Consul) *Kv {
kvProvider := new(Kv)
kvProvider.Watch = provider.Watch
kvProvider.Endpoint = provider.Endpoint
kvProvider.Prefix = provider.Prefix
@ -42,8 +42,8 @@ func NewConsulProvider(provider *ConsulProvider) *KvProvider {
return kvProvider
}
func NewEtcdProvider(provider *EtcdProvider) *KvProvider {
kvProvider := new(KvProvider)
func NewEtcdProvider(provider *Etcd) *Kv {
kvProvider := new(Kv)
kvProvider.Watch = provider.Watch
kvProvider.Endpoint = provider.Endpoint
kvProvider.Prefix = provider.Prefix
@ -52,8 +52,8 @@ func NewEtcdProvider(provider *EtcdProvider) *KvProvider {
return kvProvider
}
func NewZkProvider(provider *ZookepperProvider) *KvProvider {
kvProvider := new(KvProvider)
func NewZkProvider(provider *Zookepper) *Kv {
kvProvider := new(Kv)
kvProvider.Watch = provider.Watch
kvProvider.Endpoint = provider.Endpoint
kvProvider.Prefix = provider.Prefix
@ -62,8 +62,8 @@ func NewZkProvider(provider *ZookepperProvider) *KvProvider {
return kvProvider
}
func NewBoltDbProvider(provider *BoltDbProvider) *KvProvider {
kvProvider := new(KvProvider)
func NewBoltDbProvider(provider *BoltDb) *Kv {
kvProvider := new(Kv)
kvProvider.Watch = provider.Watch
kvProvider.Endpoint = provider.Endpoint
kvProvider.Prefix = provider.Prefix
@ -72,7 +72,7 @@ func NewBoltDbProvider(provider *BoltDbProvider) *KvProvider {
return kvProvider
}
func (provider *KvProvider) provide(configurationChan chan<- types.ConfigMessage) error {
func (provider *Kv) provide(configurationChan chan<- types.ConfigMessage) error {
switch provider.StoreType {
case store.CONSUL:
consul.Register()
@ -122,7 +122,7 @@ func (provider *KvProvider) provide(configurationChan chan<- types.ConfigMessage
return nil
}
func (provider *KvProvider) loadConfig() *types.Configuration {
func (provider *Kv) loadConfig() *types.Configuration {
configuration := new(types.Configuration)
templateObjects := struct {
Prefix string

View file

@ -15,7 +15,7 @@ import (
"github.com/gambol99/go-marathon"
)
type MarathonProvider struct {
type Marathon struct {
Watch bool
Endpoint string
marathonClient marathon.Marathon
@ -24,7 +24,7 @@ type MarathonProvider struct {
NetworkInterface string
}
func (provider *MarathonProvider) Provide(configurationChan chan<- types.ConfigMessage) error {
func (provider *Marathon) Provide(configurationChan chan<- types.ConfigMessage) error {
config := marathon.NewDefaultConfig()
config.URL = provider.Endpoint
config.EventsInterface = provider.NetworkInterface
@ -57,7 +57,7 @@ func (provider *MarathonProvider) Provide(configurationChan chan<- types.ConfigM
return nil
}
func (provider *MarathonProvider) loadMarathonConfig() *types.Configuration {
func (provider *Marathon) loadMarathonConfig() *types.Configuration {
var MarathonFuncMap = template.FuncMap{
"getPort": func(task marathon.Task) string {
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)
}
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 {
if key == label {
return value, nil
@ -234,18 +234,18 @@ func (provider *MarathonProvider) getLabel(application marathon.Application, lab
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)
}
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 {
return label
}
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 {
return label
}

View file

@ -2,15 +2,15 @@ package provider
import "github.com/emilevauge/traefik/types"
type ZookepperProvider struct {
type Zookepper struct {
Watch bool
Endpoint string
Prefix 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)
return provider.KvProvider.provide(configurationChan)
}