1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-21 05:55:35 +00:00

Port openwhisk to v1beta1 🦇

Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
This commit is contained in:
Vincent Demeester 2020-03-05 15:19:02 +01:00 committed by tekton-robot
parent 4341bae32d
commit 75e7349ef5
6 changed files with 193 additions and 210 deletions

View File

@ -1,94 +1,93 @@
# Task to define Runtime Parameters
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: openwhisk
name: openwhisk
spec:
resources:
inputs:
resources:
- name: runtime-git
type: git
params:
- name: DOCKERFILE
description: The path to the dockerfile to build from Runtime Repo
- name: OW_RUNTIME_DEBUG
description: flag to indicate debug mode should be on/off
default: "false"
- name: OW_RUNTIME_PLATFORM
description: flag to indicate the platform, one of ["openwhisk", "knative", ... ]
default: "knative"
- name: OW_ACTION_NAME
description: name of the action
default: ""
- name: OW_ACTION_CODE
description: JavaScript source code to be evaluated
default: ""
- name: OW_ACTION_MAIN
description: name of the function in the "__OW_ACTION_CODE" to call as the action handler
default: "main"
- name: OW_ACTION_BINARY
description: flag to indicate zip function, for zip actions, "__OW_ACTION_CODE" must be base64 encoded string
default: "false"
- name: OW_HTTP_METHODS
description: list of HTTP methods, any combination of [GET, POST, PUT, and DELETE], default is [POST]
default: "[POST]"
- name: OW_ACTION_RAW
description: flag to indicate raw HTTP handling, interpret and process an incoming HTTP body directly
default: "false"
- name: OW_PROJECT_URL
description: Location to local or remote file storage or public or private GitHub repo from where action source code needs to be evaluated
default: ""
- name: runtime-git
type: git
outputs:
resources:
- name: runtime-image
type: image
steps:
- name: add-ow-env-to-dockerfile
image: ubuntu
command:
- bash
args:
- -c
- |
if [ -z $(inputs.params.OW_PROJECT_URL) ]; then
OW_ACTION_CODE="$(inputs.params.OW_ACTION_CODE)"
else
TEMPDIR="knative-"$((1 + RANDOM % 100))
TEMPFILE=`basename "$(inputs.params.OW_PROJECT_URL)"`
mkdir $TEMPDIR
cd $TEMPDIR
wget -O $TEMPFILE "$(inputs.params.OW_PROJECT_URL)"
if [ "$(inputs.params.OW_ACTION_BINARY)" = true ]; then
OW_ACTION_CODE=`base64 $TEMPFILE | tr -d '[:space:]'`
else
OW_ACTION_CODE=`cat $TEMPFILE`
fi
cd ..
fi
cat <<EOF >> $(inputs.params.DOCKERFILE)
ENV __OW_RUNTIME_DEBUG "$(inputs.params.OW_RUNTIME_DEBUG)"
ENV __OW_RUNTIME_PLATFORM "$(inputs.params.OW_RUNTIME_PLATFORM)"
ENV __OW_ACTION_NAME "$(inputs.params.OW_ACTION_NAME)"
ENV __OW_ACTION_CODE "${OW_ACTION_CODE}"
ENV __OW_ACTION_MAIN "$(inputs.params.OW_ACTION_MAIN)"
ENV __OW_ACTION_BINARY "$(inputs.params.OW_ACTION_BINARY)"
ENV __OW_HTTP_METHODS "$(inputs.params.OW_HTTP_METHODS)"
ENV __OW_ACTION_RAW "$(inputs.params.OW_ACTION_RAW)"
ENV __OW_PROJECT_URL "$(inputs.params.OW_PROJECT_URL)"
EOF
- name: update-dockerfile-for-tekton
image: ubuntu
command:
- sed
args:
- -i
- -e
- 's/COPY ./COPY .\/runtime-git/g'
- $(inputs.params.DOCKERFILE)
- name: build-openwhisk-nodejs-runtime
image: "gcr.io/kaniko-project/executor:latest"
command:
- /kaniko/executor
args:
- --dockerfile=$(inputs.params.DOCKERFILE)
- --destination=$(outputs.resources.runtime-image.url)
- name: runtime-image
type: image
params:
- name: DOCKERFILE
description: The path to the dockerfile to build from Runtime Repo
- name: OW_RUNTIME_DEBUG
description: flag to indicate debug mode should be on/off
default: "false"
- name: OW_RUNTIME_PLATFORM
description: flag to indicate the platform, one of ["openwhisk", "knative", ... ]
default: "knative"
- name: OW_ACTION_NAME
description: name of the action
default: ""
- name: OW_ACTION_CODE
description: JavaScript source code to be evaluated
default: ""
- name: OW_ACTION_MAIN
description: name of the function in the "__OW_ACTION_CODE" to call as the action handler
default: "main"
- name: OW_ACTION_BINARY
description: flag to indicate zip function, for zip actions, "__OW_ACTION_CODE" must be base64 encoded string
default: "false"
- name: OW_HTTP_METHODS
description: list of HTTP methods, any combination of [GET, POST, PUT, and DELETE], default is [POST]
default: "[POST]"
- name: OW_ACTION_RAW
description: flag to indicate raw HTTP handling, interpret and process an incoming HTTP body directly
default: "false"
- name: OW_PROJECT_URL
description: Location to local or remote file storage or public or private GitHub repo from where action source code needs to be evaluated
default: ""
steps:
- name: add-ow-env-to-dockerfile
image: ubuntu
command:
- bash
args:
- -c
- |
if [ -z $(params.OW_PROJECT_URL) ]; then
OW_ACTION_CODE="$(params.OW_ACTION_CODE)"
else
TEMPDIR="knative-"$((1 + RANDOM % 100))
TEMPFILE=`basename "$(params.OW_PROJECT_URL)"`
mkdir $TEMPDIR
cd $TEMPDIR
wget -O $TEMPFILE "$(params.OW_PROJECT_URL)"
if [ "$(params.OW_ACTION_BINARY)" = true ]; then
OW_ACTION_CODE=`base64 $TEMPFILE | tr -d '[:space:]'`
else
OW_ACTION_CODE=`cat $TEMPFILE`
fi
cd ..
fi
cat <<EOF >> $(params.DOCKERFILE)
ENV __OW_RUNTIME_DEBUG "$(params.OW_RUNTIME_DEBUG)"
ENV __OW_RUNTIME_PLATFORM "$(params.OW_RUNTIME_PLATFORM)"
ENV __OW_ACTION_NAME "$(params.OW_ACTION_NAME)"
ENV __OW_ACTION_CODE "${OW_ACTION_CODE}"
ENV __OW_ACTION_MAIN "$(params.OW_ACTION_MAIN)"
ENV __OW_ACTION_BINARY "$(params.OW_ACTION_BINARY)"
ENV __OW_HTTP_METHODS "$(params.OW_HTTP_METHODS)"
ENV __OW_ACTION_RAW "$(params.OW_ACTION_RAW)"
ENV __OW_PROJECT_URL "$(params.OW_PROJECT_URL)"
EOF
- name: update-dockerfile-for-tekton
image: ubuntu
command:
- sed
args:
- -i
- -e
- 's/COPY ./COPY .\/runtime-git/g'
- $(params.DOCKERFILE)
- name: build-openwhisk-nodejs-runtime
image: "gcr.io/kaniko-project/executor:latest"
command:
- /kaniko/executor
args:
- --dockerfile=$(params.DOCKERFILE)
- --destination=$(resources.outputs.runtime-image.url)

View File

@ -110,7 +110,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-helloworld
@ -120,25 +120,24 @@ spec:
name: task-openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main() {return {payload: 'Hello World!'};}"
- name: OW_PROJECT_URL
value: ""
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-helloworld-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main() {return {payload: 'Hello World!'};}"
- name: OW_PROJECT_URL
value: ""
---
```
</details>
@ -303,7 +302,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-helloworld-with-params
@ -313,25 +312,24 @@ spec:
name: task-openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main(params) {return {payload: 'Hello ' + params.name + ' from ' + params.place + '!'};}"
- name: OW_PROJECT_URL
value: ""
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-helloworld-with-params-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main(params) {return {payload: 'Hello ' + params.name + ' from ' + params.place + '!'};}"
- name: OW_PROJECT_URL
value: ""
---
```
</details>
@ -403,7 +401,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-raw-github
@ -413,25 +411,24 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://raw.githubusercontent.com/tektoncd/catalog/openwhisk/openwhisk/runtimes/javascript/examples/03-github/hello.js"
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-raw-github-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://raw.githubusercontent.com/tektoncd/catalog/openwhisk/openwhisk/runtimes/javascript/examples/03-github/hello.js"
---
```
</details>
@ -506,7 +503,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-zip
@ -516,25 +513,24 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://github.com/tektoncd/catalog/raw/master/openwhisk/runtimes/javascript/examples/04-zip/action.zip"
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-zip-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://github.com/tektoncd/catalog/raw/master/openwhisk/runtimes/javascript/examples/04-zip/action.zip"
---
```
</details>

View File

@ -25,7 +25,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-helloworld
@ -35,25 +35,22 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main() {return {payload: 'Hello World!'};}"
- name: OW_PROJECT_URL
value: ""
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-helloworld-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main() {return {payload: 'Hello World!'};}"
- name: OW_PROJECT_URL
value: ""
---

View File

@ -25,7 +25,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-helloworld-with-params
@ -35,25 +35,22 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main(params) {return {payload: 'Hello ' + params.name + ' from ' + params.place + '!'};}"
- name: OW_PROJECT_URL
value: ""
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-helloworld-with-params-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: "function main(params) {return {payload: 'Hello ' + params.name + ' from ' + params.place + '!'};}"
- name: OW_PROJECT_URL
value: ""
---

View File

@ -25,7 +25,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-raw-github
@ -35,25 +35,22 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://raw.githubusercontent.com/tektoncd/catalog/openwhisk/openwhisk/runtimes/javascript/examples/03-github/hello.js"
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-raw-github-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_PROJECT_URL
value: "https://raw.githubusercontent.com/tektoncd/catalog/openwhisk/openwhisk/runtimes/javascript/examples/03-github/hello.js"
---

View File

@ -25,7 +25,7 @@ spec:
---
# Task Run to build NodeJS image with the action source
apiVersion: tekton.dev/v1alpha1
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
name: openwhisk-nodejs-zip
@ -35,27 +35,24 @@ spec:
name: openwhisk
trigger:
type: manual
inputs:
resources:
resources:
inputs:
- name: runtime-git
resourceRef:
name: openwhisk-nodejs-runtime-git
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_ACTION_BINARY
value: "true"
- name: OW_PROJECT_URL
value: "https://github.com/tektoncd/catalog/blob/openwhisk/openwhisk/runtimes/javascript/examples/04-zip/action.zip?raw=true"
outputs:
resources:
outputs:
- name: runtime-image
resourceRef:
name: openwhisk-nodejs-zip-image
params:
- name: DOCKERFILE
value: "./runtime-git/core/nodejs10Action/knative/Dockerfile"
- name: OW_ACTION_NAME
value: "nodejs-helloworld"
- name: OW_ACTION_CODE
value: ""
- name: OW_ACTION_BINARY
value: "true"
- name: OW_PROJECT_URL
value: "https://github.com/tektoncd/catalog/blob/openwhisk/openwhisk/runtimes/javascript/examples/04-zip/action.zip?raw=true"
---