You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bb...@apache.org on 2019/08/24 21:23:04 UTC
[mesos] 01/03: Refactored resource provider call validation.
This is an automated email from the ASF dual-hosted git repository.
bbannier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 98c54882f1be64932b29d73dbccf9f1b96dead49
Author: Benjamin Bannier <bb...@apache.org>
AuthorDate: Sat Aug 24 22:38:51 2019 +0200
Refactored resource provider call validation.
This patch collects validation of the presence of a resource provider ID
in a resource provider call into a single place.
Review: https://reviews.apache.org/r/71339/
---
src/resource_provider/validation.cpp | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/src/resource_provider/validation.cpp b/src/resource_provider/validation.cpp
index df55b5e..1f9324f 100644
--- a/src/resource_provider/validation.cpp
+++ b/src/resource_provider/validation.cpp
@@ -37,7 +37,20 @@ Option<Error> validate(const Call& call)
return Error("Expecting 'type' to be present");
}
- switch(call.type()) {
+ switch (call.type()) {
+ case Call::UNKNOWN:
+ case Call::SUBSCRIBE:
+ break;
+ case Call::UPDATE_STATE:
+ case Call::UPDATE_OPERATION_STATUS:
+ case Call::UPDATE_PUBLISH_RESOURCES_STATUS:
+ if (!call.has_resource_provider_id()) {
+ return Error("Expecting 'resource_provider_id' to be present");
+ }
+ break;
+ }
+
+ switch (call.type()) {
case Call::UNKNOWN: {
return None();
}
@@ -51,10 +64,6 @@ Option<Error> validate(const Call& call)
}
case Call::UPDATE_OPERATION_STATUS: {
- if (!call.has_resource_provider_id()) {
- return Error("Expecting 'resource_provider_id' to be present");
- }
-
if (!call.has_update_operation_status()) {
return Error("Expecting 'update_operation_status' to be present");
}
@@ -63,10 +72,6 @@ Option<Error> validate(const Call& call)
}
case Call::UPDATE_STATE: {
- if (!call.has_resource_provider_id()) {
- return Error("Expecting 'resource_provider_id' to be present");
- }
-
if (!call.has_update_state()) {
return Error("Expecting 'update_state' to be present");
}
@@ -75,10 +80,6 @@ Option<Error> validate(const Call& call)
}
case Call::UPDATE_PUBLISH_RESOURCES_STATUS: {
- if (!call.has_resource_provider_id()) {
- return Error("Expecting 'resource_provider_id' to be present");
- }
-
if (!call.has_update_publish_resources_status()) {
return Error(
"Expecting 'update_publish_resources_status' to be present.");