dubeejw commented on a change in pull request #2334: Added --last Activation
Flag
URL:
https://github.com/apache/incubator-openwhisk/pull/2334#discussion_r121762344
##########
File path: tools/cli/go-whisk-cli/commands/activation.go
##########
@@ -224,6 +248,35 @@ var activationResultCmd = &cobra.Command{
return nil
},
}
+//lastFlag(args) retrieves the last activation with flag -l or --last
+//Param: Brings in []strings from args
+//Return: Returns a []string with the latest ID or the original args and any
errors
+func lastFlag(args []string) ([]string, error) {
+ //Checks to see if there is an ID sent with the --last
+ //If an ID is given with --last then an error will be thrown
+ if flags.activation.last && len(args) == 0 {
+ options := &whisk.ActivationListOptions {
+ Limit: 1,
+ Skip: 0,
+ }
+ activations, _, err := client.Activations.List(options)
+ if err != nil { //Checks Activations.List for errors when retrieving
latest activaiton
+ whisk.Debug(whisk.DbgError, "client.Activations.List() error for flag
--last: %s\n", err)
+ return args, err
+ }
+ if len(activations) == 0 { //Checks to to see if there are activations
+ whiskErr := whisk.MakeWskError(errors.New("Activation list is empty"),
whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
+ return args, whiskErr
+ } else {
+ whisk.Debug(whisk.DbgInfo, "Appending most recent activation ID into
args\n")
+ args = append(args, activations[0].ActivationID)
+ }
+ } else if flags.activation.last && len(args) == 1 { //Checks conflict
between ID and --last
+ whiskErr := whisk.MakeWskError(errors.New("Can't use given ID with
--last"), whisk.EXITCODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE)
Review comment:
Currently we can pass an activation ID and a field filter to the activation
get command. However, your change breaks the field filter functionality.
Field filtering with activation get:
```
$ wsk activation get fa613f7e33dd45959b8a93943ea5c3e7 publish
ok: got activation fa613f7e33dd45959b8a93943ea5c3e7, displaying field publish
false
```
Attempting to field filter with your changes:
```
$ wsk activation get --last publish
error: Unable to get result for activation: Can't use given ID with --last
Run 'wsk --help' for usage.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services