Check if the specified action is a web-action
(client *whisk.Client, qname QualifiedName)
| 1258 | |
| 1259 | // Check if the specified action is a web-action |
| 1260 | func isWebAction(client *whisk.Client, qname QualifiedName) (*whisk.Action, error) { |
| 1261 | var err error = nil |
| 1262 | |
| 1263 | savedNs := client.Namespace |
| 1264 | client.Namespace = qname.GetNamespace() |
| 1265 | fullActionName := "/" + qname.GetNamespace() + "/" + qname.GetEntityName() |
| 1266 | |
| 1267 | action, _, err := client.Actions.Get(qname.GetEntityName(), DO_NOT_FETCH_CODE) |
| 1268 | |
| 1269 | if err != nil { |
| 1270 | whisk.Debug(whisk.DbgError, "client.Actions.Get(%s, %t) error: %s\n", fullActionName, DO_NOT_FETCH_CODE, err) |
| 1271 | whisk.Debug(whisk.DbgError, "Unable to obtain action '%s' for web action validation\n", fullActionName) |
| 1272 | errMsg := wski18n.T("Unable to get action '{{.name}}': {{.err}}", |
| 1273 | map[string]interface{}{"name": fullActionName, "err": err}) |
| 1274 | err = whisk.MakeWskErrorFromWskError(errors.New(errMsg), err, whisk.EXIT_CODE_ERR_NETWORK, whisk.DISPLAY_MSG, |
| 1275 | whisk.NO_DISPLAY_USAGE) |
| 1276 | } else { |
| 1277 | err = errors.New(wski18n.T("Action '{{.name}}' is not a web action. Issue 'wsk action update \"{{.name}}\" --web true' to convert the action to a web action.", |
| 1278 | map[string]interface{}{"name": fullActionName})) |
| 1279 | |
| 1280 | if action.WebAction() { |
| 1281 | err = nil |
| 1282 | } |
| 1283 | } |
| 1284 | |
| 1285 | client.Namespace = savedNs |
| 1286 | |
| 1287 | return action, err |
| 1288 | } |
| 1289 | |
| 1290 | func init() { |
| 1291 | actionCreateCmd.Flags().BoolVar(&Flags.action.native, "native", false, wski18n.T("treat ACTION as native action (zip file provides a compatible executable to run)")) |
no test coverage detected