houshengbo closed pull request #727: making sure apigw token check is done when apis are defined URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/727
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/parsers/manifest_parser.go b/parsers/manifest_parser.go index 87d76b3b..b8405b12 100644 --- a/parsers/manifest_parser.go +++ b/parsers/manifest_parser.go @@ -871,12 +871,6 @@ func (dm *YAMLParser) ComposeApiRecordsFromAllPackages(client *whisk.Config, man var requests []*whisk.ApiCreateRequest = make([]*whisk.ApiCreateRequest, 0) manifestPackages := make(map[string]Package) - // verify APIGW_ACCESS_TOKEN is set before composing APIs - // until this point, we dont know whether APIs are specified in manifest or not - if len(client.ApigwAccessToken) == 0 { - return nil, wskderrors.NewWhiskClientInvalidConfigError(wski18n.ID_MSG_CONFIG_MISSING_APIGW_ACCESS_TOKEN) - } - if manifest.Package.Packagename != "" { return dm.ComposeApiRecords(client, manifest.Package.Packagename, manifest.Package, manifest.Filepath) } else { @@ -926,6 +920,14 @@ func (dm *YAMLParser) ComposeApiRecordsFromAllPackages(client *whisk.Config, man func (dm *YAMLParser) ComposeApiRecords(client *whisk.Config, packageName string, pkg Package, manifestPath string) ([]*whisk.ApiCreateRequest, error) { var requests []*whisk.ApiCreateRequest = make([]*whisk.ApiCreateRequest, 0) + if pkg.Apis != nil { + // verify APIGW_ACCESS_TOKEN is set before composing APIs + // until this point, we dont know whether APIs are specified in manifest or not + if len(client.ApigwAccessToken) == 0 { + return nil, wskderrors.NewWhiskClientInvalidConfigError(wski18n.ID_MSG_CONFIG_MISSING_APIGW_ACCESS_TOKEN) + } + } + for apiName, apiDoc := range pkg.Apis { for gatewayBasePath, gatewayBasePathMap := range apiDoc { // append "/" to the gateway base path if its missing ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services