Skip to content

Commit

Permalink
Move uuid packages (#3355)
Browse files Browse the repository at this point in the history
  • Loading branch information
bufdev authored Sep 30, 2024
1 parent 5b407f2 commit 91e537b
Show file tree
Hide file tree
Showing 45 changed files with 63 additions and 62 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ require (
github.com/docker/docker v27.3.1+incompatible
github.com/go-chi/chi/v5 v5.1.0
github.com/gofrs/flock v0.12.1
github.com/gofrs/uuid/v5 v5.3.0
github.com/google/cel-go v0.21.0
github.com/google/go-cmp v0.6.0
github.com/google/go-containerregistry v0.20.2
github.com/google/uuid v1.6.0
github.com/jdx/go-netrc v1.0.0
github.com/jhump/protoreflect/v2 v2.0.0-beta.2
github.com/klauspost/compress v1.17.10
Expand Down Expand Up @@ -86,7 +86,6 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/pprof v0.0.0-20240929191954-255acd752d31 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6Wezm
github.com/gobwas/ws v1.2.1/go.mod h1:hRKAFb8wOxFROYNsT1bqfWnhX+b5MFeJM9r2ZSwg/KY=
github.com/gofrs/flock v0.12.1 h1:MTLVXXHf8ekldpJk3AKicLij9MdwOWkZ+a/jHHZby9E=
github.com/gofrs/flock v0.12.1/go.mod h1:9zxTsyu5xtJ9DK+1tFZyibEV7y3uwDxPPfbxeeHCoD0=
github.com/gofrs/uuid/v5 v5.3.0 h1:m0mUMr+oVYUdxpMLgSYCZiXe7PuVPnI94+OMeVBNedk=
github.com/gofrs/uuid/v5 v5.3.0/go.mod h1:CDOjlDMVAtN56jqyRUZh58JT31Tiw7/oQyEXZV+9bD8=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufconvert/bufconvert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"testing"

"github.com/bufbuild/buf/private/bufpkg/bufimage"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufgen/features_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/bufbuild/buf/private/bufpkg/bufconfig"
"github.com/bufbuild/buf/private/bufpkg/bufimage"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion private/buf/buflsp/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/bufbuild/protocompile/parser"
"github.com/bufbuild/protocompile/protoutil"
"github.com/bufbuild/protocompile/reporter"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.lsp.dev/protocol"
"go.opentelemetry.io/otel/attribute"
"go.uber.org/zap"
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufmigrate/migrate_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/multierr"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufmigrate/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/storage/storagemem"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/multierr"
"go.uber.org/zap"
)
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufworkspace/workspace_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
3 changes: 2 additions & 1 deletion private/buf/cmd/buf/command/dep/depgraph/depgraph.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/google/uuid"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -225,7 +226,7 @@ func moduleFullNameOrOpaqueID(module bufmodule.Module) string {
// dashlessCommitIDStringForModule returns the dashless UUID for the commit. If no commit
// is set, we return an empty string.
func dashlessCommitIDStringForModule(module bufmodule.Module) string {
if commitID := module.CommitID(); !commitID.IsNil() {
if commitID := module.CommitID(); commitID != uuid.Nil {
return uuidutil.ToDashless(commitID)
}
return ""
Expand Down
3 changes: 2 additions & 1 deletion private/buf/cmd/buf/command/lsfiles/lsfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/google/uuid"
"github.com/spf13/pflag"
)

Expand Down Expand Up @@ -265,7 +266,7 @@ func newExternalImageFileInfo(imageFileInfo bufimage.ImageFileInfo) *externalIma
module = moduleFullName.String()
}
var commit string
if commitID := imageFileInfo.CommitID(); !commitID.IsNil() {
if commitID := imageFileInfo.CommitID(); commitID != uuid.Nil {
commit = uuidutil.ToDashless(commitID)
}
return &externalImageFileInfo{
Expand Down
2 changes: 1 addition & 1 deletion private/buf/cmd/protoc-gen-buf-lint/lint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/bufbuild/buf/private/pkg/prototesting"
"github.com/bufbuild/buf/private/pkg/stringutil"
"github.com/bufbuild/protoplugin"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/pluginpb"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package bufcheckserverutil
import (
"buf.build/go/bufplugin/descriptor"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

type inputFile struct {
Expand Down
4 changes: 2 additions & 2 deletions private/bufpkg/bufconfig/buf_lock_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

const (
Expand Down Expand Up @@ -457,7 +457,7 @@ func validateV1AndV1Beta1DepsHaveCommits(bufLockFile BufLockFile) error {
switch fileVersion := bufLockFile.FileVersion(); fileVersion {
case FileVersionV1Beta1, FileVersionV1:
for _, depModuleKey := range bufLockFile.DepModuleKeys() {
if depModuleKey.CommitID().IsNil() {
if depModuleKey.CommitID() == uuid.Nil {
// This is a system error.
return syserror.Newf(
"%s lock files require commits, however we did not have a commit for module %q",
Expand Down
4 changes: 2 additions & 2 deletions private/bufpkg/bufimage/bufimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/pluginpb"
Expand All @@ -57,7 +57,7 @@ type ImageFileInfo interface {
// if the ImageFile came from a Module (as opposed to a serialized Protobuf message), and
// if the CommitID was known..
//
// May be empty, that is CommitID().IsNil() may be true. Callers should not rely on this
// May be empty, that is CommitID() == uuid.Nil may be true. Callers should not rely on this
// value being present. If ModuleFullName is nil, this will always be empty.
CommitID() uuid.UUID
// Imports returns the imports for this ImageFile.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmoduletesting"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/gofrs/uuid/v5"
"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/bufimagetesting/bufimagetesting.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
imagev1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1"
"github.com/bufbuild/buf/private/pkg/protodescriptor"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"github.com/bufbuild/buf/private/gen/data/datawkt"
imagev1 "github.com/bufbuild/buf/private/gen/proto/go/buf/alpha/image/v1"
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/gofrs/uuid/v5"
"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/testing/protocmp"
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/bufimageutil/bufimageutil_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/storage/storageos"
"github.com/bufbuild/buf/private/pkg/tracing"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"github.com/jhump/protoreflect/v2/protoprint"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

"github.com/bufbuild/buf/private/pkg/protoencoding"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"google.golang.org/protobuf/types/descriptorpb"
)

Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/image_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/pkg/protodescriptor"
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"google.golang.org/protobuf/types/descriptorpb"
)

Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/module_image_file_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ package bufimage

import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

type moduleImageFileInfo struct {
Expand Down
4 changes: 2 additions & 2 deletions private/bufpkg/bufimage/parser_accessor_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/gen/data/datawkt"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/multierr"
)

Expand Down Expand Up @@ -159,7 +159,7 @@ func (p *parserAccessorHandler) addPath(
if moduleFullName != nil {
p.pathToModuleFullName[path] = moduleFullName
}
if !commitID.IsNil() {
if commitID != uuid.Nil {
p.pathToCommitID[path] = commitID
}
return nil
Expand Down
3 changes: 2 additions & 1 deletion private/bufpkg/bufimage/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/bufbuild/protoplugin/protopluginutil"
"github.com/google/uuid"
"google.golang.org/protobuf/encoding/protowire"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoreflect"
Expand Down Expand Up @@ -302,7 +303,7 @@ func imageFilesToFileDescriptorProtos(imageFiles []ImageFile) []*descriptorpb.Fi

func imageFileToProtoImageFile(imageFile ImageFile) (*imagev1.ImageFile, error) {
var protoCommitID string
if !imageFile.CommitID().IsNil() {
if imageFile.CommitID() != uuid.Nil {
protoCommitID = uuidutil.ToDashless(imageFile.CommitID())
}
return fileDescriptorProtoToProtoImageFile(
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufimage/well_known_type_image_file_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package bufimage
import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

type wellKnownTypeImageFileInfo struct {
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufmodule/added_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

// addedModule represents a Module that was added in moduleSetBuilder.
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufmodule/bufmoduleapi/commit_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufmodule/bufmoduleapi/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/bufbuild/buf/private/bufpkg/bufapi"
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

// DigestForCommitID resolves the commit ID by calling the CommitService to get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/bufbuild/buf/private/pkg/storage"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

type universalProtoCommit struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
)

type universalProtoContent struct {
Expand Down
3 changes: 2 additions & 1 deletion private/bufpkg/bufmodule/bufmoduleapi/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down Expand Up @@ -494,7 +495,7 @@ func remoteDepToV1Beta1ProtoUploadRequestDepRef(
return nil, syserror.Newf("expected module name for remote module dependency %q", remoteDep.OpaqueID())
}
depCommitID := remoteDep.CommitID()
if depCommitID.IsNil() {
if depCommitID == uuid.Nil {
return nil, syserror.Newf("did not have a commit ID for a remote module dependency %q", remoteDep.OpaqueID())
}
return &modulev1beta1.UploadRequest_DepRef{
Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufmodule/bufmodulecache/base_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/bufbuild/buf/private/pkg/slicesext"
"github.com/bufbuild/buf/private/pkg/syserror"
"github.com/bufbuild/buf/private/pkg/uuidutil"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
2 changes: 1 addition & 1 deletion private/bufpkg/bufmodule/bufmodulecache/commit_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulestore"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

"github.com/bufbuild/buf/private/bufpkg/bufmodule"
"github.com/bufbuild/buf/private/bufpkg/bufmodule/bufmodulestore"
"github.com/gofrs/uuid/v5"
"github.com/google/uuid"
"go.uber.org/zap"
)

Expand Down
Loading

0 comments on commit 91e537b

Please sign in to comment.