github.com/hernad/nomad@v1.6.112/e2e/e2eutil/client.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: MPL-2.0 3 4 package e2eutil 5 6 import ( 7 "testing" 8 9 capi "github.com/hashicorp/consul/api" 10 napi "github.com/hernad/nomad/api" 11 "github.com/hernad/nomad/helper/useragent" 12 vapi "github.com/hashicorp/vault/api" 13 "github.com/shoenig/test/must" 14 ) 15 16 // NomadClient creates a default Nomad client based on the env vars 17 // from the test environment. Fails the test if it can't be created 18 func NomadClient(t *testing.T) *napi.Client { 19 client, err := napi.NewClient(napi.DefaultConfig()) 20 must.NoError(t, err) 21 return client 22 } 23 24 // ConsulClient creates a default Consul client based on the env vars 25 // from the test environment. Fails the test if it can't be created 26 func ConsulClient(t *testing.T) *capi.Client { 27 client, err := capi.NewClient(capi.DefaultConfig()) 28 must.NoError(t, err) 29 return client 30 } 31 32 // VaultClient creates a default Vault client based on the env vars 33 // from the test environment. Fails the test if it can't be created 34 func VaultClient(t *testing.T) *vapi.Client { 35 client, err := vapi.NewClient(vapi.DefaultConfig()) 36 useragent.SetHeaders(client) 37 must.NoError(t, err) 38 return client 39 }