Repository: distribution/distribution
Pull request #4129 (2023-10-24 22:19:00)

Make our UUID package internal
Nowadays there are much, much better UUID implementations to choose from, such as github.com/google/uuid. Prevent external users from importing our bespoke implementation so that we can change or migrate away from it internally without introducing breaking changes.


Patch:
diff --git a/context/context.go b/context/context.go
index 0a199615..c3fe90f9 100644
--- a/context/context.go
+++ b/context/context.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"sync"
 
-	"github.com/distribution/distribution/v3/uuid"
+	"github.com/distribution/distribution/v3/internal/uuid"
 )
 
 // instanceContext is a context that provides only an instance id. It is
diff --git a/context/http.go b/context/http.go
index 68f977ce..f0e5fd51 100644
--- a/context/http.go
+++ b/context/http.go
@@ -9,7 +9,7 @@ import (
 	"sync"
 	"time"
 
-	"github.com/distribution/distribution/v3/uuid"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/gorilla/mux"
 	log "github.com/sirupsen/logrus"
 )
diff --git a/context/trace.go b/context/trace.go
index 5bf16f8f..8fdb0a93 100644
--- a/context/trace.go
+++ b/context/trace.go
@@ -5,7 +5,7 @@ import (
 	"runtime"
 	"time"
 
-	"github.com/distribution/distribution/v3/uuid"
+	"github.com/distribution/distribution/v3/internal/uuid"
 )
 
 // WithTrace allocates a traced timing span in a new context. This allows a
diff --git a/uuid/uuid.go b/internal/uuid/uuid.go
similarity index 100%
rename from uuid/uuid.go
rename to internal/uuid/uuid.go
diff --git a/uuid/uuid_test.go b/internal/uuid/uuid_test.go
similarity index 100%
rename from uuid/uuid_test.go
rename to internal/uuid/uuid_test.go
diff --git a/notifications/bridge.go b/notifications/bridge.go
index 7404b021..de95907c 100644
--- a/notifications/bridge.go
+++ b/notifications/bridge.go
@@ -6,7 +6,7 @@ import (
 
 	"github.com/distribution/distribution/v3"
 	"github.com/distribution/distribution/v3/context"
-	"github.com/distribution/distribution/v3/uuid"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/reference"
 	events "github.com/docker/go-events"
 	"github.com/opencontainers/go-digest"
diff --git a/registry/registry.go b/registry/registry.go
index e01dcf39..0f0bb6f2 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -23,9 +23,9 @@ import (
 	"github.com/distribution/distribution/v3/configuration"
 	dcontext "github.com/distribution/distribution/v3/context"
 	"github.com/distribution/distribution/v3/health"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/distribution/v3/registry/handlers"
 	"github.com/distribution/distribution/v3/registry/listener"
-	"github.com/distribution/distribution/v3/uuid"
 	"github.com/distribution/distribution/v3/version"
 )
 
diff --git a/registry/storage/linkedblobstore.go b/registry/storage/linkedblobstore.go
index c8fe438c..31444f64 100644
--- a/registry/storage/linkedblobstore.go
+++ b/registry/storage/linkedblobstore.go
@@ -10,8 +10,8 @@ import (
 
 	"github.com/distribution/distribution/v3"
 	dcontext "github.com/distribution/distribution/v3/context"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/distribution/v3/registry/storage/driver"
-	"github.com/distribution/distribution/v3/uuid"
 	"github.com/distribution/reference"
 	"github.com/opencontainers/go-digest"
 )
diff --git a/registry/storage/purgeuploads.go b/registry/storage/purgeuploads.go
index 0ebd80b0..f9bb4447 100644
--- a/registry/storage/purgeuploads.go
+++ b/registry/storage/purgeuploads.go
@@ -6,8 +6,8 @@ import (
 	"strings"
 	"time"
 
+	"github.com/distribution/distribution/v3/internal/uuid"
 	storageDriver "github.com/distribution/distribution/v3/registry/storage/driver"
-	"github.com/distribution/distribution/v3/uuid"
 	"github.com/sirupsen/logrus"
 )
 


Test patch:
diff --git a/internal/client/repository_test.go b/internal/client/repository_test.go
index fee5bd17..16c14ad2 100644
--- a/internal/client/repository_test.go
+++ b/internal/client/repository_test.go
@@ -18,11 +18,11 @@ import (
 
 	"github.com/distribution/distribution/v3"
 	"github.com/distribution/distribution/v3/context"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/distribution/v3/manifest"
 	"github.com/distribution/distribution/v3/manifest/ocischema"
 	"github.com/distribution/distribution/v3/registry/api/errcode"
 	"github.com/distribution/distribution/v3/testutil"
-	"github.com/distribution/distribution/v3/uuid"
 	"github.com/distribution/reference"
 	"github.com/opencontainers/go-digest"
 	v1 "github.com/opencontainers/image-spec/specs-go/v1"
diff --git a/notifications/bridge_test.go b/notifications/bridge_test.go
index 4c3a4638..0c10ec04 100644
--- a/notifications/bridge_test.go
+++ b/notifications/bridge_test.go
@@ -4,10 +4,10 @@ import (
 	"testing"
 
 	"github.com/distribution/distribution/v3"
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/distribution/v3/manifest"
 	"github.com/distribution/distribution/v3/manifest/schema2"
 	v2 "github.com/distribution/distribution/v3/registry/api/v2"
-	"github.com/distribution/distribution/v3/uuid"
 	"github.com/distribution/reference"
 	events "github.com/docker/go-events"
 	"github.com/opencontainers/go-digest"
diff --git a/registry/storage/purgeuploads_test.go b/registry/storage/purgeuploads_test.go
index 4f66fdce..fe401cfa 100644
--- a/registry/storage/purgeuploads_test.go
+++ b/registry/storage/purgeuploads_test.go
@@ -7,9 +7,9 @@ import (
 	"testing"
 	"time"
 
+	"github.com/distribution/distribution/v3/internal/uuid"
 	"github.com/distribution/distribution/v3/registry/storage/driver"
 	"github.com/distribution/distribution/v3/registry/storage/driver/inmemory"
-	"github.com/distribution/distribution/v3/uuid"
 )
 
 func testUploadFS(t *testing.T, numUploads int, repoName string, startedAt time.Time) (driver.StorageDriver, context.Context) {