consul/vendor/github.com/hashicorp/go-discover
Frank Schröder 26bfb2d00a discover: move instance discover code into separate package (#3144)
This patch moves the code that discovers instances from metadata
information to github.com/hashicorp/go-discover with
sub-packages for each provider.
2017-06-21 10:40:38 +02:00
..
aws discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
azure discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
config discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
gce discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
LICENSE discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
README.md discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00
discover.go discover: move instance discover code into separate package (#3144) 2017-06-21 10:40:38 +02:00

README.md

Go Discover Nodes for Cloud Providers

go-discover is a Go (golang) library to discover ip addresses of nodes in cloud environments based on meta information like tags provided by the environment.

The following cloud providers have built-in support but additional providers can be added to the discover.Disoverers map.

  • Amazon AWS
  • Google Cloud
  • Microsoft Azure

Usage

First, install the library:

go get -u github.com/hashicorp/go-discover

All providers are configured with a "key=val key=val ..." format strings where the values are URL encoded. The discover.Discover function determines the provider through the provider key.

Example:

provider=aws region=eu-west-1 ...

Amazon AWS

l := log.New(os.Stderr, "", log.LstdFlags)
args := "provider=aws region=eu-west-1 tag_key=consul tag_value=... access_key_id=... secret_access_key=..."
nodes, err := discover.Discover(args, l)

Google Cloud

l := log.New(os.Stderr, "", log.LstdFlags)
args := "provider=gce project_name=... zone_pattern=eu-west-* tag_value=consul credentials_file=..."
nodes, err := discover.Discover(args, l)

Microsoft Azure

l := log.New(os.Stderr, "", log.LstdFlags)
args := "provider=azure tag_name=consul tag_value=... tenant_id=... client_id=... subscription_id=... secret_access_key=..."
nodes, err := discover.Discover(args, l)

For complete API documentation, see GoDoc.