diff --git a/go.mod b/go.mod index 2670fd65..dbd81f77 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,7 @@ require ( require ( github.com/digitalocean/go-libvirt v0.0.0-20220804181439-8648fbde413e // indirect github.com/golang/protobuf v1.5.3 // indirect + go.einride.tech/aip v0.60.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect diff --git a/go.sum b/go.sum index d0fb1575..4b83d701 100644 --- a/go.sum +++ b/go.sum @@ -29,6 +29,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.einride.tech/aip v0.60.0 h1:h6bgabZ5BCfAptbGex8jbh3VvPBRLa6xq+pQ1CAjHYw= +go.einride.tech/aip v0.60.0/go.mod h1:SdLbSbgSU60Xkb4TMkmsZEQPHeEWx0ikBoq5QnqZvdg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= diff --git a/pkg/backend/aio.go b/pkg/backend/aio.go index 043db143..8d5269f8 100644 --- a/pkg/backend/aio.go +++ b/pkg/backend/aio.go @@ -17,6 +17,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/server" "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -32,7 +33,7 @@ func sortAioControllers(controllers []*pb.AioController) { func (s *Server) CreateAioController(_ context.Context, in *pb.CreateAioControllerRequest) (*pb.AioController, error) { log.Printf("CreateAioController: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.AioControllerId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.AioControllerId, in.AioController.Name) resourceID = in.AioControllerId diff --git a/pkg/backend/null.go b/pkg/backend/null.go index 54b9fa0b..49a3ee44 100644 --- a/pkg/backend/null.go +++ b/pkg/backend/null.go @@ -18,6 +18,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/server" "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -33,7 +34,7 @@ func sortNullDebugs(nullDebugs []*pb.NullDebug) { func (s *Server) CreateNullDebug(_ context.Context, in *pb.CreateNullDebugRequest) (*pb.NullDebug, error) { log.Printf("CreateNullDebug: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.NullDebugId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NullDebugId, in.NullDebug.Name) resourceID = in.NullDebugId diff --git a/pkg/backend/nvme.go b/pkg/backend/nvme.go index bb100cc5..78e7520f 100644 --- a/pkg/backend/nvme.go +++ b/pkg/backend/nvme.go @@ -18,6 +18,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/server" "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -33,7 +34,7 @@ func sortNVMfRemoteControllers(controllers []*pb.NVMfRemoteController) { func (s *Server) CreateNVMfRemoteController(_ context.Context, in *pb.CreateNVMfRemoteControllerRequest) (*pb.NVMfRemoteController, error) { log.Printf("CreateNVMfRemoteController: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.NvMfRemoteControllerId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NvMfRemoteControllerId, in.NvMfRemoteController.Name) resourceID = in.NvMfRemoteControllerId diff --git a/pkg/frontend/blk.go b/pkg/frontend/blk.go index 9afaa04c..abd4167b 100644 --- a/pkg/frontend/blk.go +++ b/pkg/frontend/blk.go @@ -12,12 +12,13 @@ import ( "path" "sort" - "github.com/google/uuid" "github.com/opiproject/gospdk/spdk" pc "github.com/opiproject/opi-api/common/v1/gen/go" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/server" + "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -33,7 +34,7 @@ func sortVirtioBlks(virtioBlks []*pb.VirtioBlk) { func (s *Server) CreateVirtioBlk(_ context.Context, in *pb.CreateVirtioBlkRequest) (*pb.VirtioBlk, error) { log.Printf("CreateVirtioBlk: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.VirtioBlkId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.VirtioBlkId, in.VirtioBlk.Name) resourceID = in.VirtioBlkId diff --git a/pkg/frontend/nvme.go b/pkg/frontend/nvme.go index 0535c70f..a0244394 100644 --- a/pkg/frontend/nvme.go +++ b/pkg/frontend/nvme.go @@ -18,6 +18,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/server" "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -97,7 +98,7 @@ func (c *tcpSubsystemListener) Params(_ *pb.NvmeController, nqn string) spdk.Nvm func (s *Server) CreateNvmeSubsystem(_ context.Context, in *pb.CreateNvmeSubsystemRequest) (*pb.NvmeSubsystem, error) { log.Printf("CreateNvmeSubsystem: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.NvmeSubsystemId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NvmeSubsystemId, in.NvmeSubsystem.Name) resourceID = in.NvmeSubsystemId @@ -279,7 +280,7 @@ func (s *Server) CreateNvmeController(_ context.Context, in *pb.CreateNvmeContro return nil, status.Error(codes.InvalidArgument, "invalid input subsystem parameters") } // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.NvmeControllerId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NvmeControllerId, in.NvmeController.Name) resourceID = in.NvmeControllerId @@ -423,7 +424,7 @@ func (s *Server) CreateNvmeNamespace(_ context.Context, in *pb.CreateNvmeNamespa return nil, status.Error(codes.InvalidArgument, "invalid input subsystem parameters") } // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.NvmeNamespaceId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.NvmeNamespaceId, in.NvmeNamespace.Name) resourceID = in.NvmeNamespaceId diff --git a/pkg/frontend/scsi.go b/pkg/frontend/scsi.go index ee76ffa4..e66efb3f 100644 --- a/pkg/frontend/scsi.go +++ b/pkg/frontend/scsi.go @@ -18,6 +18,7 @@ import ( "github.com/opiproject/opi-spdk-bridge/pkg/server" "github.com/google/uuid" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -33,7 +34,7 @@ func sortScsiControllers(controllers []*pb.VirtioScsiController) { func (s *Server) CreateVirtioScsiController(_ context.Context, in *pb.CreateVirtioScsiControllerRequest) (*pb.VirtioScsiController, error) { log.Printf("CreateVirtioScsiController: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.VirtioScsiControllerId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.VirtioScsiControllerId, in.VirtioScsiController.Name) resourceID = in.VirtioScsiControllerId @@ -188,7 +189,7 @@ func (s *Server) VirtioScsiControllerStats(_ context.Context, in *pb.VirtioScsiC func (s *Server) CreateVirtioScsiLun(_ context.Context, in *pb.CreateVirtioScsiLunRequest) (*pb.VirtioScsiLun, error) { log.Printf("CreateVirtioScsiLun: Received from client: %v", in) // see https://google.aip.dev/133#user-specified-ids - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.VirtioScsiLunId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.VirtioScsiLunId, in.VirtioScsiLun.Name) resourceID = in.VirtioScsiLunId diff --git a/pkg/middleend/encryption.go b/pkg/middleend/encryption.go index 81fc1472..c29f7020 100644 --- a/pkg/middleend/encryption.go +++ b/pkg/middleend/encryption.go @@ -17,6 +17,7 @@ import ( "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/server" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/emptypb" @@ -32,7 +33,7 @@ func sortEncryptedVolumes(volumes []*pb.EncryptedVolume) { func (s *Server) CreateEncryptedVolume(_ context.Context, in *pb.CreateEncryptedVolumeRequest) (*pb.EncryptedVolume, error) { log.Printf("CreateEncryptedVolume: Received from client: %v", in) - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.EncryptedVolumeId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.EncryptedVolumeId, in.EncryptedVolume.Name) resourceID = in.EncryptedVolumeId diff --git a/pkg/middleend/qos.go b/pkg/middleend/qos.go index 74459625..affcac86 100644 --- a/pkg/middleend/qos.go +++ b/pkg/middleend/qos.go @@ -14,6 +14,7 @@ import ( "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/server" + "go.einride.tech/aip/resourceid" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/proto" @@ -29,7 +30,7 @@ func sortQosVolumes(volumes []*pb.QosVolume) { // CreateQosVolume creates a QoS volume func (s *Server) CreateQosVolume(_ context.Context, in *pb.CreateQosVolumeRequest) (*pb.QosVolume, error) { log.Printf("CreateQosVolume: Received from client: %v", in) - resourceID := uuid.New().String() + resourceID := resourceid.NewSystemGenerated() if in.QosVolumeId != "" { log.Printf("client provided the ID of a resource %v, ignoring the name field %v", in.QosVolumeId, in.QosVolume.Name) resourceID = in.QosVolumeId