Skip to content

Commit

Permalink
Added uuid parameter type
Browse files Browse the repository at this point in the history
Signed-off-by: Tong Li <[email protected]>
  • Loading branch information
Tong Li committed Jan 30, 2020
1 parent 0b6e423 commit 650150d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
9 changes: 9 additions & 0 deletions modules/gosdk/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion modules/gosdk/Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
required = ["github.com/google/uuid"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
Expand Down Expand Up @@ -40,6 +40,10 @@
name = "github.com/hyperledger/fabric"
version = "1.4.0"

[[constraint]]
name = "github.com/google/uuid"
version = "1.1.1"

[[constraint]]
name = "github.com/xixuejia/viper"
branch = "master"
Expand Down
22 changes: 22 additions & 0 deletions modules/gosdk/utilities/paramGenerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/pkg/errors"
"github.com/google/uuid"
"hfrd/modules/gosdk/common"
"math/rand"
"strconv"
Expand All @@ -13,6 +14,7 @@ import (

const (
LITERAL_PARAM = "literal"
UUID_PARAM = "uuid"
STRING_PATTERN = "stringPattern"
INTEGER_RANGE = "intRange"
PAYLOAD_RANGE = "payloadRange"
Expand Down Expand Up @@ -43,6 +45,14 @@ type PayloadRange struct {
Max string
}

type UUID struct {
}

func (p *UUID) GetValue() string {
id, _ := uuid.NewRandom()
return strings.Replace(id.String(), "-", "", -1)
}

func (p *Literal) GetValue() string {
return p.Value
}
Expand Down Expand Up @@ -126,6 +136,12 @@ func GetComplexArgs(complexParams []string, loopIndex int) ([]string, error) {
}
literal := &Literal{paramKV[1]}
arg = literal.GetValue()
case UUID_PARAM:
if len(paramKV) != 1 {
return nil, errors.Errorf("uuid type should contains 1 param")
}
uuidgt := &UUID{}
arg = uuidgt.GetValue()
case STRING_PATTERN:
if len(paramKV) != 2 {
return nil, errors.Errorf("stringPattern type should contains 2 params")
Expand Down Expand Up @@ -189,6 +205,12 @@ func GetTransientMap(complexParams []string, loopIndex int) ([]byte, error) {
}
literal := &Literal{paramKV[2]}
arg = literal.GetValue()
case UUID_PARAM:
if len(paramKV) != 1 {
return nil, errors.Errorf("uuid type should contains 1 param")
}
uuidgt := &UUID{}
arg = uuidgt.GetValue()
case STRING_PATTERN:
if len(paramKV) != 3 {
return nil, errors.Errorf("stringPattern type should contains 2 params")
Expand Down

0 comments on commit 650150d

Please sign in to comment.