Small code enhancements on providers
This commit is contained in:
parent
6f6ebb8025
commit
43d22d7a2f
6 changed files with 9 additions and 16 deletions
|
@ -174,10 +174,6 @@ func (p *Provider) getWeight(tags []string) int {
|
||||||
|
|
||||||
// Base functions
|
// 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 {
|
func (p *Provider) getAttribute(name string, tags []string, defaultValue string) string {
|
||||||
return getTag(p.getPrefixedName(name), tags, defaultValue)
|
return getTag(p.getPrefixedName(name), tags, defaultValue)
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,9 @@ func (p *Provider) createClient() (client.APIClient, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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{
|
httpClient = &http.Client{
|
||||||
Transport: tr,
|
Transport: tr,
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (p *Provider) createClient() (*dynamoClient, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &dynamoClient{
|
return &dynamoClient{
|
||||||
dynamodb.New(sess, cfg),
|
db: dynamodb.New(sess, cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ type portMapping struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type machine struct {
|
type machine struct {
|
||||||
name string
|
|
||||||
state string
|
state string
|
||||||
privateIP string
|
privateIP string
|
||||||
ports []portMapping
|
ports []portMapping
|
||||||
|
@ -108,8 +107,8 @@ func (p *Provider) createClient() (*awsClient, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &awsClient{
|
return &awsClient{
|
||||||
ecs.New(sess, cfg),
|
ecs: ecs.New(sess, cfg),
|
||||||
ec2.New(sess, cfg),
|
ec2: ec2.New(sess, cfg),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,7 +418,7 @@ func (p *Provider) loadECSConfig(ctx context.Context, client *awsClient) (*types
|
||||||
func (p *Provider) chunkIDs(ids []*string) [][]*string {
|
func (p *Provider) chunkIDs(ids []*string) [][]*string {
|
||||||
var chuncked [][]*string
|
var chuncked [][]*string
|
||||||
for i := 0; i < len(ids); i += 100 {
|
for i := 0; i < len(ids); i += 100 {
|
||||||
sliceEnd := -1
|
var sliceEnd int
|
||||||
if i+100 < len(ids) {
|
if i+100 < len(ids) {
|
||||||
sliceEnd = i + 100
|
sliceEnd = i + 100
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -161,9 +161,7 @@ func (c *clientImpl) GetIngresses() []*extensionsv1beta1.Ingress {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
log.Errorf("Failed to list ingresses in namespace %s: %s", ns, err)
|
||||||
}
|
}
|
||||||
for _, ing := range ings {
|
result = append(result, ings...)
|
||||||
result = append(result, ing)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
@ -237,7 +235,7 @@ func (c *clientImpl) newResourceEventHandler(events chan<- interface{}) cache.Re
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
Handler: &resourceEventHandler{events},
|
Handler: &resourceEventHandler{ev: events},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,6 @@ import (
|
||||||
"github.com/gambol99/go-marathon"
|
"github.com/gambol99/go-marathon"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultService = ""
|
|
||||||
|
|
||||||
type appData struct {
|
type appData struct {
|
||||||
marathon.Application
|
marathon.Application
|
||||||
SegmentLabels map[string]string
|
SegmentLabels map[string]string
|
||||||
|
|
Loading…
Add table
Reference in a new issue