From 8a86dc61fff135ba1910e3b570953c3296398816 Mon Sep 17 00:00:00 2001 From: Cory Snider Date: Tue, 24 Oct 2023 18:11:41 -0400 Subject: [PATCH] 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. Signed-off-by: Cory Snider --- context/context.go | 2 +- context/http.go | 2 +- context/trace.go | 2 +- internal/client/repository_test.go | 2 +- {uuid => internal/uuid}/uuid.go | 0 {uuid => internal/uuid}/uuid_test.go | 0 notifications/bridge.go | 2 +- notifications/bridge_test.go | 2 +- registry/registry.go | 2 +- registry/storage/linkedblobstore.go | 2 +- registry/storage/purgeuploads.go | 2 +- registry/storage/purgeuploads_test.go | 2 +- 12 files changed, 10 insertions(+), 10 deletions(-) rename {uuid => internal/uuid}/uuid.go (100%) rename {uuid => internal/uuid}/uuid_test.go (100%) diff --git a/context/context.go b/context/context.go index 0a199615f..c3fe90f9f 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 68f977ce0..f0e5fd518 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 5bf16f8fc..8fdb0a93a 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/internal/client/repository_test.go b/internal/client/repository_test.go index fee5bd17c..16c14ad2b 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/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 7404b0216..de95907c5 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/notifications/bridge_test.go b/notifications/bridge_test.go index 4c3a4638f..0c10ec049 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/registry.go b/registry/registry.go index e01dcf399..0f0bb6f2e 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 c8fe438cc..31444f642 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 0ebd80b04..f9bb4447c 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" ) diff --git a/registry/storage/purgeuploads_test.go b/registry/storage/purgeuploads_test.go index 4f66fdcea..fe401cfa1 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) {