You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/07/25 08:12:46 UTC
[servicecomb-kie] branch master updated: [fix]allow key max length=2048 (#247)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-kie.git
The following commit(s) were added to refs/heads/master by this push:
new 6853e4b [fix]allow key max length=2048 (#247)
6853e4b is described below
commit 6853e4b3512ad5453652777080ba7f9e947e3adf
Author: little-cui <su...@qq.com>
AuthorDate: Mon Jul 25 16:12:41 2022 +0800
[fix]allow key max length=2048 (#247)
---
pkg/model/db_schema.go | 2 +-
pkg/validator/rule_test.go | 11 ++++-------
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/pkg/model/db_schema.go b/pkg/model/db_schema.go
index 0434dcd..3298634 100644
--- a/pkg/model/db_schema.go
+++ b/pkg/model/db_schema.go
@@ -33,7 +33,7 @@ type LabelDoc struct {
type KVDoc struct {
ID string `json:"id,omitempty" bson:"id,omitempty" yaml:"id,omitempty" swag:"string"`
LabelFormat string `json:"label_format,omitempty" bson:"label_format,omitempty" yaml:"label_format,omitempty"`
- Key string `json:"key" yaml:"key" validate:"min=1,max=128,key"`
+ Key string `json:"key" yaml:"key" validate:"min=1,max=2048,key"`
Value string `json:"value" yaml:"value" validate:"max=131072,value"` //128K
ValueType string `json:"value_type,omitempty" bson:"value_type,omitempty" yaml:"value_type,omitempty" validate:"valueType"` //ini,json,text,yaml,properties,xml
Checker string `json:"check,omitempty" yaml:"check,omitempty" validate:"max=1048576,check"` //python script
diff --git a/pkg/validator/rule_test.go b/pkg/validator/rule_test.go
index 9a98da3..adfd040 100644
--- a/pkg/validator/rule_test.go
+++ b/pkg/validator/rule_test.go
@@ -17,12 +17,9 @@ func init() {
}
}
-var string32 = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" //32
-var string128 = string32 + string32 + string32 + string32
-var string1024 = string128 + string128 + string128 + string128 + string128 + string128 + string128 + string128
-var string8192 = string1024 + string1024 + string1024 + string1024 + string1024 + string1024 + string1024 + string1024
-var string65536 = string8192 + string8192 + string8192 + string8192 + string8192 + string8192 + string8192 + string8192
-var string131072 = string65536 + string65536
+var string32 = strings.Repeat("a", 32)
+var string2048 = strings.Repeat("a", 2048)
+var string131072 = strings.Repeat("a", 131072)
func TestValidate(t *testing.T) {
kvDoc := &model.KVDoc{Project: "a", Domain: "a",
@@ -64,7 +61,7 @@ func TestKey(t *testing.T) {
assert.Error(t, validator.Validate(kvDoc))
kvDoc = &model.KVDoc{Project: "a", Domain: "a",
- Key: string128 + "a",
+ Key: string2048 + "a",
Value: "a",
}
assert.Error(t, validator.Validate(kvDoc))