You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2022/05/24 08:05:56 UTC

[GitHub] [openwhisk-cli] ningyougang opened a new pull request, #516: Support array result

ningyougang opened a new pull request, #516:
URL: https://github.com/apache/openwhisk-cli/pull/516

   - [x] Support array result
   
   Another brother prs:
   https://github.com/apache/openwhisk-client-go/pull/153
   https://github.com/apache/openwhisk-wskdeploy/pull/1153
   
   After merged this three prs and if openwhisk itself support `support array result`, use wsk can get the correct arrary result. e.g
   ### invoke action
   * Current is
   ![image](https://user-images.githubusercontent.com/11749867/169981017-78fddc8d-58e5-4bc1-b9f3-db3037c365be.png)
   * To-Be after the three prs merged
   ![image](https://user-images.githubusercontent.com/11749867/169981141-692d0c4c-d1c3-46c4-9cbb-f16c323404e3.png)
   ### activation get
   * Currrent is
   ![image](https://user-images.githubusercontent.com/11749867/169981271-af6ff017-ce2a-4eb2-b34a-d99728f903db.png)
   * To-Be after the three prs merged
   ![image](https://user-images.githubusercontent.com/11749867/169981427-e8608927-8729-4a7a-aaa4-649160674789.png)
   
   


-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#issuecomment-1230987397

   Closed as https://github.com/apache/openwhisk-cli/pull/517 merged


-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950954594


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Btw, i already cherry-pick this pr's commits to https://github.com/apache/openwhisk-cli/pull/517,
   Because add-array-result pr: https://github.com/apache/openwhisk/pull/5290 is merged before than this pr, so when build this pr and execute this pr's test cases, it would execute openwhisk core relative's add-array-result feature test cases. e.g. when invoke below test case
   ![image](https://user-images.githubusercontent.com/11749867/185826163-7e317072-d2f5-4ad1-a887-e4d0932e26dc.png)
   it invoke use `CLIActivationsOperations` to get result in this pr
   ![image](https://user-images.githubusercontent.com/11749867/185826242-ee8d7dc8-ca3e-4e4f-afc7-5946ae77b3a9.png)
   
   When build openwhisk pr, it would use `RestActivationsOperations` to get the result
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950949572


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   The result is nil due to it is `blocking with timeout`
   
   I tested in such case (btw, i stopped all invokers containers)
   ![image](https://user-images.githubusercontent.com/11749867/185824239-edb27481-f5c6-4b84-a5ce-430aa916352c.png)
   
   The result is nil
   ![image](https://user-images.githubusercontent.com/11749867/185824343-ff2fef7a-79ab-46de-aeaf-5b5d3f4d3cd9.png)
   
   Finally is
   ![image](https://user-images.githubusercontent.com/11749867/185824375-d0ac4bd0-bb2e-4c99-b694-58fc181b9033.png)
   
   If i added `sleep 61s` for that action and make all invokers up again, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824455-e44b3419-30aa-488a-b66c-3879f8dd7e32.png)
   
   For normally hello-array action with this pr, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824674-d916ac2c-5b61-4c3b-adf7-29372395ac47.png)
   
   
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950640992


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @dgrove-oss yes, you right.
   
   But it is better to cherry this pr's commits to https://github.com/apache/openwhisk-cli/pull/517 and close this pr
   I know it is not good due to `Fix deprecated issue(pull/517)` and this pr is target is different.
   
   And due to dependency problem, it seems we must do this,
   The reason is https://github.com/apache/openwhisk-cli/pull/517#issuecomment-1221219583



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] style95 commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
style95 commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r952048370


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Was it an empty string or nil?



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950949572


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   I tested in such case (btw, i stopped all invokers containers)
   ![image](https://user-images.githubusercontent.com/11749867/185824239-edb27481-f5c6-4b84-a5ce-430aa916352c.png)
   
   The result is nil
   ![image](https://user-images.githubusercontent.com/11749867/185824343-ff2fef7a-79ab-46de-aeaf-5b5d3f4d3cd9.png)
   
   Finally is
   ![image](https://user-images.githubusercontent.com/11749867/185824375-d0ac4bd0-bb2e-4c99-b694-58fc181b9033.png)
   
   If i added `sleep 61s` for that action and make all invokers up again, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824455-e44b3419-30aa-488a-b66c-3879f8dd7e32.png)
   
   For normally hello-array action with this pr, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824674-d916ac2c-5b61-4c3b-adf7-29372395ac47.png)
   
   
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950640992


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @dgrove-oss yes, you right, need to return "" when it is array.
   
   But it is better to cherry this pr's commits to https://github.com/apache/openwhisk-cli/pull/517 and close this pr
   I know it is not good due to `Fix deprecated issue(pull/517)` and this pr is target is different.
   
   And due to dependency problem, it seems we must do this,
   The reason is https://github.com/apache/openwhisk-cli/pull/517#issuecomment-1221219583



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang closed pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang closed pull request #516: Support array result
URL: https://github.com/apache/openwhisk-cli/pull/516


-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] style95 commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
style95 commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950934720


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @ningyougang 
   This method was used to print the invocation result.
   https://github.com/apache/openwhisk-cli/blob/92c251f5d3a873029ccd8d815409582301d1103d/commands/action.go#L238
   
   Do we need to print the array result itself for the array case?



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950954594


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Btw, i already cherry-pick this pr's commits to https://github.com/apache/openwhisk-cli/pull/517,
   Because add-array-result feature is merged before than this pr, so when build this pr and execute this pr's test cases, it would execute openwhisk core relative's add-array-result feature test cases. e.g. when invoke below test case
   ![image](https://user-images.githubusercontent.com/11749867/185826163-7e317072-d2f5-4ad1-a887-e4d0932e26dc.png)
   it would invoke use `CLIActivationsOperations` to get result
   ![image](https://user-images.githubusercontent.com/11749867/185826242-ee8d7dc8-ca3e-4e4f-afc7-5946ae77b3a9.png)
   
   When build openwhisk pr, it would use `RestActivationsOperations` to get the result
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] style95 commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
style95 commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r951259415


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   ok, it seems now I get it.
   
   Previously, it returns `var res interface{}` without any initialization, when it failed to find the `field`.
   Is this an empty string in case it could not find anything?
   Isn't it nil?



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950640992


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @dgrove-oss yes, you right, need to return "" when it is array.
   
   But it is better to cherry this pr's commits to pr `Fix deprecated issue`:  https://github.com/apache/openwhisk-cli/pull/517 and close this pr
   I know it is not good due to `Fix deprecated issue(pull/517)` and this pr is target is different.
   
   And due to dependency problem, it seems we must do this,
   The reason is https://github.com/apache/openwhisk-cli/pull/517#issuecomment-1221219583



##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @dgrove-oss yes, you right, need to return "" when it is array.
   
   But it is better to cherry-pick this pr's commits to pr `Fix deprecated issue`:  https://github.com/apache/openwhisk-cli/pull/517 and close this pr
   I know it is not good due to `Fix deprecated issue(pull/517)` and this pr is target is different.
   
   And due to dependency problem, it seems we must do this,
   The reason is https://github.com/apache/openwhisk-cli/pull/517#issuecomment-1221219583



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r952049628


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   nil



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r951965300


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Yes, it would return emtry string now if it failed to find the `field`



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] dgrove-oss commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
dgrove-oss commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r942839017


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Should we insist that `field` be "" if response is an array?  I'm not sure exactly how this function is used, but it might be error prone to just silently return the array result when the caller asked for a specific field of what they must have been expecting to be a JSON object.



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950949572


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   The result is nil due to it is `blocking with timeout`, will not print the array result
   
   I tested in such case (btw, i stopped all invokers containers)
   ![image](https://user-images.githubusercontent.com/11749867/185824239-edb27481-f5c6-4b84-a5ce-430aa916352c.png)
   
   The result is nil
   ![image](https://user-images.githubusercontent.com/11749867/185824343-ff2fef7a-79ab-46de-aeaf-5b5d3f4d3cd9.png)
   
   Finally is
   ![image](https://user-images.githubusercontent.com/11749867/185824375-d0ac4bd0-bb2e-4c99-b694-58fc181b9033.png)
   
   If i added `sleep 61s` for that action and make all invokers up again, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824455-e44b3419-30aa-488a-b66c-3879f8dd7e32.png)
   
   For normally hello-array action with this pr, the result is
   ![image](https://user-images.githubusercontent.com/11749867/185824674-d916ac2c-5b61-4c3b-adf7-29372395ac47.png)
   
   
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950954594


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   Btw, i already cherry-pick this pr's commits to https://github.com/apache/openwhisk-cli/pull/517,
   Because add-array-result feature is merged before than this pr, so when build this pr and execute this pr's test cases, it would execute openwhisk core relative's add-array-result feature test cases. e.g. when invoke below test case
   ![image](https://user-images.githubusercontent.com/11749867/185826163-7e317072-d2f5-4ad1-a887-e4d0932e26dc.png)
   it invoke use `CLIActivationsOperations` to get result in this pr
   ![image](https://user-images.githubusercontent.com/11749867/185826242-ee8d7dc8-ca3e-4e4f-afc7-5946ae77b3a9.png)
   
   When build openwhisk pr, it would use `RestActivationsOperations` to get the result
   



-- 
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: issues-unsubscribe@openwhisk.apache.org

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


[GitHub] [openwhisk-cli] ningyougang commented on a diff in pull request #516: Support array result

Posted by GitBox <gi...@apache.org>.
ningyougang commented on code in PR #516:
URL: https://github.com/apache/openwhisk-cli/pull/516#discussion_r950640992


##########
commands/util.go:
##########
@@ -604,16 +604,20 @@ func getChildValueStrings(keyValueArr whisk.KeyValueArr, key string, childKey st
 	return res
 }
 
-func getValueFromJSONResponse(field string, response map[string]interface{}) interface{} {
+func getValueFromJSONResponse(field string, response interface{}) interface{} {
 	var res interface{}
 
-	for key, value := range response {
-		if key == field {
-			res = value
-			break
+	if result, ok := response.(map[string]interface{}); ok {
+		for key, value := range result {
+			if key == field {
+				res = value
+				break
+			}
 		}
 	}
-
+	if result, ok := response.([]interface{}); ok {

Review Comment:
   @dgrove-oss yes, you right, need to return "" when it is array.



-- 
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: issues-unsubscribe@openwhisk.apache.org

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