Remove dep (#1346)
This commit is contained in:
1 parent
2def804bdb
commit
39d54803be
1 file changed
+14
-5
@@ -3,14 +3,23 @@ package event
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/boundary/internal/db"
|
||||
"github.com/hashicorp/vault/sdk/helper/base62"
|
||||
)
|
||||
|
||||
// This modified newId has been done to stop a circular
|
||||
// dependency with the errors package that is caused by importing
|
||||
// boundary/internal/db
|
||||
func newId(prefix string) (string, error) {
|
||||
const op = "event.newId"
|
||||
id, err := db.NewPublicId(prefix)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s: %w", op, err)
|
||||
if prefix == "" {
|
||||
return "", fmt.Errorf("%s: missing prefix: %w", op, ErrInvalidParameter)
|
||||
}
|
||||
return id, nil
|
||||
var publicId string
|
||||
var err error
|
||||
|
||||
publicId, err = base62.Random(10)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("%s: unable to generate id %v: %w", op, err, ErrIo)
|
||||
}
|
||||
return fmt.Sprintf("%s_%s", prefix, publicId), nil
|
||||
}
|
||||
Reference in new issue
Block a user