Skip to content

Commit

Permalink
fix: add the function RandomID
Browse files Browse the repository at this point in the history
pick back from 6063149

Signed-off-by: James Lu <james.lu@suse.com>
  • Loading branch information
mantissahz committed Mar 8, 2024
1 parent b4c67df commit 9147c56
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"syscall"
"time"

"github.com/google/uuid"
"github.com/gorilla/handlers"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"
Expand All @@ -30,6 +31,8 @@ var (

const (
BlockSizeLinux = 512

randomIDLenth = 8
)

func ParseAddresses(name string) (string, string, string, int, error) {
Expand Down Expand Up @@ -284,3 +287,11 @@ func GetAddresses(volumeName, address string, dataServerProtocol types.DataServe
return "", "", "", -1, fmt.Errorf("unsupported protocol: %v", dataServerProtocol)
}
}

func UUID() string {
return uuid.New().String()
}

func RandomID() string {
return UUID()[:randomIDLenth]
}

0 comments on commit 9147c56

Please sign in to comment.