* feat!: rename event templates to 'cloudevents' This commit renames the templates for cloudevents to be named "cloudevents". BREAKING CHANGE Signed-off-by: Lance Ball <lball@redhat.com> * fixup: update commands.md doc Signed-off-by: Lance Ball <lball@redhat.com> * fixup: fix make test-templates Signed-off-by: Lance Ball <lball@redhat.com> * fixup: missed an e2e test change Signed-off-by: Lance Ball <lball@redhat.com> * fixup: gitignore and pkged.go Signed-off-by: Lance Ball <lball@redhat.com> * fixup: adjust Makefile recipe for pkged.go Signed-off-by: Lance Ball <lball@redhat.com> |
||
---|---|---|
.. | ||
.mvn/wrapper | ||
src | ||
.editorconfig | ||
.gitignore | ||
README.md | ||
manifest.yaml | ||
mvnw | ||
mvnw.cmd | ||
pom.xml |
README.md
Function project
Welcome to your new Function project!
This sample project contains a single function based on Spring Cloud Function: functions.CloudFunctionApplication.uppercase()
, which returns the uppercase of the data passed via CloudEvents.
Local execution
Make sure that Java 11 SDK
is installed.
To start server locally run ./mvnw spring-boot:run
.
The command starts http server and automatically watches for changes of source code.
If source code changes the change will be propagated to running server. It also opens debugging port 5005
so a debugger can be attached if needed.
To run tests locally run ./mvnw test
.
The func
CLI
It's recommended to set FUNC_REGISTRY
environment variable.
# replace ~/.bashrc by your shell rc file
# replace docker.io/johndoe with your registry
export FUNC_REGISTRY=docker.io/johndoe
echo "export FUNC_REGISTRY=docker.io/johndoe" >> ~/.bashrc
Building
This command builds an OCI image for the function.
func build -v # build jar
Running
This command runs the func locally in a container using the image created above.
func run
Deploying
This command will build and deploy the function into cluster.
func deploy -v # also triggers build
Function invocation
For the examples below, please be sure to set the URL
variable to the route of your function.
You get the route by following command.
func info
Note the value of Routes: from the output, set $URL
to its value.
TIP:
If you use kn
then you can set the url by:
# kn service describe <function name> and show route url
export URL=$(kn service describe $(basename $PWD) -ourl)
cURL
curl -v "$URL/uppercase" \
-H "Content-Type:application/json" \
-H "Ce-Id:1" \
-H "Ce-Subject:Uppercase" \
-H "Ce-Source:cloud-event-example" \
-H "Ce-Type:dev.knative.example" \
-H "Ce-Specversion:1.0" \
-d "{\"input\": \"$(whoami)\"}\""
HTTPie
http -v "$URL/uppercase" \
Content-Type:application/json \
Ce-Id:1 \
Ce-Subject:Uppercase \
Ce-Source:cloud-event-example \
Ce-Type:dev.knative.example \
Ce-Specversion:1.0 \
input=$(whoami)
Cleanup
To remove the deployed function from your cluster, run:
func delete