Replace uuid dependency with internal library

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-05-22 15:55:54 -07:00
parent 25fb44fb8b
commit f8c0086e93
4 changed files with 14 additions and 14 deletions

View file

@ -12,7 +12,7 @@ import (
"testing" "testing"
"time" "time"
"code.google.com/p/go-uuid/uuid" "github.com/docker/distribution/uuid"
"github.com/docker/distribution" "github.com/docker/distribution"
"github.com/docker/distribution/context" "github.com/docker/distribution/context"
@ -141,7 +141,7 @@ func TestBlobUploadChunked(t *testing.T) {
b1[513:1024], b1[513:1024],
} }
repo := "test.example.com/uploadrepo" repo := "test.example.com/uploadrepo"
uuids := []string{uuid.New()} uuids := []string{uuid.Generate().String()}
m = append(m, testutil.RequestResponseMapping{ m = append(m, testutil.RequestResponseMapping{
Request: testutil.Request{ Request: testutil.Request{
Method: "POST", Method: "POST",
@ -159,7 +159,7 @@ func TestBlobUploadChunked(t *testing.T) {
}) })
offset := 0 offset := 0
for i, chunk := range chunks { for i, chunk := range chunks {
uuids = append(uuids, uuid.New()) uuids = append(uuids, uuid.Generate().String())
newOffset := offset + len(chunk) newOffset := offset + len(chunk)
m = append(m, testutil.RequestResponseMapping{ m = append(m, testutil.RequestResponseMapping{
Request: testutil.Request{ Request: testutil.Request{
@ -256,7 +256,7 @@ func TestBlobUploadMonolithic(t *testing.T) {
dgst, b1 := newRandomBlob(1024) dgst, b1 := newRandomBlob(1024)
var m testutil.RequestResponseMap var m testutil.RequestResponseMap
repo := "test.example.com/uploadrepo" repo := "test.example.com/uploadrepo"
uploadID := uuid.New() uploadID := uuid.Generate().String()
m = append(m, testutil.RequestResponseMapping{ m = append(m, testutil.RequestResponseMapping{
Request: testutil.Request{ Request: testutil.Request{
Method: "POST", Method: "POST",

View file

@ -4,11 +4,11 @@ import (
"net/http" "net/http"
"time" "time"
"code.google.com/p/go-uuid/uuid"
"github.com/docker/distribution" "github.com/docker/distribution"
"github.com/docker/distribution/context" "github.com/docker/distribution/context"
"github.com/docker/distribution/digest" "github.com/docker/distribution/digest"
"github.com/docker/distribution/registry/storage/driver" "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/uuid"
) )
// linkedBlobStore provides a full BlobService that namespaces the blobs to a // linkedBlobStore provides a full BlobService that namespaces the blobs to a
@ -85,7 +85,7 @@ func (lbs *linkedBlobStore) Put(ctx context.Context, mediaType string, p []byte)
func (lbs *linkedBlobStore) Create(ctx context.Context) (distribution.BlobWriter, error) { func (lbs *linkedBlobStore) Create(ctx context.Context) (distribution.BlobWriter, error) {
context.GetLogger(ctx).Debug("(*linkedBlobStore).Writer") context.GetLogger(ctx).Debug("(*linkedBlobStore).Writer")
uuid := uuid.New() uuid := uuid.Generate().String()
startedAt := time.Now().UTC() startedAt := time.Now().UTC()
path, err := lbs.blobStore.pm.path(uploadDataPathSpec{ path, err := lbs.blobStore.pm.path(uploadDataPathSpec{

View file

@ -5,10 +5,10 @@ import (
"strings" "strings"
"time" "time"
"code.google.com/p/go-uuid/uuid"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/docker/distribution/context" "github.com/docker/distribution/context"
storageDriver "github.com/docker/distribution/registry/storage/driver" storageDriver "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/uuid"
) )
// uploadData stored the location of temporary files created during a layer upload // uploadData stored the location of temporary files created during a layer upload
@ -116,8 +116,8 @@ func getOutstandingUploads(ctx context.Context, driver storageDriver.StorageDriv
func uUIDFromPath(path string) (string, bool) { func uUIDFromPath(path string) (string, bool) {
components := strings.Split(path, "/") components := strings.Split(path, "/")
for i := len(components) - 1; i >= 0; i-- { for i := len(components) - 1; i >= 0; i-- {
if uuid := uuid.Parse(components[i]); uuid != nil { if u, err := uuid.Parse(components[i]); err == nil {
return uuid.String(), i == len(components)-1 return u.String(), i == len(components)-1
} }
} }
return "", false return "", false

View file

@ -6,10 +6,10 @@ import (
"testing" "testing"
"time" "time"
"code.google.com/p/go-uuid/uuid"
"github.com/docker/distribution/context" "github.com/docker/distribution/context"
"github.com/docker/distribution/registry/storage/driver" "github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/inmemory" "github.com/docker/distribution/registry/storage/driver/inmemory"
"github.com/docker/distribution/uuid"
) )
var pm = defaultPathMapper var pm = defaultPathMapper
@ -18,7 +18,7 @@ func testUploadFS(t *testing.T, numUploads int, repoName string, startedAt time.
d := inmemory.New() d := inmemory.New()
ctx := context.Background() ctx := context.Background()
for i := 0; i < numUploads; i++ { for i := 0; i < numUploads; i++ {
addUploads(ctx, t, d, uuid.New(), repoName, startedAt) addUploads(ctx, t, d, uuid.Generate().String(), repoName, startedAt)
} }
return d, ctx return d, ctx
} }
@ -73,7 +73,7 @@ func TestPurgeAll(t *testing.T) {
fs, ctx := testUploadFS(t, uploadCount, "test-repo", oneHourAgo) fs, ctx := testUploadFS(t, uploadCount, "test-repo", oneHourAgo)
// Ensure > 1 repos are purged // Ensure > 1 repos are purged
addUploads(ctx, t, fs, uuid.New(), "test-repo2", oneHourAgo) addUploads(ctx, t, fs, uuid.Generate().String(), "test-repo2", oneHourAgo)
uploadCount++ uploadCount++
deleted, errs := PurgeUploads(ctx, fs, time.Now(), true) deleted, errs := PurgeUploads(ctx, fs, time.Now(), true)
@ -95,7 +95,7 @@ func TestPurgeSome(t *testing.T) {
newUploadCount := 4 newUploadCount := 4
for i := 0; i < newUploadCount; i++ { for i := 0; i < newUploadCount; i++ {
addUploads(ctx, t, fs, uuid.New(), "test-repo", time.Now().Add(1*time.Hour)) addUploads(ctx, t, fs, uuid.Generate().String(), "test-repo", time.Now().Add(1*time.Hour))
} }
deleted, errs := PurgeUploads(ctx, fs, time.Now(), true) deleted, errs := PurgeUploads(ctx, fs, time.Now(), true)
@ -115,7 +115,7 @@ func TestPurgeOnlyUploads(t *testing.T) {
// Create a directory tree outside _uploads and ensure // Create a directory tree outside _uploads and ensure
// these files aren't deleted. // these files aren't deleted.
dataPath, err := pm.path(uploadDataPathSpec{name: "test-repo", id: uuid.New()}) dataPath, err := pm.path(uploadDataPathSpec{name: "test-repo", id: uuid.Generate().String()})
if err != nil { if err != nil {
t.Fatalf(err.Error()) t.Fatalf(err.Error())
} }