-
Notifications
You must be signed in to change notification settings - Fork 949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: add rules for type validation #2394
feature: add rules for type validation #2394
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2394 +/- ##
==========================================
+ Coverage 68.35% 68.59% +0.24%
==========================================
Files 272 272
Lines 18206 18210 +4
==========================================
+ Hits 12445 12492 +47
+ Misses 4332 4302 -30
+ Partials 1429 1416 -13
|
feels so good to see it! 😍 |
3312a22
to
6136667
Compare
6136667
to
504e13b
Compare
@rudyfly please double check these rules. |
504e13b
to
b192d7a
Compare
I think that there is no limit of |
56e8d07
to
afd8571
Compare
@@ -325,6 +325,10 @@ func (s *Server) updateContainer(ctx context.Context, rw http.ResponseWriter, re | |||
if err := json.NewDecoder(reader).Decode(config); err != nil { | |||
return httputils.NewHTTPError(err, http.StatusBadRequest) | |||
} | |||
// validate request body | |||
if err := config.Validate(strfmt.NewFormats()); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this validation should be before plugin point. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any feedback on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, the validation should be immediately before ContainerMgr.Update
to promise
valid types like a sentinel, that's enough. @allencloud
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got your point. Agree with you. @zhuangqh
apis/swagger.yml
Outdated
@@ -3172,11 +3173,13 @@ definitions: | |||
description: "The new volume's name. If not specified, Pouch generates a name." | |||
type: "string" | |||
x-nullable: false | |||
pattern: ^[a-zA-Z0-9][a-zA-Z0-9_\-.]{0,63}$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we need @rudyfly to take a review of this to validate if the restriction rules is reasonable for volume management
apis/swagger.yml
Outdated
@@ -3909,8 +3913,9 @@ definitions: | |||
type: "string" | |||
example: "127.0.0.1" | |||
HostPort: | |||
description: "Host port number that the container's port is mapped to." | |||
description: "Host port number that the container's port is mapped to. range [0,65535]" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the port 0
is valid? I am it should be (0,65535]
.
WDYT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has updated
@@ -3909,8 +3913,9 @@ definitions: | |||
type: "string" | |||
example: "127.0.0.1" | |||
HostPort: | |||
description: "Host port number that the container's port is mapped to." | |||
description: "Host port number that the container's port is mapped to. range [0,65535]" | |||
type: "string" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it is strange to use string
type to describe port, it is compatible with Moby.
Just comment to record this.
afd8571
to
b037706
Compare
Signed-off-by: zhuangqh <[email protected]>
b037706
to
3a66d8d
Compare
@allencloud after discussing with @rudyfly . I have removed all of the rules related to volume or label. |
LGTM |
Signed-off-by: zhuangqh [email protected]
Ⅰ. Describe what this PR did
Add rules to validate post request body.
Ⅱ. Does this pull request fix one issue?
fixes #443
Ⅲ. Why don't you add test cases (unit test/integration test)? (你真的觉得不需要加测试吗?)
added, but not complete. I would like to invite volunteers to complete test.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews