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
(args []string)
| 266 | // Param: Brings in []strings from args |
| 267 | // Return: Returns a []string with the latest ID or the original args and any errors |
| 268 | func lastFlag(args []string) ([]string, error) { |
| 269 | if Flags.activation.last { |
| 270 | options := &whisk.ActivationListOptions{ |
| 271 | Limit: 1, |
| 272 | Skip: 0, |
| 273 | } |
| 274 | activations, _, err := Client.Activations.List(options) |
| 275 | if err != nil { // Checks Activations.List for errors when retrieving latest activation |
| 276 | whisk.Debug(whisk.DbgError, "Client.Activations.List(%#v) error during lastFlag: %s\n", options, err) |
| 277 | return args, err |
| 278 | } |
| 279 | if len(activations) == 0 { // Checks to see if there are activations available |
| 280 | whisk.Debug(whisk.DbgError, "No activations found in activation list\n") |
| 281 | errStr := wski18n.T("Activation list does not contain any activations.") |
| 282 | whiskErr := whisk.MakeWskError(errors.New(errStr), whisk.EXIT_CODE_ERR_GENERAL, whisk.DISPLAY_MSG, whisk.DISPLAY_USAGE) |
| 283 | return args, whiskErr |
| 284 | } |
| 285 | if len(args) == 0 { |
| 286 | whisk.Debug(whisk.DbgInfo, "Appending most recent activation ID(%s) into args\n", activations[0].ActivationID) |
| 287 | args = append(args, activations[0].ActivationID) |
| 288 | } else { |
| 289 | whisk.Debug(whisk.DbgInfo, "Appending most recent activation ID(%s) into args\n", activations[0].ActivationID) |
| 290 | args = append(args, activations[0].ActivationID) |
| 291 | whisk.Debug(whisk.DbgInfo, "Allocating appended ID to correct position in args\n") |
| 292 | args[0], args[len(args)-1] = args[len(args)-1], args[0] // IDs should be located at args[0], if 1 or more arguments are given ID has to be moved to args[0] |
| 293 | } |
| 294 | } |
| 295 | return args, nil |
| 296 | } |
| 297 | |
| 298 | var activationPollCmd = &cobra.Command{ |
| 299 | Use: "poll [ NAMESPACE | ACTION_NAME ]", |