Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static Build, Versioning and Support for More Languages #72

Merged
merged 14 commits into from
Mar 4, 2019
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ tests/build/
vendor/

# Go binary proxy
actionProxyLoop/proxy
golang1.10/proxy
common/proxy
actionloop/proxy
golang1.11/proxy

# Go test transient files
openwhisk/_test/exec
Expand All @@ -26,6 +27,7 @@ openwhisk/_test/output/
openwhisk/action/
openwhisk/compile/
openwhisk/debug.test
*.pyc

# Eclipse
tests/bin/
Expand Down
33 changes: 33 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!--
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
-->
# ActionLoop v1.0.1
- embedded file type detection
- now showing the commend
- librdkafka in golang image
- showing version numbuer with -debug

# Actionloop v1.0.2
Versioning
- renamed actionloop docker image to actionloop-v1.0.2
Docker Images Support
- static build of the executable docker image, so actionloop can be used also in alpine images
ActionLoop for Scripting Languages
- any script starting with '#!' is recognized as executable
- now the -compile will zip the entire directory of the `bin` directory after compilation
- if you upload a folder `src/exec` the entire directory is moved to `bin`, including other uplooaded files
4 changes: 2 additions & 2 deletions CREDITS.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Michele Sciabarra <michele@sciabarra.com>
Michele Sciabarra <msciabarra@apache.org>

Carlos Santana
Carlos Santana <csantana23@gmail.com>

Rodric Rabbah <rodric@gmail.com>

Expand Down
25 changes: 0 additions & 25 deletions LICENSE-filetype.txt

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ This repository containst both the OpenWhisk runtime for Golang Actions, as well
- Deployment for [Generic](docs/DEPLOY.md#generic) actions
- The [ActionLoop](docs/ACTION.md#actionloop) protocol for generic actions

# Change Log

[CHANGES.md](Here.)

# License
[Apache 2.0](LICENSE.txt)

Expand Down
File renamed without changes.
16 changes: 15 additions & 1 deletion actionProxyLoop/build.gradle → actionloop/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,19 @@
* limitations under the License.
*/

ext.dockerImageName = 'actionloop'
ext.dockerImageName = 'actionloop-v1.0.2'
dgrove-oss marked this conversation as resolved.
Show resolved Hide resolved
apply from: '../gradle/docker.gradle'

distDocker.dependsOn 'copyProxy'
distDocker.finalizedBy('cleanup')

task copyProxy(type: Copy) {
from '../common/proxy'
into '.'
}

task cleanup(type: Delete) {
delete 'proxy'
delete 'gobuild.py'
delete 'gobuild.py.launcher.go'
}
7 changes: 5 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ golang {
goVersion = '1.11.5'
}


build.dependsOn vendor

build {
targetPlatform = ['linux-amd64']
go 'build -o actionProxyLoop/proxy main/proxy.go'
go """build -o common/proxy -ldflags '-extldflags "-static"' main/proxy.go"""
}

task cleanup(type: Delete) {
delete 'common/proxy'
}
3 changes: 2 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ IMAGES?=openwhisk

all: .PHONY

.PHONY: bash-hello golang-hello-single golang-main-single golang-main-standalone golang-main-package golang-main-vendor golang-hello-vendor

bash-hello:
cd $@ && OW_USER=$(IMAGES) make clean deploy test

Expand Down Expand Up @@ -30,5 +32,4 @@ golang-hello-vendor:
cd $@ && OW_USER=$(IMAGES) make clean devel test
cd $@ && OW_USER=$(IMAGES) make clean deploy test

.PHONY: bash-hello golang-hello-single golang-main-single golang-main-standalone golang-main-package golang-main-vendor golang-hello-vendor

2 changes: 1 addition & 1 deletion examples/bash-hello/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
WSK?=wsk
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
NAME=bash-hello
PACKAGE=test
SRC=hello.sh
Expand Down
4 changes: 2 additions & 2 deletions examples/golang-hello-single/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=hello
Expand All @@ -19,7 +19,7 @@ $(ZIP): $(SRC)

clean:
-$(WSK) action delete $(PACKAGE)/$(NAME)
-rm $(ZIP) package.done test.json
-rm $(ZIP) package.done test.json 2>/dev/null

test: test.json
$(WSK) action invoke test/$(NAME) -r
Expand Down
8 changes: 4 additions & 4 deletions examples/golang-hello-vendor/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=hello
Expand All @@ -23,14 +23,14 @@ $(BINZIP): $(SRCS) $(VENDORS) $(SRCZIP)
docker run -i $(OW_COMPILER) -compile $(MAIN) <$(SRCZIP) >$(BINZIP)

$(SRCZIP): $(SRCS) $(VENDORS)
cd src ; zip ../$(SRCZIP) -r *
cd src ; zip ../$(SRCZIP) -qr *

clean:
-$(WSK) action delete $(PACKAGE)/$(NAME)
-rm $(BINZIP) $(SRCZIP) package.done test.json
-rm $(BINZIP) $(SRCZIP) package.done test.json 2>/dev/null

clean_vendor:
-rm -r $(VENDORS)
-rm -r $(VENDORS)

test: test.json
$(WSK) action invoke test/$(NAME) -r
Expand Down
8 changes: 4 additions & 4 deletions examples/golang-main-package/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=main
Expand All @@ -16,14 +16,14 @@ devel: package.done $(SRCZIP)
$(WSK) action update $(PACKAGE)/$(NAME) $(SRCZIP) --main $(MAIN) --docker $(OW_COMPILER)

$(BINZIP): $(SRCS)
cd src ; zip - -r * | docker run -i $(OW_COMPILER) -compile $(MAIN) >../$(BINZIP)
cd src ; zip - -qr * | docker run -i $(OW_COMPILER) -compile $(MAIN) >../$(BINZIP)

$(SRCZIP): $(SRCS)
cd src ; zip ../$(SRCZIP) -r *
cd src ; zip ../$(SRCZIP) -qr *

clean:
-$(WSK) action delete $(PACKAGE)/$(NAME)
-rm $(BINZIP) $(SRCZIP) package.done test.json
-rm $(BINZIP) $(SRCZIP) package.done test.json 2>/dev/null

test: test.json
$(WSK) action invoke test/$(NAME) -r
Expand Down
4 changes: 2 additions & 2 deletions examples/golang-main-single/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=main
Expand All @@ -19,7 +19,7 @@ $(ZIP): $(SRC)

clean:
-$(WSK) action delete $(PACKAGE)/$(NAME)
-rm $(ZIP) package.done test.json
-rm $(ZIP) package.done test.json 2>/dev/null

test: test.json
$(WSK) action invoke test/$(NAME) -r
Expand Down
2 changes: 1 addition & 1 deletion examples/golang-main-standalone/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=main
Expand Down
4 changes: 2 additions & 2 deletions examples/golang-main-vendor/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
OW_USER?=openwhisk
OW_RUNTIME?=$(OW_USER)/actionloop
OW_RUNTIME?=$(OW_USER)/actionloop-v1.0.2
OW_COMPILER?=$(OW_USER)/actionloop-golang-v1.11
WSK?=wsk
MAIN=main
Expand All @@ -23,7 +23,7 @@ $(BINZIP): $(SRCS) $(VENDORS) $(SRCZIP)
docker run -i $(OW_COMPILER) -compile $(MAIN) <$(SRCZIP) >$(BINZIP)

$(SRCZIP): $(SRCS) $(VENDORS)
cd src ; zip ../$(SRCZIP) -r *
cd src ; zip ../$(SRCZIP) -qr *

clean:
-$(WSK) action delete $(PACKAGE)/$(NAME)
Expand Down
3 changes: 1 addition & 2 deletions golang1.11/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ distDocker.dependsOn 'copyCompiler'
distDocker.dependsOn 'copyEpilogue'
distDocker.finalizedBy('cleanup')


task copyProxy(type: Copy) {
from '../actionProxyLoop/proxy'
from '../common/proxy'
into '.'
}

Expand Down
31 changes: 1 addition & 30 deletions main/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
package main

import (
"archive/zip"
"bytes"
"flag"
"fmt"
"io/ioutil"
"log"
"os"

Expand All @@ -44,32 +41,6 @@ func fatalIf(err error) {
}
}

// use the runtime as a compiler "on-the-fly"
func extractAndCompile(ap *openwhisk.ActionProxy) {

// read the std input
in, err := ioutil.ReadAll(os.Stdin)
fatalIf(err)

// extract and compile it
file, err := ap.ExtractAndCompile(&in, *compile)
fatalIf(err)

// read the file, zip it and write it to stdout
buf := new(bytes.Buffer)
zwr := zip.NewWriter(buf)
zf, err := zwr.Create("exec")
fatalIf(err)
filedata, err := ioutil.ReadFile(file)
fatalIf(err)
_, err = zf.Write(filedata)
fatalIf(err)
fatalIf(zwr.Flush())
fatalIf(zwr.Close())
_, err = os.Stdout.Write(buf.Bytes())
fatalIf(err)
}

func main() {
flag.Parse()

Expand All @@ -91,7 +62,7 @@ func main() {

// compile on the fly upon request
if *compile != "" {
extractAndCompile(ap)
ap.ExtractAndCompileIO(os.Stdin, os.Stdout, *compile)
return
}

Expand Down
6 changes: 3 additions & 3 deletions openwhisk/_test/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ function build_main {


build hi
zip hi.zip exec
zip -q hi.zip exec
cp exec hi

build_main hello_message
zip hello_message.zip exec
zip -q hello_message.zip exec
cp exec hello_message

build_main hello_greeting
zip hello_greeting.zip exec
zip -q hello_greeting.zip exec
cp exec hello_greeting

test -e hello.zip && rm hello.zip
Expand Down
11 changes: 11 additions & 0 deletions openwhisk/_test/compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.
import os, sys
os.rename(sys.argv[2], sys.argv[3]+"/action")
with open(sys.argv[3]+"/exec", "w") as f:
f.write("""#!/bin/bash
cd "$(dirname $0)"
export PYTHONPATH=$PWD/action
python action/exec.py
""")
18 changes: 18 additions & 0 deletions openwhisk/_test/find.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
find "$1" | sort
6 changes: 6 additions & 0 deletions openwhisk/_test/pysample/exec
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.
cd "$(dirname $0)"
export PYTHONPATH=$PWD/lib
python lib/exec.py
2 changes: 2 additions & 0 deletions openwhisk/_test/pysample/lib/action/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.
7 changes: 7 additions & 0 deletions openwhisk/_test/pysample/lib/action/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.
def main(args):
name = "world"
if "name" in args:
name = args["name"]
return {"python": "Hello, %s" % name }