MCPcopy Create free account
hub / github.com/apache/openwhisk-cli / lastFlag

Function lastFlag

commands/activation.go:268–296  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

266// Param: Brings in []strings from args
267// Return: Returns a []string with the latest ID or the original args and any errors
268func 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
298var activationPollCmd = &cobra.Command{
299 Use: "poll [ NAMESPACE | ACTION_NAME ]",

Callers 1

activation.goFile · 0.85

Calls 1

ListMethod · 0.80

Tested by

no test coverage detected