diff --git a/DEPLOYING.md b/DEPLOYING.md
index 47a26c19..ff39ee50 100644
--- a/DEPLOYING.md
+++ b/DEPLOYING.md
@@ -4,9 +4,16 @@
You can build your function using our provided builder, which already includes buildpacks and an invoker layer:
```
-pack build my-function --path . --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0
+pack build my-function --path . --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=path.function
```
-Where `my-function` is the name of your runnable function image, later used by Docker.
+Where:
+ * `my-function` is the name of your runnable function image, later used by Docker.
+ * `path` is the name of the file or package where the function resides.
+ * `function` is the name of the method or function.
+
+Examples:
+ * Python: BP_FUNCTION=func.main. `func` is the name of the .py file. main is the `method`.
+ * Java: BP_FUNCTION=function.Handler. `function` the package. `Handler` is the class that implements Function.
## Local Deployment
diff --git a/buildpacks/java/README.md b/buildpacks/java/README.md
index c0ba6600..5612bce8 100644
--- a/buildpacks/java/README.md
+++ b/buildpacks/java/README.md
@@ -23,7 +23,10 @@ The buildpack will do the following if detection passed:
To get started you'll need to create a directory where your function will be defined.
From within this directory we require a few files to properly detect this as a Java function:
-* `func.yaml` (optional): We use this to configure the runtime environment variables. See the [Knative Func CLI docs](https://github.com/knative-sandbox/kn-plugin-func/blob/main/docs/guides/func_yaml.md) for more details.
+* `func.yaml` (optional): We use this to configure the runtime environment variables.
+ This buildpack makes use of `envs` and `options`. The keys `name` and `runtime` are required to maintain compatibility with Knative func cli, but are not used by this buildpack.
+ See [Knative's func.yaml documentation](https://github.com/knative/func/blob/main/docs/reference/func_yaml.md)
+ for more `func.yaml` information.
* `pom.xml` or `build.gradle`: These are used by the other Java buildpacks to compile your function.
* Java package in folder `src/main/java/functions`: This is the default location your function will be detected. If you do choose to use another package to store your functions, you will need to define where your function is located with the `BP_FUNCTION` configuration for the buildpack.
diff --git a/buildpacks/python/README.md b/buildpacks/python/README.md
index e6e1ffc5..53d8a4c4 100644
--- a/buildpacks/python/README.md
+++ b/buildpacks/python/README.md
@@ -4,7 +4,8 @@ The Python Function Buildpack is a Cloud Native Buildpack that provides a Python
## Behaviour
This buildpack will participate if any of the following conditions are met:
-* A file with the name `func.yaml` is detected
+- The `BP_FUNCTION` environment variable is set.
+- A valid `func.yaml` exists in the function directory. See [func.yaml](#func.yaml)
The buildpack will do the following if detection passed:
* Request for a Python runtime to be installed to a layer marked `build` and `launch`
@@ -37,18 +38,26 @@ From within this directory we require a few files to properly detect this as a P
* You can find more details about the different accepted parameters [below](#fp).
* `func.yaml` (optional): This is the configuration used to configure your function.
- * The python module and function name can be modified here by defining some environment variables in the `envs` section.
- ```
- envs:
- - name: MODULE_NAME
- value: my_module
- - name: FUNCTION_NAME
- value: my_func
- ```
- By defining the above, we will look for a `my_module.py` instead of `func.py` which contains a function with the name `my_func`.
+
+ The python module and function name can be modified here by defining some environment variables in the `envs` section.
+ ```
+ name: test
+ runtime: python
+ envs:
+ - name: MODULE_NAME
+ value: my_module
+ - name: FUNCTION_NAME
+ value: my_func
+ ```
+ By defining the above, we will look for a `my_module.py` instead of `func.py` which contains a function with the name `my_func`.
+
+ This buildpack makes use of `envs` and `options`. The keys `name` and `runtime` are required to maintain compatibility with Knative func cli, but are not used by this buildpack.
+ See [Knative's func.yaml documentation](https://github.com/knative/func/blob/main/docs/reference/func_yaml.md)
+ for more `func.yaml` information.
**NOTE**: The environment variables here (namely `MODULE_NAME` and `FUNCTION_NAME` will be overriden by the values specified by `BP_FUNCTION`)
+
* `requirements.txt`: This file is required by the Python dependency. It is used to define your function's dependencies. If you do not have any, you still need to provide an empty file.
## Accepted Function Parameters
diff --git a/samples/java/cloudevents/txt-to-pdf-gradle/Makefile b/samples/java/cloudevents/txt-to-pdf-gradle/Makefile
new file mode 100644
index 00000000..da602895
--- /dev/null
+++ b/samples/java/cloudevents/txt-to-pdf-gradle/Makefile
@@ -0,0 +1,36 @@
+.PHONY: build publish deploy destroy clean
+
+FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdfjavagradle
+
+FUNCTION := out/image
+$(FUNCTION):
+ @mkdir -p $(@D)
+ pack build $(FUNCTION_IMAGE) --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=com.example.demo.DemoApplication
+ printf $(FUNCTION_IMAGE) > $@
+
+build: $(FUNCTION)
+
+publish: $(FUNCTION)
+ docker push $(shell cat $(FUNCTION))
+
+.INTERMEDIATE: $(CONFIG)
+CREDS := ./creds.yaml
+CONFIG := out/config.yaml
+$(CONFIG): $(FUNCTION) $(CREDS) $(wildcard config/*)
+ @mkdir -p $(@D)
+ ytt -f config --data-values-file $(CREDS) -v function_image="$(shell cat $(FUNCTION))" > $@
+
+config: $(CONFIG)
+
+deploy: $(CONFIG) publish
+ kapp deploy -a demo -f $(CONFIG)
+
+destroy:
+ kapp delete -a demo
+
+clean:
+ docker rmi $(FUNCTION_IMAGE)
+ rm -rf ./out/
+
+docker: $(FUNCTION)
+ docker run --env-file aws.env --rm -p 8080:8080 -e 8080 --entrypoint function $(FUNCTION_IMAGE)
diff --git a/samples/java/cloudevents/txt-to-pdf-gradle/func.yaml b/samples/java/cloudevents/txt-to-pdf-gradle/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/samples/java/cloudevents/txt-to-pdf-gradle/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/samples/java/cloudevents/txt-to-pdf-maven/Makefile b/samples/java/cloudevents/txt-to-pdf-maven/Makefile
index 8c5a0a0b..b2cbfcca 100644
--- a/samples/java/cloudevents/txt-to-pdf-maven/Makefile
+++ b/samples/java/cloudevents/txt-to-pdf-maven/Makefile
@@ -1,6 +1,6 @@
.PHONY: build publish deploy destroy clean
-FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdfjava
+FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdfjavamaven
FUNCTION := out/image
$(FUNCTION):
diff --git a/samples/java/cloudevents/txt-to-pdf-maven/spring-java-fn/func.yaml b/samples/java/cloudevents/txt-to-pdf-maven/spring-java-fn/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/samples/java/cloudevents/txt-to-pdf-maven/spring-java-fn/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/samples/java/http/request-response-gradle/Makefile b/samples/java/http/request-response-gradle/Makefile
new file mode 100644
index 00000000..7f660897
--- /dev/null
+++ b/samples/java/http/request-response-gradle/Makefile
@@ -0,0 +1,36 @@
+.PHONY: build publish deploy destroy clean
+
+FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:reqresponsejavagradle
+
+FUNCTION := out/image
+$(FUNCTION):
+ @mkdir -p $(@D)
+ pack build $(FUNCTION_IMAGE) --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=com.vmware.functions.Handler
+ printf $(FUNCTION_IMAGE) > $@
+
+build: $(FUNCTION)
+
+publish: $(FUNCTION)
+ docker push $(shell cat $(FUNCTION))
+
+.INTERMEDIATE: $(CONFIG)
+CREDS := ./creds.yaml
+CONFIG := out/config.yaml
+$(CONFIG): $(FUNCTION) $(CREDS) $(wildcard config/*)
+ @mkdir -p $(@D)
+ ytt -f config --data-values-file $(CREDS) -v function_image="$(shell cat $(FUNCTION))" > $@
+
+config: $(CONFIG)
+
+deploy: $(CONFIG) publish
+ kapp deploy -a demo -f $(CONFIG)
+
+destroy:
+ kapp delete -a demo
+
+clean:
+ docker rmi $(FUNCTION_IMAGE)
+ rm -rf ./out/
+
+docker: $(FUNCTION)
+ docker run --env-file aws.env --rm -p 8080:8080 -e 8080 --entrypoint function $(FUNCTION_IMAGE)
diff --git a/samples/java/http/request-response-gradle/func.yaml b/samples/java/http/request-response-gradle/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/samples/java/http/request-response-gradle/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/samples/java/http/request-response-maven/Makefile b/samples/java/http/request-response-maven/Makefile
new file mode 100644
index 00000000..554938de
--- /dev/null
+++ b/samples/java/http/request-response-maven/Makefile
@@ -0,0 +1,36 @@
+.PHONY: build publish deploy destroy clean
+
+FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:reqresponsejavamaven
+
+FUNCTION := out/image
+$(FUNCTION):
+ @mkdir -p $(@D)
+ pack build $(FUNCTION_IMAGE) --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=com.vmware.functions.Handler
+ printf $(FUNCTION_IMAGE) > $@
+
+build: $(FUNCTION)
+
+publish: $(FUNCTION)
+ docker push $(shell cat $(FUNCTION))
+
+.INTERMEDIATE: $(CONFIG)
+CREDS := ./creds.yaml
+CONFIG := out/config.yaml
+$(CONFIG): $(FUNCTION) $(CREDS) $(wildcard config/*)
+ @mkdir -p $(@D)
+ ytt -f config --data-values-file $(CREDS) -v function_image="$(shell cat $(FUNCTION))" > $@
+
+config: $(CONFIG)
+
+deploy: $(CONFIG) publish
+ kapp deploy -a demo -f $(CONFIG)
+
+destroy:
+ kapp delete -a demo
+
+clean:
+ docker rmi $(FUNCTION_IMAGE)
+ rm -rf ./out/
+
+docker: $(FUNCTION)
+ docker run --env-file aws.env --rm -p 8080:8080 -e 8080 --entrypoint function $(FUNCTION_IMAGE)
diff --git a/samples/java/http/request-response-maven/func.yaml b/samples/java/http/request-response-maven/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/samples/java/http/request-response-maven/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/samples/python/cloudevents/s3-lambda/README.md b/samples/python/cloudevents/s3-lambda/README.md
index f8aee1b6..3434d22b 100644
--- a/samples/python/cloudevents/s3-lambda/README.md
+++ b/samples/python/cloudevents/s3-lambda/README.md
@@ -1,6 +1,6 @@
To deploy this, first create the container with the buildpack cli
```
-pack build --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0
+pack build --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=main.main
```
Publish it to your registry:
diff --git a/samples/python/cloudevents/s3-lambda/func.yaml b/samples/python/cloudevents/s3-lambda/func.yaml
deleted file mode 100644
index 71800b36..00000000
--- a/samples/python/cloudevents/s3-lambda/func.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
diff --git a/samples/python/cloudevents/sqs-lambda/README.md b/samples/python/cloudevents/sqs-lambda/README.md
index 601ffb62..43f23449 100644
--- a/samples/python/cloudevents/sqs-lambda/README.md
+++ b/samples/python/cloudevents/sqs-lambda/README.md
@@ -64,7 +64,7 @@ The folder `knative-function-encrypter` has the function that will be listening
With docker running, build the image from this folder:
```
-pack build encrypter --path PATH/TO/knative-function-encrypter --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0
+pack build encrypter --path PATH/TO/knative-function-encrypter --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=main.main
```
Tag and push to your registry:
diff --git a/samples/python/cloudevents/sqs-lambda/knative-function-encrypter/func.yaml b/samples/python/cloudevents/sqs-lambda/knative-function-encrypter/func.yaml
deleted file mode 100644
index 71800b36..00000000
--- a/samples/python/cloudevents/sqs-lambda/knative-function-encrypter/func.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
diff --git a/samples/python/cloudevents/txt-to-pdf/Makefile b/samples/python/cloudevents/txt-to-pdf/Makefile
index bd381d3b..b1e220fb 100644
--- a/samples/python/cloudevents/txt-to-pdf/Makefile
+++ b/samples/python/cloudevents/txt-to-pdf/Makefile
@@ -5,7 +5,7 @@ FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdf
FUNCTION := out/image
$(FUNCTION): app/*
@mkdir -p $(@D)
- pack build $(FUNCTION_IMAGE) --path ./app/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0
+ pack build $(FUNCTION_IMAGE) --path ./app/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=main.main
printf $(FUNCTION_IMAGE) > $@
build: $(FUNCTION)
diff --git a/samples/python/cloudevents/txt-to-pdf/app/func.yaml b/samples/python/cloudevents/txt-to-pdf/app/func.yaml
deleted file mode 100644
index b0184a1f..00000000
--- a/samples/python/cloudevents/txt-to-pdf/app/func.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
-envs:
-- name: MODULE_NAME
- value: main
-- name: FUNCTION_NAME
- value: main
diff --git a/samples/python/http/adder/README.md b/samples/python/http/adder/README.md
index dca54452..60e72ab1 100644
--- a/samples/python/http/adder/README.md
+++ b/samples/python/http/adder/README.md
@@ -9,7 +9,7 @@ This example will take two number and add them up only if the requestor is authe
## Usage
1. We want to first build the image:
```
- pack build adder --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0
+ pack build adder --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.1.0 --env BP_FUNCTION=func.main
```
1. After the image is successfully built we can run it in docker.
diff --git a/samples/python/http/adder/func.yaml b/samples/python/http/adder/func.yaml
deleted file mode 100644
index 71800b36..00000000
--- a/samples/python/http/adder/func.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
diff --git a/templates/java/cloudevents-gradle/func.yaml b/templates/java/cloudevents-gradle/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/templates/java/cloudevents-gradle/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/templates/java/cloudevents-maven/func.yaml b/templates/java/cloudevents-maven/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/templates/java/cloudevents-maven/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/templates/java/http-gradle/func.yaml b/templates/java/http-gradle/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/templates/java/http-gradle/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/templates/java/http-maven/func.yaml b/templates/java/http-maven/func.yaml
deleted file mode 100644
index 7d354241..00000000
--- a/templates/java/http-maven/func.yaml
+++ /dev/null
@@ -1,3 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
diff --git a/templates/python/cloudevents/func.yaml b/templates/python/cloudevents/func.yaml
deleted file mode 100644
index 52b1c339..00000000
--- a/templates/python/cloudevents/func.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
-envs:
-- name: MODULE_NAME
- value: func
-- name: FUNCTION_NAME
- value: main
diff --git a/templates/python/http/func.yaml b/templates/python/http/func.yaml
deleted file mode 100644
index 52b1c339..00000000
--- a/templates/python/http/func.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2021-2022 VMware, Inc.
-# SPDX-License-Identifier: BSD-2-Clause
-
-envs:
-- name: MODULE_NAME
- value: func
-- name: FUNCTION_NAME
- value: main
diff --git a/tests/testdata/template_and_smoke/template-ce/Makefile b/tests/testdata/template_and_smoke/template-ce/Makefile
index 9b4b12ad..197e2081 100644
--- a/tests/testdata/template_and_smoke/template-ce/Makefile
+++ b/tests/testdata/template_and_smoke/template-ce/Makefile
@@ -7,14 +7,17 @@ template-ce.path := $(abspath $(path))
$(eval $(call INCLUDE_FILE, $(ROOT_DIR)/builder))
template-ce.image := kn-fn-test/template-ce
-template-ce.image_paths := $(shell find $(template-ce.path) -mindepth 1 -maxdepth 1 -type l)
-$(template-ce.image_paths): $(PACK) $(builder.image.out)
- cd $@ && $(PACK) build $(template-ce.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --pull-policy if-not-present --clear-cache
+template-ce.java_image_paths := $(shell find $(template-ce.path) -mindepth 1 -maxdepth 1 -type l | grep java-)
+template-ce.python_image_paths := $(shell find $(template-ce.path) -mindepth 1 -maxdepth 1 -type l | grep python-)
+$(template-ce.java_image_paths): $(PACK) $(builder.image.out)
+ cd $@ && $(PACK) build $(template-ce.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --env BP_FUNCTION=functions.Handler --pull-policy if-not-present --clear-cache
+$(template-ce.python_image_paths): $(PACK) $(builder.image.out)
+ cd $@ && $(PACK) build $(template-ce.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --env BP_FUNCTION=func.main --pull-policy if-not-present --clear-cache
template-ce.clean := $(addsuffix .clean,$(template-ce.image_paths))
$(template-ce.clean):
-docker rmi -f $(template-ce.image):$(basename $(notdir $@))
.PHONY: template-tests.images
-template-tests.images .PHONY: $(template-ce.image_paths)
+template-tests.images .PHONY: $(template-ce.java_image_paths) $(template-ce.python_image_paths)
clean .PHONY: $(template-ce.clean)
diff --git a/tests/testdata/template_and_smoke/template-http/Makefile b/tests/testdata/template_and_smoke/template-http/Makefile
index 779b3141..817a17d7 100644
--- a/tests/testdata/template_and_smoke/template-http/Makefile
+++ b/tests/testdata/template_and_smoke/template-http/Makefile
@@ -7,14 +7,17 @@ template-http.path := $(abspath $(path))
$(eval $(call INCLUDE_FILE, $(ROOT_DIR)/builder))
template-http.image := kn-fn-test/template-http
-template-http.image_paths := $(shell find $(template-http.path) -mindepth 1 -maxdepth 1 -type l)
-$(template-http.image_paths): $(PACK) $(builder.image.out)
- cd $@ && $(PACK) build $(template-http.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --pull-policy if-not-present --clear-cache
+template-http.java_image_paths := $(shell find $(template-http.path) -mindepth 1 -maxdepth 1 -type l | grep java-)
+template-http.python_image_paths := $(shell find $(template-http.path) -mindepth 1 -maxdepth 1 -type l | grep python-)
+$(template-http.java_image_paths): $(PACK) $(builder.image.out)
+ cd $@ && $(PACK) build $(template-http.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --env BP_FUNCTION=functions.Handler --pull-policy if-not-present --clear-cache
+$(template-http.python_image_paths): $(PACK) $(builder.image.out)
+ cd $@ && $(PACK) build $(template-http.image):$(notdir $@) --builder $(shell cat $(builder.image.out)) --env BP_FUNCTION=func.main --pull-policy if-not-present --clear-cache
template-http.clean := $(addsuffix .clean,$(template-http.image_paths))
$(template-http.clean):
-docker rmi -f $(template-http.image):$(basename $(notdir $@))
.PHONY: template-tests.images
-template-tests.images .PHONY: $(template-http.image_paths)
+template-tests.images .PHONY: $(template-http.java_image_paths) $(template-http.python_image_paths)
clean .PHONY: $(template-http.clean)