GithubHelp home page GithubHelp logo

apache / openwhisk-client-go Goto Github PK

View Code? Open in Web Editor NEW
35.0 41.0 44.0 367 KB

Go client library for the Apache OpenWhisk platform

Home Page: https://openwhisk.apache.org/

License: Apache License 2.0

Go 97.57% Makefile 0.56% Shell 1.87%
openwhisk apache serverless faas functions-as-a-service cloud serverless-architectures serverless-functions

openwhisk-client-go's Introduction

Openwhisk Client Go

License Build Status

This project openwhisk-client-go is a Go client library to access the Openwhisk API.


Building the project

Prerequisites

The Openwhisk Go Client library requires you to Download and install GoLang onto your local machine.

Note Go version 1.15 or higher is recommended

Make sure you select the package that fits your local environment, and set the GOPATH environment variable.

Download the source code from GitHub

As the code is managed using GitHub, it is easiest to retrieve the code using the git clone command.

If you just want to build the code and do not intend to be a Contributor, you can clone the latest code from the Apache repository:

git clone [email protected]:apache/openwhisk-client-go

You can also specify a release (tag), if you do not want the latest code, by using the --branch <tag> flag. For example, you can clone the source code for the tagged 1.1.0 release

git clone --branch 1.1.0 [email protected]:apache/openwhisk-client-go

You can also pull the code from a fork of the repository. If you intend to become a Contributor to the project, read the section Contributing to the project below on how to setup a fork.

Building using go build

Change into the cloned project directory and use the following command to build all packages:

$ go build -v ./...

or simply build just the whisk commands:

$ go build -v ./whisk

Note: There is no main function in this project as the ./whisk packages are treated together as a client library.

Testing using go test

Open a terminal, change into the project directory and use the following command to run the unit tests:

$ go test -v ./... -tags=unit

You should see all the unit tests passed; if not, please log an issue 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.

    • If you are using a local quick start standalone, OpenWhisk services APIHOST will look like http://localhost:3233
    • If you are using IBM cloud functions as your provider, APIHOST will look like <region>.functions.cloud.ibm.com where region can be us-east, us-south or any additional regions
  • 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.

Usage

import "github.com/apache/openwhisk-client-go/whisk"

Construct a new whisk client, then use various services to access different parts of the whisk api. For example to get the hello package actions:

client, _ := whisk.NewClient(http.DefaultClient, nil)
actions, resp, err := client.Actions.List("hello", nil)

Some API methods have optional parameters that can be passed. For example, to list the first 10 actions of the hello package:

client, _ := whisk.NewClient(http.DefaultClient, nil)

options := &whisk.ActionListOptions{
  Limit: 10,
  Skip: 0,
}

actions, resp, err := client.Actions.List("hello", options)

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:

config := &whisk.Config{
  Host: "<APIHOST>",
  Version: "<APIVERSION>",
  Namespace: "<NAMESPACE>",
  AuthToken: "<AUTH>",
}
client, err := whisk.Newclient(http.DefaultClient, config)

Example

You need to have an OpenWhisk service accessible, to run the following example.

package main

import (
  "os"
  "fmt"
  "net/http"

  "github.com/apache/openwhisk-client-go/whisk"
)

func main() {
  client, err := whisk.NewClient(http.DefaultClient, nil)
  if err != nil {
    fmt.Println(err)
    os.Exit(-1)
  }

  options := &whisk.ActionListOptions{
    Limit: 10,
    Skip: 0,
  }

  actions, resp, err := client.Actions.List("", options)
  if err != nil {
    fmt.Println(err)
    os.Exit(-1)
  }

  fmt.Println("Returned with status: ", resp.Status)
  fmt.Printf("Returned actions: \n%+v", actions)

}

Then run it with the go tool:

$ cd example
$ go run example_list_actions.go

If the openWhisk service is available and your configuration is correct, you should receive the status and the actions with the above example.


Contributing to the project

Git repository setup

  1. Fork the Apache repository

    If you intend to contribute code, you will want to fork the apache/openwhisk-client-go repository into your github account and use that as the source for your clone.

  2. Clone the repository from your fork:

    git clone [email protected]:${GITHUB_ACCOUNT_USERNAME}/openwhisk-client-go.git
  3. Add the Apache repository as a remote with the upstream alias:

    git remote add upstream [email protected]:apache/openwhisk-client-go

    You can now use git push to push local commit changes to your origin repository and submit pull requests to the upstream project repository.

  4. Optionally, prevent accidental pushes to upstream using this command:

    git remote set-url --push upstream no_push

Be sure to Sync your fork before starting any contributions to keep it up-to-date with the upstream repository.

Adding new dependencies

Please use go get to add new dependencies to the go.mod file:

go get -u github.com/project/[email protected]

Please avoid using commit hashes for referencing non-OpenWhisk libraries.

Updating dependency versions

Although you might be tempted to edit the go.mod file directly, please use the recommended method of using the go get command:

go get -u github.com/project/libname  # Using "latest" version
go get -u github.com/project/[email protected] # Using tagged version
go get -u github.com/project/libname@aee5cab1c  # Using a commit hash

Updating Go version

Although you could edit the version directly in the go.mod file, it is better to use the go edit command:

go mod edit -go=1.15

openwhisk-client-go's People

Contributors

aprlirainkun avatar bbrowning avatar bpoole16 avatar cbickel avatar ddebarros avatar dgrove-oss avatar dubee avatar giusdp avatar jbampton avatar jessealva avatar jiangpengcheng avatar jonfriesen avatar larandersson avatar lionelvillard avatar masnnuller avatar matthiaskubik avatar mdeuser avatar mrutkows avatar ningyougang avatar pritidesai avatar rabbah avatar sciabarracom avatar shubhamgupta9582 avatar skbihari avatar tysonnorris avatar underwoodb-sd-ibm avatar upgle avatar vvraskin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openwhisk-client-go's Issues

Make test command fails in Travis build

The make test command fails in Travis. See output below:

$ make test

Installing dependencies

go get -d -t ./...

package gopkg.in/yaml.v2: unrecognized import path "gopkg.in/yaml.v2" (https fetch: Get https://gopkg.in/yaml.v2?go-get=1: dial tcp 45.33.37.13:443: i/o timeout)

make: *** [deps] Error 1



The command "make test" exited with 2.

Add the integration tests in Go

Travis CI is now running the scala integration tests in openwhisk cli for this repo. We need to write the integration tests in Go by implementing the REST API of openwhisk for all the listed openwhisk api functions.

Example is broken: whisk.NewClient(http.DefaultClient, nil)

From the README example:

client, _ := whisk.NewClient(http.DefaultClient, nil)
action, resp, err := client.Actions.List("hello")

But this breaks, since inside the NewClient() code it calls if config.Insecure {..} on a nil config, which panics with panic: runtime error: invalid memory address or nil pointer dereference

command `wsk action invoke` fails in some case

when create action using below code:

#demo.js
function main(params) {
  return { response: params };
}

and then use wsk action invoke demo --result, the command will return an error:

error: Unable to invoke action 'demo': The connection failed, or timed out. (HTTP status code 200)
Run 'wsk --help' for usage.

the reason is described below:

when wsk get the http result:

[]byte(`{"response": {}}`)

it will check whether the result succeed or failed in line 381 of incubator-openwhisk-client-go/whisk/client.go

    if (IsHttpRespSuccess(resp) &&                                      // HTTP Status == 200
        data!=nil &&                                                    // HTTP response body exists
        v != nil &&
        !strings.Contains(reflect.TypeOf(v).String(), "Activation") &&  // Request is not `wsk activation get`
        !IsResponseResultSuccess(data)) {                               // HTTP response body has Whisk error result
        Debug(DbgInfo, "Got successful HTTP; but activation response reports an error\n")
        return parseErrorResponse(resp, data, v)
    }

in isResponseResultSuccess, it will try to decode data to a golang struct:

func IsResponseResultSuccess(data []byte) bool {
    errResp := new(WhiskErrorResponse)
    err := json.Unmarshal(data, &errResp)
    if (err == nil && errResp.Response != nil) {
        Debug(DbgWarn, "data is %s", data)
        return errResp.Response.Success
    }
    Debug(DbgWarn, "data is %s", data)
    Debug(DbgWarn, "IsResponseResultSuccess: failed to parse response result: %v\n", err)
    return true;
}

# struct
type WhiskResponse struct {
        Result  *WhiskResult `json:"result"`
        Success bool         `json:"success"`
        Status  *interface{} `json:"status"`
}

type WhiskResult struct {
}

type WhiskErrorResponse struct {
        Response *WhiskResponse `json:"response"`
}

while the demo action's result including the response key and its corresponding value is a dict, so it will be decoded without error with err.Resp.Response != nil, but this dict doesn't has a key named 'success', so the value of errResp.Response.Success will be false, it lead to the whole command failed.

Support API Host and authkey external configuration

When running go unit/integration tests - In addition to obtaining configuration from $OPENWHISK_HOME/whisk.properties or from $HOME/.wskprops, allow the apihost and authkey values to be separately specified such that the previously mentioned configuration files are not needed.

Allow the for the possibility of running tests against an external openwhisk instance that's already up and running outside of the current system.

Related issues: #43, #47, #23

Unable to create request URL, because OpenWhisk API host is missing

When I build against version of ad5aa34 and run on IBM Cloud, this code is getting an error:

Unable to create request URL, because OpenWhisk API host is missing"

even though __OW_API_HOST and __OW_API_KEY are set to correct values in the environment (which is expected since it's running on IBM Cloud)

This same code was working fine against an older commit (b3d194d), so I think something changed in this library.

What updates do I need to make in my code to make this work?

Currently my code is directly loading the environment variables and passing that to the whisk.NewClient() call. Is that still the right way to do things? I believe I did that as a workaround to #23

Platform Agnostic - determine home dir location

@jthomas discovered wskdeploy was looking for .wskprops file under current directory instead of user's home for 386 version of OS (apache/openwhisk-wskdeploy#1014).

@mrutkows applied a quick fix to unblock @jthomas so that he can continue working on his presentation (apache/openwhisk-wskdeploy#1015).

But in long term, we would like to fix this in right way which is adding it in Go client so that the same functionality can be used by the CLI and also by Whisk Deploy.

We are looking at changing GetPropsFromWskprops located at https://github.com/apache/incubator-openwhisk-client-go/blob/master/whisk/wskprops.go#L162

Add functionality of reading .wskprops path using homedir.Expand() like it done in CLI at https://github.com/apache/incubator-openwhisk-cli/blob/461f94fafe405feb3c664a43f6c117bac4d3c27f/commands/property.go#L402.

After the go client is changed, we need to update Whisk Deploy and CLI to use this functionality from here.

invalid warning generated by http client

https://github.com/apache/incubator-openwhisk-client-go/blob/df32dca4aecca4ec30add11ce89eac72928f95f4/whisk/client.go#L652-L659

will always emit a warning - @dubee is the intention to emit this warning only if err != nill?

diff --git a/whisk/client.go b/whisk/client.go
index 58a29b7..938d812 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -654,9 +654,12 @@ func IsResponseResultSuccess(data []byte) bool {
        err := json.Unmarshal(data, &errResp)
        if err == nil && errResp.Response != nil {
                return errResp.Response.Success
+       } else if err != nil {
+               Debug(DbgWarn, "IsResponseResultSuccess: failed to parse response result: %v\n", err)
+               return false
+       } else {
+               return true
        }
-       Debug(DbgWarn, "IsResponseResultSuccess: failed to parse response result: %v\n", err)
-       return true
 }

i can open a pr once you confirm.

Not adding "api" to the URL

I'm running against Bluemix, and trying to list activations with:

	config, err := WhiskConfigFromEnvironment()
	if err != nil {
		return nil, err
	}
	client, _ := whisk.NewClient(http.DefaultClient, config)
	activations, resp, err := client.Activations.List(nil)

In WhiskConfigFromEnvironment() I’m setting config.AUTH and config.APIHOST based on what’s in my ~/.wskprops file.

However it's getting a 404 because it's trying to go to http://openwhisk.ng.bluemix.net/v1/namespaces/_/activations, which is missing api in the base url.

If I run wsk -d activation list I can see that it goes to https://openwhisk.ng.bluemix.net/api/v1/namespaces/_/activations?limit=30&skip=0.

I verified that it fixes the issue w/ this (hacky) workaround:

    requestUrlString := strings.Replace(requestUrl.String(), "v1", "api/v1", 1)

    req, err := http.NewRequest(method, requestUrlString, buf)

After that change, client.Activations.List(nil) returns the list of activations.

Some source files miss Apache license headers

Following Apache license header guideline, all human-readable Apache-developed files that are included within a distribution must include the header text with few exceptions. You can find few exceptions here: which files do not require a license header.

I used Apache Rat to check this repository after excluding a few files, and I got this report. We need to add Apache licensing header to those files.

Unapproved licenses:

  openwhisk-client-go/tools/travis/setup.sh
  openwhisk-client-go/tools/travis/build.sh
  openwhisk-client-go/tools/travis/test_openwhisk.sh
  openwhisk-client-go/Makefile

The excluded files are:

**/*.json
**/**.gradle
**/gradlew
**/gradle/**
**/.**
**/templates/**
**/*.j2.*
**/.github/**
**/auth.whisk.system
**/auth.guest
**/i18n_resources.go

wsk activation list behavior

A recent change to the way activations are listed produced two different behaviors.

When there are no activations, the result is this:

> wsk activation list 
activations

and when repeated with activations, the result is this:

>  wsk activation list
Datetime            Activation ID                    Kind                 Start Duration   Status            Entity                                                                                              
2019-03-14 15:25:40 1d11658e3f974e6391658e3f97be63ac nodejs:6             cold  69ms       success           guest/e:0.0.1                                                                                       

@larandersson perhaps we should nuke the naked activations headers when there are no results.

additionally, can we trim the lines so that they don't overflow unnecessarily?

Screen Shot 2019-03-14 at 2 42 42 PM

consider adopting the kubectl "plugin" mechanism

proposal: adopt kubectl's lightweight plugin mechanism for the openwhisk go cli. it's not even really a plugin mechanism, just a simple dispatcher. kubectl foo works if some executable kubectl-foo is on my PATH. kubectl is agnostic to the impl of kubectl-foo; i.e. it could be another go executable, a nodejs shebang, a bash script, etc.

getting this support into wsk should require only small changes, especially if we can leverage the platform's "which/type" support. i.e.: wsk foo, if not resolved by a built-in command or command subtree "foo" will delegate to the PATH resolver, which does a which foo. if this succeeds, it delegates the command line to an Exec of that resolved /path/to/foo.

kubectl also has a kubectl plugin list, which is a bit more time-intensive, but at the same time not latency sensitive: this one must scan PATH for matching wsk-xxxx executables.

Verify if this repo gets the latest go whisk code for openwhisk

Since the Go CLI decides to have a separate repo to host the code, the first step should make sure the repo here hosts the latest the Go CLI code and keep the same pace as the Go CLI changes.

This repo hosts the code of go-whisk under openwhisk/tools/cli. Another repo needs to be created for go-whisk-cli under openwhisk/tools/cli.

Before finishing the movement of Go CLI from openwhisk over here, we can tentatively maintain Go CLI at two locations.

After the movement is done, the one in openwhisk will deprecate.

http/https proxy support is broken

When using the wsk CLI with a proxy, the proxy configuration is ignored.

Steps to recreate.

  1. run wsk action list. confirm the command works successfully as expected.
  2. set the HTTPS_PROXY environment variable to https://some.non.existent.host:1234
  3. run wsk action list again

Expected result:
An error containing proxyconnect tcp: dial tcp: in the error message

Actual result:
Results of successful wsk action list command.

Update to use latest go-whisk code

This is currently out-of date. Need to update to latest code in whisk core, add build instructions to make sure wsk18in gets built correctly.

Add documentation

I was tiring to invoke a function using the this lib. I had to jump between the wsk client code and this to figure out what to do here. For instance here it would have been really helpful to know that payload should be a map[string]interface{} to send data.

Cannot reuse TCP connection across action invocations

In the current implimentation, LoadX509KeyPair() is executed when making a new http request. As a result, a new Transport is created for each request. However, TCP connections cannot be reused across different transports. This will cause the program to reach fd limits quickly under a heavy load, e.g., invoke actions programmingly.

Here is a demo of the deficiency:
When I invoke an action (host ip: 13.66.***.**) sequentially for a couple of times, several connections are established. Idealy, only one connection should be created and reused.

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 localhost:socks         0.0.0.0:*               LISTEN     
tcp        0      0 localhost:1188          0.0.0.0:*               LISTEN     
tcp        0      0 mingyu-virtual-ma:35702 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35698 13.66.***.**:https      ESTABLISHED 
tcp        0      0 mingyu-virtual-ma:35696 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35700 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35704 13.66.***.**:https      ESTABLISHED
tcp        0      0 mingyu-virtual-ma:35694 13.66.***.**:https      ESTABLISHED
tcp6       0      0 ip6-localhost:ipp       [::]:*                  LISTEN     
tcp6       0      0 ip6-localhost:socks     [::]:*                  LISTEN

Use Gogradle for build

This repo should use Gogradle to do builds with like incubator-openwhisk-cli does. All other build methods should be removed.

Benchmarking the reflection API

I have modified the source files as follows:

diff --git a/go.mod b/go.mod
index 0491f2d..eb9c282 100644
--- a/go.mod
+++ b/go.mod
@@ -1,12 +1,13 @@
module github.com/apache/openwhisk-client-go

-go 1.15
+go 1.16

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/cloudfoundry/jibber_jabber v0.0.0-20151120183258-bcc4c8345a21
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/color v1.10.0

  •   github.com/goccy/go-reflect v1.1.0
      github.com/google/go-querystring v1.0.0
      github.com/hokaccha/go-prettyjson v0.0.0-20210113012101-fb4e108d2519
      github.com/nicksnyder/go-i18n v1.10.1
    

diff --git a/go.sum b/go.sum
index 25fcb1b..86cd625 100644
--- a/go.sum
+++ b/go.sum
@@ -11,6 +11,8 @@ github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGE
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
+github.com/goccy/go-reflect v1.1.0 h1:kiT3+exv9ULtdpawlMzCGT1y5bWOmuY3jgS86GB9t1s=
+github.com/goccy/go-reflect v1.1.0/go.mod h1:n0oYZn8VcV2CkWTxi8B9QjkCoq6GTtCEdfmR66YhFtE=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
diff --git a/whisk/client.go b/whisk/client.go
index 0bd25cd..5f18a8f 100644
--- a/whisk/client.go
+++ b/whisk/client.go
@@ -29,12 +29,13 @@ import (
"net"
"net/http"
"net/url"

  •   "reflect"
      "regexp"
      "runtime"
      "strings"
      "time"
    
  •   reflect "github.com/goccy/go-reflect"
    
  •   "github.com/apache/openwhisk-client-go/wski18n"
    

)

diff --git a/whisk/util.go b/whisk/util.go
index 683c680..32e7a09 100644
--- a/whisk/util.go
+++ b/whisk/util.go
@@ -21,9 +21,10 @@ import (
"errors"
"fmt"
"net/url"

  •   "reflect"
      "strings"
    
  •   reflect "github.com/goccy/go-reflect"
    
  •   "github.com/apache/openwhisk-client-go/wski18n"
      "github.com/fatih/color"
      "github.com/google/go-querystring/query"
    

Create/Deploy a go action using this go-client

Hello,

I'm trying to deploy an action with go runtime by using this go client. I found the Insert method, so I'm trying something like:

newAction := whisk.Action{
	Namespace: "_",
	Name:      foo,
	Version:   "v1",
}
newAction.Exec = &whisk.Exec{
	Kind: "Go:1.15",
	Code: <???>,
	Image: <???>,
}
_, resp, err := client.Actions.Insert(&newAction, true)

The problem is that I can't figure out how to specify the source code for this function. Is it possible to assing a certain path to a field of one of these two types like newAction.Exec.sth = "/path/to/foo.go" ??
Also, when i try for example setting newAction.Exec.Image = "/path/to/exec.zip" (where zip created following this guide) and ignoring Code field, i'm getting a 400 Bad Request with the following error:

The request content was malformed:
'code' must be a string or attachment object defined in 'exec' for 'go:1.15' actions (code oMTYeg66S3pUoWR4TGUSXusml8cmV2jF)

So, i'm pretty sure that I'm not using it right 😝. Does anyone have any thoughts on this?

Best regards

Example Request

Hi,

I'd like to deploy action/function with go runtime by also importing external go library.

Could you provide an example for that ?

regression in wsk cli tests correlated to client-go commit 67f06bc

As shown by comparing the TravisCI results of wsk-cli PRs apache/openwhisk-cli#422 and apache/openwhisk-cli#423, The client-go PR #116 (git hash 67f06bc) introduced failures in the WskCliConsoleTests (see https://travis-ci.org/apache/incubator-openwhisk-cli/builds/505208192#L5182).

@larandersson @rabbah - Please take a look and decide if we need to update test cases, need a compensating fix in the cli, or if the client-go commit was buggy. This is blocking progress on the next Apache release of the wsk cli and dependent projects.

How can I specify "--insecure" using this library?

I install openwhisk in ubuntu in my own computer and I can access it using wsk -i ....... However, I have problems using this library to access openwhisk.

For example:
I can run the following command to list all the actions I have created in openwhisk.
wsk -i action list
The output is

actions
/guest/test                                                          private blackbox

However, when I try to do the same thing in a GO program using this library, something wrong happens. Here are my codes:

config := &whisk.Config{
                Host: "http://172.17.0.1",
		Version: "v1",
		Verbose: true,
		Namespace: "_",
		AuthToken: "23bc46b1-71f6-4ed5-8c54-816aa4f8c502:123zO3xZCLrMN6v2BKK1dXYFpXlPkccOFqm12CdAsMgRU4VrNZ9lyGVCGuMDGIwP",
		Debug: true,
		Insecure: true,
	}
client, err := whisk.NewClient(http.DefaultClient, config)

if err != nil {
	fmt.Println(err)
	os.Exit(-1)
}

options := &whisk.ActionListOptions{
        Limit: 30,
  	Skip: 0,
}

actions, resp, err := client.Actions.List("",options)
if err != nil {
        fmt.Println(err)
        os.Exit(-1)
}
fmt.Println("Returned with status: ", resp.Status)
fmt.Println("Returned actions: \n%+v", actions)

The error message is:

The resource requires authentication, which was not supplied with the request (code df76048ef1abc23514e2a73aa26c910b)

I wonder if I did something wrong in the GO program. Thanks!

Establishment of Travis CI

Travis CI is needed to guarantee the quality of the code changes.
Both unit tests and integration tests against openwhisk will be tested in Travis CI.

This repo needs to bring in the test cases against openwhisk services. By far, these test cases are only available in Go and only for binary of openwhisk-cli. We can tentatively use them as the integration tests before reimplementing them in go and rest based.

wrong statusCode in case of application error in activation output

Hi guys,

I am getting statusCode 0 in case of application error. It should be 1 in case of application error. I am returning 400 statusCode in my action's output but it is showing statusCode 0 in response map and in the root json also it is showing statusCode 0.
you can see the output of wsk -i activation get activationId command in below screenshot.
Screenshot from 2021-01-05 13-18-14

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.