Merge pull request #6685 from hashicorp/b-api-separation-20191112
remove accidental project leakage in api/ package
This commit is contained in:
commit
801466f5d9
|
@ -196,7 +196,7 @@ check: ## Lint the source code
|
|||
@if (git status | grep -q .pb.go); then echo the following proto files are out of sync; git status |grep .pb.go; exit 1; fi
|
||||
|
||||
@echo "==> Check API package is isolated from rest"
|
||||
@! go list -f '{{ join .Deps "\n" }}' ./api | grep github.com/hashicorp/nomad/ | grep -v -e /vendor/ -e /nomad/api/
|
||||
@! go list --test -f '{{ join .Deps "\n" }}' ./api | grep github.com/hashicorp/nomad/ | grep -v -e /vendor/ -e /nomad/api/ -e nomad/api.test
|
||||
|
||||
.PHONY: checkscripts
|
||||
checkscripts: ## Lint shell scripts
|
||||
|
|
|
@ -10,7 +10,6 @@ import (
|
|||
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/nomad/helper/uuid"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -150,11 +149,11 @@ func TestAllocations_RescheduleInfo(t *testing.T) {
|
|||
job.Canonicalize()
|
||||
|
||||
alloc := &Allocation{
|
||||
ID: uuid.Generate(),
|
||||
ID: generateUUID(),
|
||||
Namespace: DefaultNamespace,
|
||||
EvalID: uuid.Generate(),
|
||||
EvalID: generateUUID(),
|
||||
Name: "foo-bar[1]",
|
||||
NodeID: uuid.Generate(),
|
||||
NodeID: generateUUID(),
|
||||
TaskGroup: *job.TaskGroups[0].Name,
|
||||
JobID: *job.ID,
|
||||
Job: job,
|
||||
|
@ -266,14 +265,14 @@ func TestAllocations_ExecErrors(t *testing.T) {
|
|||
}
|
||||
job.Canonicalize()
|
||||
|
||||
allocID := uuid.Generate()
|
||||
allocID := generateUUID()
|
||||
|
||||
alloc := &Allocation{
|
||||
ID: allocID,
|
||||
Namespace: DefaultNamespace,
|
||||
EvalID: uuid.Generate(),
|
||||
EvalID: generateUUID(),
|
||||
Name: "foo-bar[1]",
|
||||
NodeID: uuid.Generate(),
|
||||
NodeID: generateUUID(),
|
||||
TaskGroup: *job.TaskGroups[0].Name,
|
||||
JobID: *job.ID,
|
||||
Job: job,
|
||||
|
|
|
@ -11,7 +11,6 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/go-uuid"
|
||||
"github.com/hashicorp/nomad/api/internal/testutil"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -318,24 +317,16 @@ func TestQueryString(t *testing.T) {
|
|||
func TestClient_NodeClient(t *testing.T) {
|
||||
http := "testdomain:4646"
|
||||
tlsNode := func(string, *QueryOptions) (*Node, *QueryMeta, error) {
|
||||
uu, err := uuid.GenerateUUID()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return &Node{
|
||||
ID: uu,
|
||||
ID: generateUUID(),
|
||||
Status: "ready",
|
||||
HTTPAddr: http,
|
||||
TLSEnabled: true,
|
||||
}, nil, nil
|
||||
}
|
||||
noTlsNode := func(string, *QueryOptions) (*Node, *QueryMeta, error) {
|
||||
uu, err := uuid.GenerateUUID()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return &Node{
|
||||
ID: uu,
|
||||
ID: generateUUID(),
|
||||
Status: "ready",
|
||||
HTTPAddr: http,
|
||||
TLSEnabled: false,
|
||||
|
|
|
@ -8,7 +8,6 @@ require (
|
|||
github.com/gorilla/websocket v1.4.1
|
||||
github.com/hashicorp/go-cleanhttp v0.5.1
|
||||
github.com/hashicorp/go-rootcerts v1.0.0
|
||||
github.com/hashicorp/go-uuid v1.0.1
|
||||
github.com/kr/pretty v0.1.0
|
||||
github.com/mitchellh/go-testing-interface v1.0.0
|
||||
github.com/stretchr/testify v1.3.0
|
||||
|
|
|
@ -10,8 +10,6 @@ github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVo
|
|||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI=
|
||||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
|
||||
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
|
||||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
crand "crypto/rand"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
|
@ -90,3 +92,18 @@ func int64ToPtr(i int64) *int64 {
|
|||
func float64ToPtr(f float64) *float64 {
|
||||
return &f
|
||||
}
|
||||
|
||||
// generateUUID generates a uuid useful for testing only
|
||||
func generateUUID() string {
|
||||
buf := make([]byte, 16)
|
||||
if _, err := crand.Read(buf); err != nil {
|
||||
panic(fmt.Errorf("failed to read random bytes: %v", err))
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%08x-%04x-%04x-%04x-%12x",
|
||||
buf[0:4],
|
||||
buf[4:6],
|
||||
buf[6:8],
|
||||
buf[8:10],
|
||||
buf[10:16])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue