dubeejw commented on a change in pull request #2326: (Review) Alphabetize
URL:
https://github.com/apache/incubator-openwhisk/pull/2326#discussion_r125915647
##########
File path: tools/cli/go-whisk-cli/commands/api.go
##########
@@ -1203,79 +1219,110 @@ var apiListCmdV2 = &cobra.Command{
* Takes an API object (containing one more more single
basepath/relpath/operation triplets)
* and some filtering configuration. For each API endpoint matching the
filtering criteria, display
* each endpoint's configuration - one line per configuration property (action
name, verb, api name, api gw url)
+ * Parses and initializes values for ApiFilteredList struct
*/
-func printFilteredListApiV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb
string) {
+func genFilteredListV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb
string,sortAlg string) []whisk.ApiFilteredList{
+ var sortInfo whisk.ApiFilteredList
+ var sortInfoArr []whisk.ApiFilteredList
baseUrl := strings.TrimSuffix(resultApi.BaseUrl, "/")
apiName := resultApi.Swagger.Info.Title
basePath := resultApi.Swagger.BasePath
if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) {
for path, _ := range resultApi.Swagger.Paths {
- whisk.Debug(whisk.DbgInfo, "printFilteredListApiV2: comparing api
relpath: %s\n", path)
+ whisk.Debug(whisk.DbgInfo, "genFilteredListV2: comparing api
relpath: %s\n", path)
if ( len(apiPath) == 0 || path == apiPath) {
- whisk.Debug(whisk.DbgInfo, "printFilteredListApiV2: relpath
matches\n")
+ whisk.Debug(whisk.DbgInfo, "genFilteredListV2: relpath
matches\n")
for op, opv := range resultApi.Swagger.Paths[path] {
- whisk.Debug(whisk.DbgInfo, "printFilteredListApiV2:
comparing operation: '%s'\n", op)
+ whisk.Debug(whisk.DbgInfo, "genFilteredListV2: comparing
operation: '%s'\n", op)
if ( len(apiVerb) == 0 || strings.ToLower(op) ==
strings.ToLower(apiVerb)) {
- whisk.Debug(whisk.DbgInfo, "printFilteredListApiV2:
operation matches: %#v\n", opv)
+ whisk.Debug(whisk.DbgInfo, "genFilteredListV2:
operation matches: %#v\n", opv)
var actionName string
if (len(opv.XOpenWhisk.Package) > 0) {
actionName =
"/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
actionName =
"/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
}
- fmt.Printf("%s: %s\n", wski18n.T("Action"), actionName)
- fmt.Printf(" %s: %s\n", wski18n.T("API Name"),
apiName)
- fmt.Printf(" %s: %s\n", wski18n.T("Base path"),
basePath)
- fmt.Printf(" %s: %s\n", wski18n.T("Path"), path)
- fmt.Printf(" %s: %s\n", wski18n.T("Verb"), op)
- fmt.Printf(" %s: %s\n", wski18n.T("URL"),
baseUrl+path)
+ sortInfo = AssignListInfo(actionName, op, apiName,
basePath, path, baseUrl+path, sortAlg)
+ whisk.Debug(whisk.DbgInfo, "Appening to sortInfoArr:
%s %s\n", sortInfo.RelPath)
+ sortInfoArr = append(sortInfoArr, sortInfo)
}
}
}
}
}
+ return sortInfoArr
}
/*
* Takes an API object (containing one more more single
basepath/relpath/operation triplets)
* and some filtering configuration. For each API matching the filtering
criteria, display the API
* on a single line (action name, verb, api name, api gw url).
+ * Parses and initializes values for ApiFilteredRow struct
*
* NOTE: Large action name and api name value will be truncated by their
associated max size parameters.
*/
-func printFilteredListRowV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb
string, maxActionNameSize int, maxApiNameSize int) {
+func genFilteredRowV2(resultApi *whisk.RetApiV2, apiPath string, apiVerb
string, maxActionNameSize int, maxApiNameSize int, sortAlg string)
[]whisk.ApiFilteredRow {
+ var sortInfo whisk.ApiFilteredRow
+ var sortInfoArr []whisk.ApiFilteredRow
baseUrl := strings.TrimSuffix(resultApi.BaseUrl, "/")
apiName := resultApi.Swagger.Info.Title
+ basePath := resultApi.Swagger.BasePath
if (resultApi.Swagger != nil && resultApi.Swagger.Paths != nil) {
for path, _ := range resultApi.Swagger.Paths {
- whisk.Debug(whisk.DbgInfo, "printFilteredListRowV2: comparing api
relpath: %s\n", path)
+ whisk.Debug(whisk.DbgInfo, "genFilteredRowV2: comparing api
relpath: %s\n", path)
if ( len(apiPath) == 0 || path == apiPath) {
- whisk.Debug(whisk.DbgInfo, "printFilteredListRowV2: relpath
matches\n")
+ whisk.Debug(whisk.DbgInfo, "genFilteredRowV2: relpath
matches\n")
for op, opv := range resultApi.Swagger.Paths[path] {
- whisk.Debug(whisk.DbgInfo, "printFilteredListRowV2:
comparing operation: '%s'\n", op)
+ whisk.Debug(whisk.DbgInfo, "genFilteredRowV2: comparing
operation: '%s'\n", op)
if ( len(apiVerb) == 0 || strings.ToLower(op) ==
strings.ToLower(apiVerb)) {
- whisk.Debug(whisk.DbgInfo, "printFilteredListRowV2:
operation matches: %#v\n", opv)
+ whisk.Debug(whisk.DbgInfo, "genFilteredRowV2:
operation matches: %#v\n", opv)
var actionName string
if (len(opv.XOpenWhisk.Package) > 0) {
actionName =
"/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.Package+"/"+opv.XOpenWhisk.ActionName
} else {
actionName =
"/"+opv.XOpenWhisk.Namespace+"/"+opv.XOpenWhisk.ActionName
}
- fmt.Printf(fmtString,
- actionName[0 : min(len(actionName),
maxActionNameSize)],
- op,
- apiName[0 : min(len(apiName), maxApiNameSize)],
- baseUrl+path)
+ sortInfo = AssignRowInfo(actionName[0 :
min(len(actionName), maxActionNameSize)], op, apiName[0 : min(len(apiName),
maxApiNameSize)], basePath, path, baseUrl+path, sortAlg)
+ sortInfo.FmtString = fmtString
+ whisk.Debug(whisk.DbgInfo, "Appening to sortInfoArr:
%s %s\n", sortInfo.RelPath)
+ sortInfoArr = append(sortInfoArr, sortInfo)
}
}
}
}
}
+ return sortInfoArr
+}
+
+func AssignRowInfo(actionName string, verb string, apiName string, basePath
string, relPath string, url string, flag string ) whisk.ApiFilteredRow {
+ var sortInfo whisk.ApiFilteredRow
+
+ sortInfo.ActionName = actionName
+ sortInfo.Verb = verb
+ sortInfo.ApiName = apiName
+ sortInfo.BasePath = basePath
+ sortInfo.RelPath = relPath
+ sortInfo.Url = url
+ sortInfo.Flag = flag
+ return sortInfo
+}
+
+func AssignListInfo(actionName string, verb string, apiName string, basePath
string, relPath string, url string, flag string ) whisk.ApiFilteredList {
Review comment:
No space after `flag string`.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services