diff --git a/agent/retry_join.go b/agent/retry_join.go index 8a5c418a3..c5a1c41bc 100644 --- a/agent/retry_join.go +++ b/agent/retry_join.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "github.com/hashicorp/consul/lib" discover "github.com/hashicorp/go-discover" ) @@ -67,7 +68,11 @@ func (r *retryJoiner) retryJoin() error { return nil } - disco := discover.Discover{} + disco, err := discover.New(discover.WithUserAgent(lib.UserAgent())) + if err != nil { + return err + } + r.logger.Printf("[INFO] agent: Retry join %s is supported for: %s", r.cluster, strings.Join(disco.Names(), " ")) r.logger.Printf("[INFO] agent: Joining %s cluster...", r.cluster) attempt := 0 diff --git a/agent/retry_join_test.go b/agent/retry_join_test.go index 5badbb879..d30bf686d 100644 --- a/agent/retry_join_test.go +++ b/agent/retry_join_test.go @@ -8,7 +8,10 @@ import ( ) func TestGoDiscoverRegistration(t *testing.T) { - d := discover.Discover{} + d, err := discover.New() + if err != nil { + t.Fatal(err) + } got := d.Names() want := []string{"aliyun", "aws", "azure", "digitalocean", "gce", "os", "scaleway", "softlayer", "triton"} if !reflect.DeepEqual(got, want) { diff --git a/lib/useragent.go b/lib/useragent.go new file mode 100644 index 000000000..84e76d4df --- /dev/null +++ b/lib/useragent.go @@ -0,0 +1,29 @@ +package lib + +import ( + "fmt" + "runtime" + + "github.com/hashicorp/consul/version" +) + +var ( + // projectURL is the project URL. + projectURL = "https://www.consul.io/" + + // rt is the runtime - variable for tests. + rt = runtime.Version() + + // versionFunc is the func that returns the current version. This is a + // function to take into account the different build processes and distinguish + // between enterprise and oss builds. + versionFunc = func() string { + return version.GetHumanVersion() + } +) + +// UserAgent returns the consistent user-agent string for Consul. +func UserAgent() string { + return fmt.Sprintf("Consul/%s (+%s; %s)", + versionFunc(), projectURL, rt) +} diff --git a/lib/useragent_test.go b/lib/useragent_test.go new file mode 100644 index 000000000..3ebaa9ecb --- /dev/null +++ b/lib/useragent_test.go @@ -0,0 +1,18 @@ +package lib + +import ( + "testing" +) + +func TestUserAgent(t *testing.T) { + projectURL = "https://consul-test.com" + rt = "go5.0" + versionFunc = func() string { return "1.2.3" } + + act := UserAgent() + + exp := "Consul/1.2.3 (+https://consul-test.com; go5.0)" + if exp != act { + t.Errorf("expected %q to be %q", act, exp) + } +} diff --git a/vendor/github.com/aws/aws-sdk-go/NOTICE.txt b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt index 5f14d1162..899129ecc 100644 --- a/vendor/github.com/aws/aws-sdk-go/NOTICE.txt +++ b/vendor/github.com/aws/aws-sdk-go/NOTICE.txt @@ -1,3 +1,3 @@ AWS SDK for Go -Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. +Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. Copyright 2014-2015 Stripe, Inc. diff --git a/vendor/github.com/digitalocean/godo/LICENSE.txt b/vendor/github.com/digitalocean/godo/LICENSE.txt index 43c5d2eee..47f978eac 100644 --- a/vendor/github.com/digitalocean/godo/LICENSE.txt +++ b/vendor/github.com/digitalocean/godo/LICENSE.txt @@ -52,4 +52,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/github.com/gophercloud/gophercloud/LICENSE b/vendor/github.com/gophercloud/gophercloud/LICENSE index fbbbc9e4c..5e86b007c 100644 --- a/vendor/github.com/gophercloud/gophercloud/LICENSE +++ b/vendor/github.com/gophercloud/gophercloud/LICENSE @@ -9,10 +9,8 @@ License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the -specific language governing permissions and limitations under the License. +specific language governing permissions and limitations under the License. ------- - Apache License Version 2.0, January 2004 http://www.apache.org/licenses/