You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/07/31 17:56:22 UTC

[GitHub] houshengbo closed pull request #96: Update the doc of client go to make it clear for 0.9.0

houshengbo closed pull request #96: Update the doc of client go to make it clear for 0.9.0
URL: https://github.com/apache/incubator-openwhisk-client-go/pull/96
 
 
   

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/README.md b/README.md
index d4ca0d21..c36fb91d 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,49 @@
 This project `openwhisk-client-go` is a Go client library to access Openwhisk API.
 
 
+### Prerequisites
+
+You need to install the following package in order to run this Go client library:
+- [Go](https://golang.org/doc/install)
+
+Make sure you select the package that fits your local environment, and [set the GOPATH environment variable](https://github.com/golang/go/wiki/SettingGOPATH).
+
+
+### Installation
+
+After you download the source code either from the Github or the release page of OpenWhisk, you should have a directory named
+_incubator-openwhisk-client-go_ to host all the source code. Please copy this root directory _incubator-openwhisk-client-go_
+into the directory $GOPATH/src/github.com/apache.
+
+
+### Test
+
+Open a terminal, and run the following commands to run the unit tests:
+
+```
+$ cd $GOPATH/src/github.com/apache/incubator-openwhisk-client-go
+$ go test -v ./... -tags=unit
+```
+
+You should see all the unit tests passed. If not, please [log an issue](https://github.com/apache/incubator-openwhisk-client-go/issues) for us.
+
+
+### Configuration
+
+This Go client library is used to access the OpenWhisk API, so please make sure you have an OpenWhisk service running somewhere
+available for you to run this library.
+
+We use a configuration file called _wskprop_ to specify all the parameters necessary for this Go client library to access the OpenWhisk
+services. Make sure you create or edit the file _~/.wskprops_, and add the mandatory parameters APIHOST, APIVERSION, NAMESPACE and AUTH.
+
+The parameter APIHOST is the OpenWhisk API hostname (for example, openwhisk.ng.bluemix.net, 172.17.0.1, and so on).
+The parameter APIVERSION is the version of OpenWhisk API to be used to access the OpenWhisk resources.
+The parameter NAMESPACE is the OpenWhisk namespace used to specify the OpenWhisk resources about to be accessed.
+The parameter AUTH is the authentication key used to authenticate the incoming requests to the OpenWhisk services.
+
+For more information regarding the REST API of OpenWhisk, please refer to [OpenWhisk REST API](https://github.com/apache/incubator-openwhisk/blob/master/docs/rest_api.md).
+
+
 ### Usage
 
 ```go
@@ -49,20 +92,29 @@ options := &whisk.ActionListOptions{
 actions, resp, err := client.Actions.List(options)
 ```
 
-Whisk can be configured by passing in a `*whisk.Config` object as the second argument to `whisk.New( ... )`.  For example:
+By default, this Go client library is automatically configured by the configuration file _wskprop_. The parameters of APIHOST, APIVERSION,
+NAMESPACE and AUTH will be used to access the OpenWhisk services.
+
+In addition, it can also be configured by passing in a `*whisk.Config` object as the second argument to `whisk.New( ... )`.  For example:
 
 ```go
-u, _ := url.Parse("https://whisk.stage1.ng.bluemix.net:443/api/v1/")
 config := &whisk.Config{
+  Host: "openwhisk.ng.bluemix.net",
+  Version: "v1"
   Namespace: "_",
-  AuthKey: "aaaaa-bbbbb-ccccc-ddddd-eeeee",
-  BaseURL: u
+  AuthKey: "aaaaa-bbbbb-ccccc-ddddd-eeeee"
 }
 client, err := whisk.Newclient(http.DefaultClient, config)
 ```
 
 
 ### Example
+
+You need to have an OpenWhisk service accessible, to run the following example.
+
+Please be advised that all the Go files you are about to create should be under the directory of $GOPATH or its subdirectories.
+For example, create the Go file named _openwhisk_client_go.go_ under a directory called $GOPATH/src/example to try the following code.
+
 ```go
 import (
   "net/http"
@@ -95,5 +147,21 @@ func main() {
 }
 ```
 
+Then build it with the go tool:
+
+```
+$ cd $GOPATH/src/example
+$ go build
+```
+
+The command above will build an executable named client in the directory alongside your source code. Execute it to see the the result:
+
+
+$ ./openwhisk_client_go
+
+If the openWhisk service is available and your configuration is correct, you should receive the status and the actions with
+the above example.
+
+
 # Disclaimer
 Apache OpenWhisk Client Go is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
diff --git a/whisk/action_test.go b/whisk/action_test.go
index 57f7e664..abd08fec 100644
--- a/whisk/action_test.go
+++ b/whisk/action_test.go
@@ -1,4 +1,4 @@
-//// +build unit
+// +build unit
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services