Create/Deploy a go action using this go-client
john98nf opened this issue · 1 comments
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
Solution found by studying openwhisk-cli action create command implementation itself. Code field requires to point to a string containing the action-code. So something like:
file, err := ioutil.ReadFile("/path/to/sourceCode.go")
if err != nil {
log.Fatal(err)
}
code := string(file)
newAction.Exec.Code = &code
, should do the trick.