Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

Commit

Permalink
Build with Go 1.15 (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sepetrov authored Oct 5, 2020
1 parent ffd182f commit 7b2c26d
Show file tree
Hide file tree
Showing 2,340 changed files with 72 additions and 742,828 deletions.
48 changes: 27 additions & 21 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,14 @@ build_allways: &build_allways
tags:
only: /.*/
defaults: &defaults
working_directory: /home/circleci/.go_workspace/src/github.com/kubeless/kubeless
environment:
GOPATH: /home/circleci/.go_workspace
CONTROLLER_IMAGE_NAME: kubeless/function-controller
BUILDER_IMAGE_NAME: kubeless/function-image-builder
CGO_ENABLED: "0"
TEST_DEBUG: "1"
GKE_VERSION: 1.12
MINIKUBE_VERSION: v1.2.0
MANIFESTS: kubeless kubeless-non-rbac kubeless-openshift
GO111MODULE: "on"
exports: &exports
# It is not possible to resolve env vars in the environment section:
# https://discuss.circleci.com/t/using-environment-variables-in-config-yml-not-working/14237
Expand All @@ -32,7 +29,7 @@ restore_workspace: &restore_workspace
run: |
make bootstrap
sudo cp -r /tmp/go/bin/* /usr/local/bin/
cp -r /tmp/go/src/github.com/kubeless/kubeless/*yaml .
cp -r /tmp/go/*yaml .
#### End of definitions

workflows:
Expand Down Expand Up @@ -79,13 +76,14 @@ jobs:
build:
<<: *defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.15
steps:
- checkout
- restore_cache:
keys:
- go-mod-v4-{{ checksum "go.sum" }}
- <<: *exports
# go build creates files under /usr/local/go where the running user doesn't have permissions to write
- run: sudo chown -R circleci:circleci /usr/local/go/
- run: go get -u golang.org/x/lint/golint
- run: go mod download
- run: make bootstrap
- run: make VERSION=${CONTROLLER_TAG} binary
- run: make test
Expand All @@ -99,18 +97,26 @@ jobs:
cp ${f}.yaml build-manifests/
done
- persist_to_workspace:
root: /home/circleci/.go_workspace
paths:
- bin
- src/github.com/kubeless/kubeless/*yaml
root: /go
paths:
- ./bin
- persist_to_workspace:
root: ./
paths:
- ./*yaml
- store_artifacts:
path: /home/circleci/.go_workspace/bin/kubeless
path: /go/bin/kubeless
destination: ./bin/kubeless
- store_artifacts:
path: build-manifests
path: ./build-manifests/
- save_cache:
key: go-mod-v4-{{ checksum "go.sum" }}
paths:
- /go/pkg/mod
minikube:
<<: *defaults
machine:
image: ubuntu-1604:201903-01
image: ubuntu-1604:202007-01
steps:
- checkout
- run: sudo apt-get update -y
Expand All @@ -125,7 +131,7 @@ jobs:
build-cross-binaries:
<<: *defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.15
steps:
- <<: *exports
- checkout
Expand All @@ -138,7 +144,7 @@ jobs:
minikube_build_functions:
<<: *defaults
machine:
image: ubuntu-1604:201903-01
image: ubuntu-1604:202007-01
steps:
- checkout
- <<: *exports
Expand All @@ -147,7 +153,7 @@ jobs:
- <<: *restore_workspace
- run: ./script/pull-or-build-image.sh function-controller
- run: ./script/pull-or-build-image.sh function-image-builder
- run: "echo '{\"host\": \"unix:///var/run/docker.sock\", \"storage-driver\": \"overlay2\", \"insecure-registries\" : [\"0.0.0.0/0\"]}' > /tmp/daemon.json"
- run: "echo '{\"insecure-registries\" : [\"0.0.0.0/0\"]}' > /tmp/daemon.json"
- run: sudo mv /tmp/daemon.json /etc/docker/daemon.json
- run: sudo service docker restart
- run: docker info
Expand All @@ -159,7 +165,7 @@ jobs:
GKE:
<<: *defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.15
steps:
- run: |
# In case of GKE we will only want to build if it is
Expand All @@ -186,7 +192,7 @@ jobs:
push_latest_images:
<<: *defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.15
steps:
- <<: *exports
- setup_remote_docker
Expand All @@ -205,7 +211,7 @@ jobs:
release:
<<: *defaults
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.15
steps:
- <<: *exports
- checkout
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ fmt:
$(GOFMT) -s -w $(GO_FILES)

bats:
git clone --depth=1 https://github.com/sstephenson/bats.git
git clone --branch=v0.4.0 --depth=1 https://github.com/sstephenson/bats.git

ksonnet-lib:
git clone --depth=1 https://github.com/ksonnet/ksonnet-lib.git

.PHONY: bootstrap
bootstrap: bats ksonnet-lib

go get -u github.com/mitchellh/gox
GO111MODULE="off" go get -u github.com/mitchellh/gox
GO111MODULE="off" go get -u golang.org/x/lint/golint

@if ! which kubecfg >/dev/null; then \
sudo wget -q -O /usr/local/bin/kubecfg https://github.com/ksonnet/kubecfg/releases/download/v0.9.0/kubecfg-$$(go env GOOS)-$$(go env GOARCH); \
Expand Down
58 changes: 23 additions & 35 deletions examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ GIT_SHA1 ?= master
BASE_URL := https://raw.githubusercontent.com/kubeless/kubeless/$(GIT_SHA1)

get-python:
kubeless function deploy get-python --runtime python2.7 --handler helloget.foo --from-file python/helloget.py
kubeless function deploy get-python --runtime python3.7 --handler helloget.foo --from-file python/helloget.py

get-python-verify:
kubeless function call get-python |egrep hello.world
Expand All @@ -19,19 +19,19 @@ get-python-update-verify:

get-python-deps:
cd python && zip hellowithdeps.zip hellowithdeps.py hellowithdepshelper.py && cd ..
kubeless function deploy get-python-deps --runtime python2.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.zip --dependencies python/requirements.txt
kubeless function deploy get-python-deps --runtime python3.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.zip --dependencies python/requirements.txt

get-python-deps-tar-gz:
cd python && tar czf hellowithdeps.tar.gz hellowithdeps.py hellowithdepshelper.py && cd ..
kubeless function deploy get-python-deps-tar-gz --runtime python2.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.gz --dependencies python/requirements.txt
kubeless function deploy get-python-deps-tar-gz --runtime python3.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.gz --dependencies python/requirements.txt

get-python-deps-tar-bz2:
cd python && tar cjf hellowithdeps.tar.bz2 hellowithdeps.py hellowithdepshelper.py && cd ..
kubeless function deploy get-python-deps-tar-bz2 --runtime python2.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.bz2 --dependencies python/requirements.txt
kubeless function deploy get-python-deps-tar-bz2 --runtime python3.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.bz2 --dependencies python/requirements.txt

get-python-deps-tar-xz:
cd python && tar cJf hellowithdeps.tar.xz hellowithdeps.py hellowithdepshelper.py && cd ..
kubeless function deploy get-python-deps-tar-xz --runtime python2.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.xz --dependencies python/requirements.txt
kubeless function deploy get-python-deps-tar-xz --runtime python3.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tar.xz --dependencies python/requirements.txt

get-python-deps-verify:
kubeless function call get-python-deps |egrep Google
Expand All @@ -46,7 +46,7 @@ get-python-deps-tar-xz-verify:
kubeless function call get-python-deps-tar-xz |egrep Google

get-python-custom-port:
kubeless function deploy get-python-custom-port --runtime python2.7 --handler helloget.foo --from-file python/helloget.py --port 8081
kubeless function deploy get-python-custom-port --runtime python3.7 --handler helloget.foo --from-file python/helloget.py --port 8081

get-python-custom-port-verify:
kubectl get svc get-python-custom-port -o yaml | grep 'targetPort: 8081'
Expand All @@ -63,21 +63,9 @@ get-python-deps-update-verify:
echo "Checking updated deps of $$pod"; \
kubectl exec -it $$pod pip freeze | grep -q "twitter=="

get-python-34:
kubeless function deploy get-python --runtime python3.4 --handler helloget.foo --from-file python/helloget.py

get-python-34-verify:
kubeless function call get-python |egrep hello.world

get-python-36:
kubeless function deploy get-python-36 --runtime python3.6 --handler helloget.foo --from-file python/helloget.py

get-python-36-verify:
kubeless function call get-python-36 |egrep hello.world

get-python-url-deps:
cd python && tar czf hellowithdeps.tgz hellowithdeps.py hellowithdepshelper.py && cd ..
kubeless function deploy get-python-url-deps --runtime python2.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tgz --dependencies $(BASE_URL)/examples/python/requirements.txt
kubeless function deploy get-python-url-deps --runtime python3.7 --handler hellowithdeps.foo --from-file python/hellowithdeps.tgz --dependencies $(BASE_URL)/examples/python/requirements.txt

get-python-url-deps-verify:
kubeless function call get-python-url-deps |egrep Google
Expand Down Expand Up @@ -107,7 +95,7 @@ get-node-url-tar-xz-verify:
kubeless function call get-node-url-tar-xz |egrep hello.world

scheduled-get-python:
kubeless function deploy scheduled-get-python --schedule "* * * * *" --runtime python2.7 --handler helloget.foo --from-file python/helloget.py
kubeless function deploy scheduled-get-python --schedule "* * * * *" --runtime python3.7 --handler helloget.foo --from-file python/helloget.py

scheduled-get-python-verify:
number="1"; \
Expand All @@ -128,7 +116,7 @@ scheduled-get-python-verify:
timeout-python:
$(eval TMPDIR := $(shell mktemp -d))
printf 'def foo(event, context):\n%4swhile 1: pass\n%4sreturn "hello world"\n' > $(TMPDIR)/hello-loop.py
kubeless function deploy timeout-python --runtime python2.7 --handler helloget.foo --from-file $(TMPDIR)/hello-loop.py --timeout 3
kubeless function deploy timeout-python --runtime python3.7 --handler helloget.foo --from-file $(TMPDIR)/hello-loop.py --timeout 3
rm -rf $(TMPDIR)

timeout-python-verify:
Expand Down Expand Up @@ -202,7 +190,7 @@ timeout-go-verify:
echo $(MSG) | egrep Request.timeout.exceeded

get-go-deps:
kubeless function deploy get-go-deps --runtime go1.14 --handler helloget.Hello --from-file golang/hellowithdeps.go --dependencies golang/Gopkg.toml
kubeless function deploy get-go-deps --runtime go1.14 --handler helloget.Hello --from-file golang/hellowithdeps.go --dependencies golang/go.mod

get-go-deps-verify:
kubeless function call get-go-deps --data '{"hello": "world"}'
Expand All @@ -221,7 +209,7 @@ post-go-verify:
echo $$logs | grep -q "cli.kubeless.io"

get-python-metadata:
kubeless function deploy get-python-metadata --runtime python2.7 --handler helloget.foo --from-file python/helloget.py --env foo:bar,bar=foo --memory 128Mi --label foo:bar,bar=foo,foobar
kubeless function deploy get-python-metadata --runtime python3.7 --handler helloget.foo --from-file python/helloget.py --env foo:bar,bar=foo --memory 128Mi --label foo:bar,bar=foo,foobar

get-python-metadata-verify:
kubeless function call get-python-metadata |egrep hello.world
Expand All @@ -233,7 +221,7 @@ get-python-metadata-verify:

get-python-secrets:
kubectl create secret generic test-secret --from-literal=key=MY_KEY || true
kubeless function deploy get-python-secrets --runtime python2.7 --handler helloget.foo --from-file python/helloget.py --secrets test-secret
kubeless function deploy get-python-secrets --runtime python3.7 --handler helloget.foo --from-file python/helloget.py --secrets test-secret

get-python-secrets-verify:
$(eval pod := $(shell kubectl get pod -l function=get-python-secrets -o go-template -o custom-columns=:metadata.name --no-headers=true))
Expand Down Expand Up @@ -344,7 +332,7 @@ custom-get-python-update-verify:
get: get-python get-nodejs get-python-metadata get-ruby get-ruby-deps get-python-custom-port

post-python:
kubeless function deploy post-python --runtime python2.7 --handler hellowithdata.handler --from-file python/hellowithdata.py
kubeless function deploy post-python --runtime python3.7 --handler hellowithdata.handler --from-file python/hellowithdata.py

post-python-verify:
kubeless function call post-python --data '{"it-s": "alive"}'|egrep "it.*alive"
Expand All @@ -357,7 +345,7 @@ post-python-verify:
echo $$logs | grep -q "event-id.*"

post-python-custom-port:
kubeless function deploy post-python-custom-port --runtime python2.7 --handler hellowithdata.handler --from-file python/hellowithdata.py --port 8081
kubeless function deploy post-python-custom-port --runtime python3.7 --handler hellowithdata.handler --from-file python/hellowithdata.py --port 8081

post-python-custom-port-verify:
kubectl get svc post-python-custom-port -o yaml | grep 'targetPort: 8081'
Expand Down Expand Up @@ -399,7 +387,7 @@ post: post-python post-nodejs post-ruby post-python-custom-port

pubsub-python:
kubeless topic create s3-python || true
kubeless function deploy pubsub-python --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless function deploy pubsub-python --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless trigger kafka create pubsub-python --function-selector created-by=kubeless,function=pubsub-python --trigger-topic s3-python

# Generate a random string to inject into s3 topic,
Expand Down Expand Up @@ -429,7 +417,7 @@ pubsub-python-verify:
echo $$logs | grep -q "event-id.*"

python-nats:
kubeless function deploy python-nats --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless function deploy python-nats --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless trigger nats create python-nats --function-selector created-by=kubeless,function=python-nats --trigger-topic test

python-nats-verify:
Expand Down Expand Up @@ -459,7 +447,7 @@ python-nats-verify:
echo $$logs | grep -q "event-id.*"

python-kinesis:
kubeless function deploy python-kinesis --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless function deploy python-kinesis --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py
$(eval NODEPORT := $(shell kubectl get svc kinesis -o jsonpath="{.spec.ports[0].nodePort}"))
$(eval MINIKUBE_IP := $(shell minikube ip))
kubectl create secret generic ec2 --from-literal=aws_access_key_id=kinesalite --from-literal=aws_secret_access_key=kinesalite
Expand Down Expand Up @@ -493,7 +481,7 @@ python-kinesis-verify:
echo $$logs | grep -q "event-id.*"

python-kinesis-multi-record:
kubeless function deploy python-kinesis-multi-record --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py
kubeless function deploy python-kinesis-multi-record --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py
$(eval NODEPORT := $(shell kubectl get svc kinesis -o jsonpath="{.spec.ports[0].nodePort}"))
$(eval MINIKUBE_IP := $(shell minikube ip))
kubeless trigger kinesis create kinesis-trigger-mr --function-name python-kinesis-multi-record --aws-region kinesalite --shard-id shardId-000000000000 --stream kubeless-stream --secret ec2 --endpoint http://$(MINIKUBE_IP):$(NODEPORT)
Expand Down Expand Up @@ -527,13 +515,13 @@ python-kinesis-multi-record-verify:
echo $$logs | grep -q "event-id.*"

nats-python-func1-topic-test:
kubeless function deploy nats-python-func1-topic-test --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=nats-topic-test
kubeless function deploy nats-python-func1-topic-test --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=nats-topic-test

nats-python-func2-topic-test:
kubeless function deploy nats-python-func2-topic-test --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=nats-topic-test
kubeless function deploy nats-python-func2-topic-test --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=nats-topic-test

nats-python-func-multi-topic:
kubeless function deploy nats-python-func-multi-topic --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py --label func=nats-python-func-multi-topic
kubeless function deploy nats-python-func-multi-topic --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py --label func=nats-python-func-multi-topic

nats-python-trigger-topic-test:
kubeless trigger nats create nats-python-trigger-topic-test --function-selector created-by=kubeless,topic=nats-topic-test --trigger-topic topic-test
Expand Down Expand Up @@ -646,7 +634,7 @@ nats-python-func-multi-topic-verify:

kafka-python-func1-topic-s3-python:
kubeless topic create s3-python || true
kubeless function deploy kafka-python-func1-topic-s3-python --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=s3-python
kubeless function deploy kafka-python-func1-topic-s3-python --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=s3-python

kafka-python-func1-topic-s3-python-verify:
$(eval DATA := $(shell mktemp -u -t XXXXXXXX))
Expand All @@ -668,7 +656,7 @@ kafka-python-func1-topic-s3-python-verify:

kafka-python-func2-topic-s3-python:
kubeless topic create s3-python || true
kubeless function deploy kafka-python-func2-topic-s3-python --runtime python2.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=s3-python
kubeless function deploy kafka-python-func2-topic-s3-python --runtime python3.7 --handler pubsub.handler --from-file python/hellowithdata.py --label topic=s3-python

kafka-python-func2-topic-s3-python-verify:
$(eval DATA := $(shell mktemp -u -t XXXXXXXX))
Expand Down
4 changes: 0 additions & 4 deletions examples/golang/Gopkg.toml

This file was deleted.

7 changes: 7 additions & 0 deletions examples/golang/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module function

go 1.14

require (
github.com/sirupsen/logrus v1.6.0
)
2 changes: 1 addition & 1 deletion examples/python/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ ENV FUNC_HANDLER=foo \
ADD helloget.py /
RUN mkdir -p /kubeless/
RUN chown 1000:1000 /kubeless
ENTRYPOINT [ "bash", "-c", "cp /helloget.py /kubeless/ && python2.7 /kubeless.py"]
ENTRYPOINT [ "bash", "-c", "cp /helloget.py /kubeless/ && python3.7 /kubeless.py"]
2 changes: 1 addition & 1 deletion examples/python/function.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: function
spec:
handler: hello.handler
runtime: python2.7
runtime: python3.7
function: |
import json
def handler():
Expand Down
2 changes: 1 addition & 1 deletion examples/python/function1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
name: function1
spec:
handler: hello.foobar
runtime: python2.7
runtime: python3.7
deps: |
cowpy
function: |
Expand Down
2 changes: 1 addition & 1 deletion examples/python/hellowithdata.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
def handler(event, context):
print event
print(event)
return event['data']
3 changes: 0 additions & 3 deletions examples/python/hellowithdata34.py

This file was deleted.

Loading

0 comments on commit 7b2c26d

Please sign in to comment.