You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by pd...@apache.org on 2018/09/10 18:00:11 UTC
[incubator-openwhisk-wskdeploy] branch master updated: Bug fix.
Export shouldn't fail when ApiGW missing (#979)
This is an automated email from the ASF dual-hosted git repository.
pdesai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git
The following commit(s) were added to refs/heads/master by this push:
new a3efa2c Bug fix. Export shouldn't fail when ApiGW missing (#979)
a3efa2c is described below
commit a3efa2c9d5e99c7d38322d4bca61a4a414c6ef88
Author: Pavel Kravchenko <kp...@il.ibm.com>
AuthorDate: Mon Sep 10 21:00:06 2018 +0300
Bug fix. Export shouldn't fail when ApiGW missing (#979)
* Bug fix. Export shouldn't fail when ApiGW missing
* reverting unneeded formatting
---
cmd/export.go | 92 ++++++++++++++++++++++------------------
wski18n/i18n_ids.go | 1 +
wski18n/i18n_resources.go | 22 +++++-----
wski18n/resources/en_US.all.json | 4 ++
4 files changed, 66 insertions(+), 53 deletions(-)
diff --git a/cmd/export.go b/cmd/export.go
index a894906..886344e 100644
--- a/cmd/export.go
+++ b/cmd/export.go
@@ -30,6 +30,7 @@ import (
"github.com/apache/incubator-openwhisk-wskdeploy/runtimes"
"github.com/apache/incubator-openwhisk-wskdeploy/utils"
"github.com/apache/incubator-openwhisk-wskdeploy/wski18n"
+ "github.com/apache/incubator-openwhisk-wskdeploy/wskprint"
"github.com/spf13/cobra"
)
@@ -274,68 +275,75 @@ func exportProject(projectName string, targetManifest string) error {
}
- // List API request query parameters
- apiListReqOptions := new(whisk.ApiListRequestOptions)
- apiListReqOptions.SpaceGuid = strings.Split(client.Config.AuthToken, ":")[0]
- apiListReqOptions.AccessToken = client.Config.ApigwAccessToken
+ // API Gateway is an optional component. Export APIs only when ApigwAccessToken is configured
+ if len(client.ApigwAccessToken) == 0 {
+ warningString := wski18n.T(wski18n.ID_MSG_CONFIG_MISSING_APIGW_ACCESS_TOKEN)
+ wskprint.PrintOpenWhiskWarning(warningString)
+ } else {
- // Get list of APIs from OW
- retApiList, _, err := client.Apis.List(apiListReqOptions)
- if err != nil {
- return err
- }
+ // List API request query parameters
+ apiListReqOptions := new(whisk.ApiListRequestOptions)
+ apiListReqOptions.SpaceGuid = strings.Split(client.Config.AuthToken, ":")[0]
+ apiListReqOptions.AccessToken = client.Config.ApigwAccessToken
+
+ // Get list of APIs from OW
+ retApiList, _, err := client.Apis.List(apiListReqOptions)
+ if err != nil {
+ return err
+ }
- // iterate over the list of APIs to determine whether any of them part of the managed project
- retApiArray := (*whisk.RetApiArray)(retApiList)
- for _, api := range retApiArray.Apis {
+ // iterate over the list of APIs to determine whether any of them part of the managed project
+ retApiArray := (*whisk.RetApiArray)(retApiList)
+ for _, api := range retApiArray.Apis {
- apiName := api.ApiValue.Swagger.Info.Title
- apiBasePath := strings.TrimPrefix(api.ApiValue.Swagger.BasePath, "/")
+ apiName := api.ApiValue.Swagger.Info.Title
+ apiBasePath := strings.TrimPrefix(api.ApiValue.Swagger.BasePath, "/")
- // run over api paths looking for one pointing to an action belonging to the given project
- for path := range api.ApiValue.Swagger.Paths {
- for op, opv := range api.ApiValue.Swagger.Paths[path].MakeOperationMap() {
- if len(opv.XOpenWhisk.Package) > 0 {
- pkgName := opv.XOpenWhisk.Package
+ // run over api paths looking for one pointing to an action belonging to the given project
+ for path := range api.ApiValue.Swagger.Paths {
+ for op, opv := range api.ApiValue.Swagger.Paths[path].MakeOperationMap() {
+ if len(opv.XOpenWhisk.Package) > 0 {
+ pkgName := opv.XOpenWhisk.Package
- if pkg, ok := maniyaml.Packages[pkgName]; ok {
- if pkg.Namespace == opv.XOpenWhisk.Namespace {
+ if pkg, ok := maniyaml.Packages[pkgName]; ok {
+ if pkg.Namespace == opv.XOpenWhisk.Namespace {
- // now adding the api to the maniyaml
- if pkg.Apis == nil {
- pkg.Apis = make(map[string]map[string]map[string]map[string]parsers.APIMethodResponse)
- }
+ // now adding the api to the maniyaml
+ if pkg.Apis == nil {
+ pkg.Apis = make(map[string]map[string]map[string]map[string]parsers.APIMethodResponse)
+ }
- path = strings.TrimPrefix(path, "/")
+ path = strings.TrimPrefix(path, "/")
- apiMethodResponse := *new(parsers.APIMethodResponse)
- splitApiUrl := strings.Split(opv.XOpenWhisk.ApiUrl, ".")
- responseType := splitApiUrl[len(splitApiUrl)-1]
+ apiMethodResponse := *new(parsers.APIMethodResponse)
+ splitApiUrl := strings.Split(opv.XOpenWhisk.ApiUrl, ".")
+ responseType := splitApiUrl[len(splitApiUrl)-1]
- apiMethodResponse.Method = op
- apiMethodResponse.Response = responseType
+ apiMethodResponse.Method = op
+ apiMethodResponse.Response = responseType
- if pkgApi, ok := pkg.Apis[apiName]; ok {
- if pkgApiBasePath, ok := pkgApi[apiBasePath]; ok {
- if _, ok := pkgApiBasePath[path]; ok {
- pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
+ if pkgApi, ok := pkg.Apis[apiName]; ok {
+ if pkgApiBasePath, ok := pkgApi[apiBasePath]; ok {
+ if _, ok := pkgApiBasePath[path]; ok {
+ pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
+ } else {
+ pkg.Apis[apiName][apiBasePath][path] = map[string]parsers.APIMethodResponse{}
+ pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
+ }
} else {
+ pkg.Apis[apiName][apiBasePath] = map[string]map[string]parsers.APIMethodResponse{}
pkg.Apis[apiName][apiBasePath][path] = map[string]parsers.APIMethodResponse{}
pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
}
} else {
+ pkg.Apis[apiName] = map[string]map[string]map[string]parsers.APIMethodResponse{}
pkg.Apis[apiName][apiBasePath] = map[string]map[string]parsers.APIMethodResponse{}
pkg.Apis[apiName][apiBasePath][path] = map[string]parsers.APIMethodResponse{}
pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
}
- } else {
- pkg.Apis[apiName] = map[string]map[string]map[string]parsers.APIMethodResponse{}
- pkg.Apis[apiName][apiBasePath] = map[string]map[string]parsers.APIMethodResponse{}
- pkg.Apis[apiName][apiBasePath][path] = map[string]parsers.APIMethodResponse{}
- pkg.Apis[apiName][apiBasePath][path][opv.XOpenWhisk.ActionName] = apiMethodResponse
- }
- maniyaml.Packages[pkgName] = pkg
+ maniyaml.Packages[pkgName] = pkg
+ }
}
}
}
diff --git a/wski18n/i18n_ids.go b/wski18n/i18n_ids.go
index faaf979..041aff8 100644
--- a/wski18n/i18n_ids.go
+++ b/wski18n/i18n_ids.go
@@ -336,4 +336,5 @@ var I18N_ID_SET = [](string){
ID_WARN_PACKAGES_NOT_FOUND_X_path_X,
ID_WARN_RUNTIME_CHANGED_X_runtime_X_action_X,
ID_WARN_WHISK_PROPS_DEPRECATED,
+ ID_MSG_CONFIG_MISSING_APIGW_ACCESS_TOKEN,
}
diff --git a/wski18n/i18n_resources.go b/wski18n/i18n_resources.go
index ecc0f6a..2a1c643 100644
--- a/wski18n/i18n_resources.go
+++ b/wski18n/i18n_resources.go
@@ -92,12 +92,12 @@ func wski18nResourcesDe_deAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/de_DE.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
-var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x3c\x6b\x8f\x1b\x37\x92\xdf\xfd\x2b\x0a\xc1\x02\x4e\x80\x19\x4d\xb2\x87\x03\x0e\xc6\xf9\x80\x39\x7b\x92\x9d\x8d\xed\x31\xc6\xe3\x0d\x02\xdb\x68\x53\xdd\x25\x89\xab\x6e\xb2\x97\x64\x4b\x56\x06\xfa\xef\x87\x2a\x92\xdd\xad\x47\x3f\x24\x3b\xb8\xf5\x17\x4b\x22\x59\x2f\x16\xeb\x49\xce\x87\x27\x00\x8f\x4f\x00\x00\xbe\x93\xd9\x77\xcf\xe0\xbb\xc2\xce\x93\xd2\xe0\x4c\x7e\x49\xd0\x18\x6d\xbe\xbb\xf0\xa3\xce\x08 [...]
+var _wski18nResourcesEn_usAllJson = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x3c\x6b\x8f\x1b\x37\x92\xdf\xfd\x2b\x0a\xc1\x02\x4e\x80\x19\x4d\xb2\x87\x03\x0e\xc6\xf9\x80\x39\x7b\x92\x9d\x8d\xed\x31\xc6\xe3\x0d\x02\xdb\x68\x53\xdd\x25\x89\xab\x6e\xb2\x97\x64\x4b\x56\x06\xfa\xef\x87\x2a\x92\xdd\xad\x47\x3f\x24\x3b\xb8\xf5\x17\x4b\x22\x59\x2f\x16\xeb\x49\xce\x87\x27\x00\x8f\x4f\x00\x00\xbe\x93\xd9\x77\xcf\xe0\xbb\xc2\xce\x93\xd2\xe0\x4c\x7e\x49\xd0\x18\x6d\xbe\xbb\xf0\xa3\xce\x08 [...]
func wski18nResourcesEn_usAllJsonBytes() ([]byte, error) {
return bindataRead(
@@ -112,7 +112,7 @@ func wski18nResourcesEn_usAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 19493, mode: os.FileMode(420), modTime: time.Unix(1535665259, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/en_US.all.json", size: 19618, mode: os.FileMode(436), modTime: time.Unix(1536397293, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -132,7 +132,7 @@ func wski18nResourcesEs_esAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/es_ES.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -152,7 +152,7 @@ func wski18nResourcesFr_frAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/fr_FR.all.json", size: 101, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -172,7 +172,7 @@ func wski18nResourcesIt_itAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/it_IT.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -192,7 +192,7 @@ func wski18nResourcesJa_jaAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ja_JA.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -212,7 +212,7 @@ func wski18nResourcesKo_krAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/ko_KR.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -232,7 +232,7 @@ func wski18nResourcesPt_brAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/pt_BR.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -252,7 +252,7 @@ func wski18nResourcesZh_hansAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hans.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@@ -272,7 +272,7 @@ func wski18nResourcesZh_hantAllJson() (*asset, error) {
return nil, err
}
- info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(420), modTime: time.Unix(1520374115, 0)}
+ info := bindataFileInfo{name: "wski18n/resources/zh_Hant.all.json", size: 0, mode: os.FileMode(436), modTime: time.Unix(1536397114, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
diff --git a/wski18n/resources/en_US.all.json b/wski18n/resources/en_US.all.json
index 35978ee..9545ea2 100644
--- a/wski18n/resources/en_US.all.json
+++ b/wski18n/resources/en_US.all.json
@@ -503,5 +503,9 @@
{
"id": "msg_dbg_packages_found_project",
"translation": "Deployment file [{{.path}}]: Found packages under project [{{.name}}].\n"
+ },
+ {
+ "id": "msg_config_missing_apigw_access_token",
+ "translation": "The apigw access token is not configured.\n"
}
]