mirror of
https://github.com/status-im/consul.git
synced 2025-01-10 13:55:55 +00:00
vendor: upgrade github.com/hashicorp/go-discover
Pull in improved debug logging for AWS
This commit is contained in:
parent
0516deff0c
commit
ad82659eed
8
vendor/github.com/hashicorp/go-discover/README.md
generated
vendored
8
vendor/github.com/hashicorp/go-discover/README.md
generated
vendored
@ -17,10 +17,10 @@ The following cloud providers have implementations in the go-discover/provider
|
||||
sub packages. Additional providers can be added through the [Register](https://godoc.org/github.com/hashicorp/go-discover#Register)
|
||||
function.
|
||||
|
||||
* Amazon AWS [Config options](http://godoc.org/github.com/hashicorp/go-discover/aws)
|
||||
* Google Cloud [Config options](http://godoc.org/github.com/hashicorp/go-discover/gce)
|
||||
* Microsoft Azure [Config options](http://godoc.org/github.com/hashicorp/go-discover/azure)
|
||||
* SoftLayer [Config options](http://godoc.org/github.com/hashicorp/go-discover/softlayer)
|
||||
* Amazon AWS [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/aws)
|
||||
* Google Cloud [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/gce)
|
||||
* Microsoft Azure [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/azure)
|
||||
* SoftLayer [Config options](http://godoc.org/github.com/hashicorp/go-discover/provider/softlayer)
|
||||
|
||||
### Config Example
|
||||
|
||||
|
2
vendor/github.com/hashicorp/go-discover/discover.go
generated
vendored
2
vendor/github.com/hashicorp/go-discover/discover.go
generated
vendored
@ -110,5 +110,7 @@ func (d *Discover) Addrs(cfg string, l *log.Logger) ([]string, error) {
|
||||
if p == nil {
|
||||
return nil, fmt.Errorf("discover: unknown provider " + name)
|
||||
}
|
||||
l.Printf("[DEBUG] discover: Using provider %q", name)
|
||||
|
||||
return p.Addrs(args, l)
|
||||
}
|
||||
|
34
vendor/github.com/hashicorp/go-discover/provider/aws/aws_discover.go
generated
vendored
34
vendor/github.com/hashicorp/go-discover/provider/aws/aws_discover.go
generated
vendored
@ -46,17 +46,26 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error
|
||||
accessKey := args["access_key_id"]
|
||||
secretKey := args["secret_access_key"]
|
||||
|
||||
log.Printf("[DEBUG] discover-aws: Using region=%s tag_key=%s tag_value=%s", region, tagKey, tagValue)
|
||||
if accessKey == "" && secretKey == "" {
|
||||
log.Printf("[DEBUG] discover-aws: No static credentials")
|
||||
log.Printf("[DEBUG] discover-aws: Using environment variables, shared credentials or instance role")
|
||||
} else {
|
||||
log.Printf("[DEBUG] discover-aws: Static credentials provided")
|
||||
}
|
||||
|
||||
if region == "" {
|
||||
l.Printf("[INFO] discover-aws: Looking up region")
|
||||
l.Printf("[INFO] discover-aws: Region not provided. Looking up region in metadata...")
|
||||
ec2meta := ec2metadata.New(session.New())
|
||||
identity, err := ec2meta.GetInstanceIdentityDocument()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("discover-aws: %s", err)
|
||||
return nil, fmt.Errorf("discover-aws: GetInstanceIdentityDocument failed: %s", err)
|
||||
}
|
||||
region = identity.Region
|
||||
}
|
||||
l.Printf("[INFO] discover-aws: Region is %s", region)
|
||||
|
||||
l.Printf("[DEBUG] discover-aws: Creating session...")
|
||||
svc := ec2.New(session.New(), &aws.Config{
|
||||
Region: ®ion,
|
||||
Credentials: credentials.NewChainCredentials(
|
||||
@ -73,29 +82,38 @@ func (p *Provider) Addrs(args map[string]string, l *log.Logger) ([]string, error
|
||||
}),
|
||||
})
|
||||
|
||||
l.Printf("[INFO] discover-aws: Filter instances with %s=%s", tagKey, tagValue)
|
||||
resp, err := svc.DescribeInstances(&ec2.DescribeInstancesInput{
|
||||
Filters: []*ec2.Filter{
|
||||
{
|
||||
&ec2.Filter{
|
||||
Name: aws.String("tag:" + tagKey),
|
||||
Values: []*string{aws.String(tagValue)},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("discover-aws: %s", err)
|
||||
return nil, fmt.Errorf("discover-aws: DescribeInstancesInput failed: %s", err)
|
||||
}
|
||||
l.Printf("[INFO] discover-aws: Filter instances by %s=%s", tagKey, tagValue)
|
||||
|
||||
l.Printf("[DEBUG] discover-aws: Found %d reservations", len(resp.Reservations))
|
||||
var addrs []string
|
||||
for i := range resp.Reservations {
|
||||
for _, inst := range resp.Reservations[i].Instances {
|
||||
for _, r := range resp.Reservations {
|
||||
l.Printf("[DEBUG] discover-aws: Reservation %s has %d instances", *r.ReservationId, len(r.Instances))
|
||||
for _, inst := range r.Instances {
|
||||
id := *inst.InstanceId
|
||||
l.Printf("[DEBUG] discover-aws: Found instance %s", id)
|
||||
|
||||
// Terminated instances don't have the PrivateIpAddress field
|
||||
if inst.PrivateIpAddress == nil {
|
||||
l.Printf("[DEBUG] discover-aws: Instance %s has no private ip", id)
|
||||
continue
|
||||
}
|
||||
l.Printf("[INFO] discover-aws: Found %x", *inst.PrivateIpAddress)
|
||||
|
||||
l.Printf("[INFO] discover-aws: Instance %s has private ip %s", id, *inst.PrivateIpAddress)
|
||||
addrs = append(addrs, *inst.PrivateIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
l.Printf("[DEBUG] discover-aws: Found ip addresses: %v", addrs)
|
||||
return addrs, nil
|
||||
}
|
||||
|
4
vendor/vendor.json
vendored
4
vendor/vendor.json
vendored
@ -25,8 +25,8 @@
|
||||
{"checksumSHA1":"cdOCt0Yb+hdErz8NAQqayxPmRsY=","path":"github.com/hashicorp/errwrap","revision":"7554cd9344cec97297fa6649b055a8c98c2a1e55","revisionTime":"2014-10-28T05:47:10Z"},
|
||||
{"checksumSHA1":"nd3S1qkFv7zZxA9be0bw4nT0pe0=","path":"github.com/hashicorp/go-checkpoint","revision":"e4b2dc34c0f698ee04750bf2035d8b9384233e1b","revisionTime":"2015-10-22T18:15:14Z"},
|
||||
{"checksumSHA1":"b8F628srIitj5p7Y130xc9k0QWs=","path":"github.com/hashicorp/go-cleanhttp","revision":"3573b8b52aa7b37b9358d966a898feb387f62437","revisionTime":"2017-02-11T01:34:15Z"},
|
||||
{"checksumSHA1":"0g3hRu2ynuFBKhurobMnLqMnH3s=","path":"github.com/hashicorp/go-discover","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z"},
|
||||
{"checksumSHA1":"ktNW667wT7z7/l+Lk2g3a/0vCyU=","path":"github.com/hashicorp/go-discover/provider/aws","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
|
||||
{"checksumSHA1":"uNoQWG5h2hzWHjaLi376ZXVaCr4=","path":"github.com/hashicorp/go-discover","revision":"21b26b722865b64ae5809a532d2c18f3a3800129","revisionTime":"2017-08-16T16:53:52Z"},
|
||||
{"checksumSHA1":"6wdwVsYyTqW4ReHsWs4mEwoz1FI=","path":"github.com/hashicorp/go-discover/provider/aws","revision":"21b26b722865b64ae5809a532d2c18f3a3800129","revisionTime":"2017-08-16T16:53:52Z","tree":true},
|
||||
{"checksumSHA1":"r97P32e+VmNMh2vwLkZa1zPEDQU=","path":"github.com/hashicorp/go-discover/provider/azure","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
|
||||
{"checksumSHA1":"KC/MepQsQF17904UShiM61jmaEs=","path":"github.com/hashicorp/go-discover/provider/gce","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
|
||||
{"checksumSHA1":"SIyZ44AHIUTBfI336ACpCeybsLg=","path":"github.com/hashicorp/go-discover/provider/softlayer","revision":"b518491d039b6782035b8881502b4f5e9fcc887b","revisionTime":"2017-08-01T15:32:04Z","tree":true},
|
||||
|
Loading…
x
Reference in New Issue
Block a user