Small code enhancements on providers

This commit is contained in:
Vincent Demeester 2018-08-01 16:58:03 +02:00 committed by Traefiker Bot
parent 6f6ebb8025
commit 43d22d7a2f
6 changed files with 9 additions and 16 deletions

View file

@ -174,10 +174,6 @@ func (p *Provider) getWeight(tags []string) int {
// Base functions
func (p *Provider) hasAttribute(name string, tags []string) bool {
return hasTag(p.getPrefixedName(name), tags)
}
func (p *Provider) getAttribute(name string, tags []string, defaultValue string) string {
return getTag(p.getPrefixedName(name), tags, defaultValue)
}

View file

@ -97,7 +97,9 @@ func (p *Provider) createClient() (client.APIClient, error) {
if err != nil {
return nil, err
}
sockets.ConfigureTransport(tr, hostURL.Scheme, hostURL.Host)
if err := sockets.ConfigureTransport(tr, hostURL.Scheme, hostURL.Host); err != nil {
return nil, err
}
httpClient = &http.Client{
Transport: tr,

View file

@ -79,7 +79,7 @@ func (p *Provider) createClient() (*dynamoClient, error) {
}
return &dynamoClient{
dynamodb.New(sess, cfg),
db: dynamodb.New(sess, cfg),
}, nil
}

View file

@ -53,7 +53,6 @@ type portMapping struct {
}
type machine struct {
name string
state string
privateIP string
ports []portMapping
@ -108,8 +107,8 @@ func (p *Provider) createClient() (*awsClient, error) {
}
return &awsClient{
ecs.New(sess, cfg),
ec2.New(sess, cfg),
ecs: ecs.New(sess, cfg),
ec2: ec2.New(sess, cfg),
}, nil
}
@ -419,7 +418,7 @@ func (p *Provider) loadECSConfig(ctx context.Context, client *awsClient) (*types
func (p *Provider) chunkIDs(ids []*string) [][]*string {
var chuncked [][]*string
for i := 0; i < len(ids); i += 100 {
sliceEnd := -1
var sliceEnd int
if i+100 < len(ids) {
sliceEnd = i + 100
} else {

View file

@ -161,9 +161,7 @@ func (c *clientImpl) GetIngresses() []*extensionsv1beta1.Ingress {
if err != nil {
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
}
for _, ing := range ings {
result = append(result, ing)
}
result = append(result, ings...)
}
return result
}
@ -237,7 +235,7 @@ func (c *clientImpl) newResourceEventHandler(events chan<- interface{}) cache.Re
}
return true
},
Handler: &resourceEventHandler{events},
Handler: &resourceEventHandler{ev: events},
}
}

View file

@ -16,8 +16,6 @@ import (
"github.com/gambol99/go-marathon"
)
const defaultService = ""
type appData struct {
marathon.Application
SegmentLabels map[string]string