dingelish commented on a change in pull request #603:
URL: https://github.com/apache/incubator-teaclave/pull/603#discussion_r798191319



##########
File path: services/management/enclave/src/service.rs
##########
@@ -438,8 +438,8 @@ impl TeaclaveManagement for TeaclaveManagementService {
     // access control: none
     // when a task is created, following rules will be verified:
     // 1) arugments match function definition
-    // 2) input match function definition
-    // 3) output match function definition
+    // 2) input files match function definition
+    // 3) output files  match function definition

Review comment:
       please remove additional spaces

##########
File path: types/src/task_state.rs
##########
@@ -135,12 +136,29 @@ impl Task<Create> {
 
         // check input fkeys
         let inputs_spec: HashSet<&String> = function.inputs.iter().map(|f| 
&f.name).collect();
-        let req_input_fkeys: HashSet<&String> = 
req_input_owners.keys().collect();
+        let mut req_input_fkeys: HashSet<&String> = 
req_input_owners.keys().collect();
+        // If an input/output file is marked with `optional: True`, users do 
not need to
+        // register the file.
+        let option_inputs_spec: HashSet<&String> = function
+            .inputs
+            .iter()
+            .filter(|f| f.optional)
+            .map(|f| &f.name)
+            .collect();
+        req_input_fkeys.extend(&option_inputs_spec);
+
         ensure!(inputs_spec == req_input_fkeys, "input keys mismatch");
 
         // check output fkeys
         let outputs_spec: HashSet<&String> = function.outputs.iter().map(|f| 
&f.name).collect();
-        let req_output_fkeys: HashSet<&String> = 
req_output_owners.keys().collect();
+        let mut req_output_fkeys: HashSet<&String> = 
req_output_owners.keys().collect();
+        let option_outputs_spec: HashSet<&String> = function
+            .outputs
+            .iter()
+            .filter(|f| f.optional)
+            .map(|f| &f.name)

Review comment:
       checkout filter_map 
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter_map

##########
File path: types/src/task_state.rs
##########
@@ -135,12 +136,29 @@ impl Task<Create> {
 
         // check input fkeys
         let inputs_spec: HashSet<&String> = function.inputs.iter().map(|f| 
&f.name).collect();
-        let req_input_fkeys: HashSet<&String> = 
req_input_owners.keys().collect();
+        let mut req_input_fkeys: HashSet<&String> = 
req_input_owners.keys().collect();
+        // If an input/output file is marked with `optional: True`, users do 
not need to
+        // register the file.
+        let option_inputs_spec: HashSet<&String> = function
+            .inputs
+            .iter()
+            .filter(|f| f.optional)
+            .map(|f| &f.name)

Review comment:
       checkout filter_map 
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter_map




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@teaclave.apache.org
For additional commands, e-mail: notifications-h...@teaclave.apache.org

Reply via email to