From 43d22d7a2f0c24b4c9c0da72f80f50f78d27a688 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 1 Aug 2018 16:58:03 +0200 Subject: [PATCH] Small code enhancements on providers --- provider/consulcatalog/config.go | 4 ---- provider/docker/docker.go | 4 +++- provider/dynamodb/dynamodb.go | 2 +- provider/ecs/ecs.go | 7 +++---- provider/kubernetes/client.go | 6 ++---- provider/marathon/config.go | 2 -- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/provider/consulcatalog/config.go b/provider/consulcatalog/config.go index 1532132dd..96466ed9d 100644 --- a/provider/consulcatalog/config.go +++ b/provider/consulcatalog/config.go @@ -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) } diff --git a/provider/docker/docker.go b/provider/docker/docker.go index 250430998..a49b40adf 100644 --- a/provider/docker/docker.go +++ b/provider/docker/docker.go @@ -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, diff --git a/provider/dynamodb/dynamodb.go b/provider/dynamodb/dynamodb.go index e2876da02..2de67e35d 100644 --- a/provider/dynamodb/dynamodb.go +++ b/provider/dynamodb/dynamodb.go @@ -79,7 +79,7 @@ func (p *Provider) createClient() (*dynamoClient, error) { } return &dynamoClient{ - dynamodb.New(sess, cfg), + db: dynamodb.New(sess, cfg), }, nil } diff --git a/provider/ecs/ecs.go b/provider/ecs/ecs.go index 25a36b63e..ce0e9fe30 100644 --- a/provider/ecs/ecs.go +++ b/provider/ecs/ecs.go @@ -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 { diff --git a/provider/kubernetes/client.go b/provider/kubernetes/client.go index ca2c8eefd..d09bf5a40 100644 --- a/provider/kubernetes/client.go +++ b/provider/kubernetes/client.go @@ -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}, } } diff --git a/provider/marathon/config.go b/provider/marathon/config.go index 2bf884755..fc4117836 100644 --- a/provider/marathon/config.go +++ b/provider/marathon/config.go @@ -16,8 +16,6 @@ import ( "github.com/gambol99/go-marathon" ) -const defaultService = "" - type appData struct { marathon.Application SegmentLabels map[string]string