You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by ho...@apache.org on 2017/07/11 03:07:31 UTC
[incubator-openwhisk-cli] 04/04: wsk CLI should tolerate APIs that
do not yet have a mapped action (#2458)
This is an automated email from the ASF dual-hosted git repository.
houshengbo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-cli.git
commit 128718933b53de28a96f1c80707a2c746e8203d4
Author: Mark Deuser <md...@us.ibm.com>
AuthorDate: Fri Jul 7 14:40:19 2017 -0400
wsk CLI should tolerate APIs that do not yet have a mapped action (#2458)
* wsk CLI should tolerate APIs that do not yet have a mapped action
- bump API GW version so that action-less APIs can be created via cli/swagger
* Add `wsk api list --full` test for action-less apis
---
commands/api.go | 45 ++++++++++++++++++++++++++++------------
wski18n/resources/en_US.all.json | 4 ++++
2 files changed, 36 insertions(+), 13 deletions(-)
diff --git a/commands/api.go b/commands/api.go
index 11aa494..968c8b7 100644
--- a/commands/api.go
+++ b/commands/api.go
@@ -864,21 +864,34 @@ var apiCreateCmdV2 = &cobra.Command{
for op, opv := range retApi.Swagger.Paths[path] {
whisk.Debug(whisk.DbgInfo, "Path operation: %s\n", op)
var fqActionName string
- if (len(opv.XOpenWhisk.Package) > 0) {
+ if (opv.XOpenWhisk == nil) {
+ fqActionName = ""
+ } else if (len(opv.XOpenWhisk.Package) > 0) {
fqActionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
fqActionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
}
whisk.Debug(whisk.DbgInfo, "baseUrl %s Path %s Path obj %+v\n", baseUrl, path, opv)
- fmt.Fprintf(color.Output,
- wski18n.T("{{.ok}} created API {{.path}} {{.verb}} for action {{.name}}\n{{.fullpath}}\n",
- map[string]interface{}{
- "ok": color.GreenString("ok:"),
- "path": strings.TrimSuffix(retApi.Swagger.BasePath, "/") + path,
- "verb": op,
- "name": boldString(fqActionName),
- "fullpath": managedUrl,
- }))
+ if len(fqActionName) > 0 {
+ fmt.Fprintf(color.Output,
+ wski18n.T("{{.ok}} created API {{.path}} {{.verb}} for action {{.name}}\n{{.fullpath}}\n",
+ map[string]interface{}{
+ "ok": color.GreenString("ok:"),
+ "path": strings.TrimSuffix(retApi.Swagger.BasePath, "/") + path,
+ "verb": op,
+ "name": boldString(fqActionName),
+ "fullpath": managedUrl,
+ }))
+ } else {
+ fmt.Fprintf(color.Output,
+ wski18n.T("{{.ok}} created API {{.path}} {{.verb}}\n{{.fullpath}}\n",
+ map[string]interface{}{
+ "ok": color.GreenString("ok:"),
+ "path": strings.TrimSuffix(retApi.Swagger.BasePath, "/") + path,
+ "verb": op,
+ "fullpath": managedUrl,
+ }))
+ }
}
}
}
@@ -1218,7 +1231,9 @@ func printFilteredListApiV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb s
if ( len(apiVerb) == 0 || strings.ToLower(op) == strings.ToLower(apiVerb)) {
whisk.Debug(whisk.DbgInfo, "printFilteredListApiV2: operation matches: %#v\n", opv)
var actionName string
- if (len(opv.XOpenWhisk.Package) > 0) {
+ if (opv.XOpenWhisk == nil) {
+ actionName = ""
+ } else if (len(opv.XOpenWhisk.Package) > 0) {
actionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
actionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
@@ -1256,7 +1271,9 @@ func printFilteredListRowV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb s
if ( len(apiVerb) == 0 || strings.ToLower(op) == strings.ToLower(apiVerb)) {
whisk.Debug(whisk.DbgInfo, "printFilteredListRowV2: operation matches: %#v\n", opv)
var actionName string
- if (len(opv.XOpenWhisk.Package) > 0) {
+ if (opv.XOpenWhisk == nil) {
+ actionName = ""
+ } else if (len(opv.XOpenWhisk.Package) > 0) {
actionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
actionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
@@ -1287,7 +1304,9 @@ func getLargestActionNameSizeV2(retApiArray *whisk.RetApiArrayV2, apiPath string
if ( len(apiVerb) == 0 || strings.ToLower(op) == strings.ToLower(apiVerb)) {
whisk.Debug(whisk.DbgInfo, "getLargestActionNameSize: operation matches: %#v\n", opv)
var fullActionName string
- if (len(opv.XOpenWhisk.Package) > 0) {
+ if (opv.XOpenWhisk == nil) {
+ fullActionName = ""
+ } else if (len(opv.XOpenWhisk.Package) > 0) {
fullActionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
fullActionName = "/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 7d3a9bd..765f961 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -1188,6 +1188,10 @@
"translation": "{{.ok}} created API {{.path}} {{.verb}} for action {{.name}}\n{{.fullpath}}\n"
},
{
+ "id": "{{.ok}} created API {{.path}} {{.verb}}\n{{.fullpath}}\n",
+ "translation": "{{.ok}} created API {{.path}} {{.verb}}\n{{.fullpath}}\n"
+ },
+ {
"id": "Unable to parse api command arguments: {{.err}}",
"translation": "Unable to parse api command arguments: {{.err}}"
},
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.