Skip to content
This repository was archived by the owner on Oct 25, 2023. It is now read-only.

Commit b100e9f

Browse files
author
Rodolfo Sanchez
authored
Merge pull request #90 from vmware-tanzu/feat/delete-func-name-java
2 parents a56d291 + 3c7276c commit b100e9f

File tree

6 files changed

+3
-32
lines changed

6 files changed

+3
-32
lines changed

buildpacks/java/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ The buildpack will do the following if detection passed:
1818
| Environment Variable | Description |
1919
|----------------------|-------------|
2020
| `$BP_FUNCTION` | Configure the function to load. If the function lives in the default package: `<class>`. If the function lives in their own package: `<package>.<class>`. Defaults to `functions.Handler` |
21-
| `$BP_DEFAULT_FUNCTION` | Configure the default function. By specifying this property, a function with the name can be accessed via the `/` path. Defaults to empty. |
2221

2322
## Getting started
2423
To get started you'll need to create a directory where your function will be defined.

buildpacks/java/java/build.go

-2
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) {
4949
}
5050

5151
functionClass, isFuncDefDefault := cr.Resolve("BP_FUNCTION")
52-
defaultDef, isDefaultFuncDefault := cr.Resolve("BP_DEFAULT_FUNCTION")
5352

5453
functionLayer := NewFunction(context.Application.Path,
5554
WithLogger(b.Logger),
5655
WithFunctionClass(functionClass, isFuncDefDefault),
57-
WithDefaultFunction(defaultDef, isDefaultFuncDefault),
5856
WithFuncYamlEnvs(e.Metadata["func_yaml_envs"].(map[string]interface{})),
5957
)
6058
result.Layers = append(result.Layers, functionLayer)

buildpacks/java/java/detect.go

-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ func (d Detect) checkConfigs(cr libpak.ConfigurationResolver) bool {
2020
return true
2121
}
2222

23-
if _, defined := cr.Resolve("BP_DEFAULT_FUNCTION"); defined {
24-
return true
25-
}
26-
2723
return false
2824
}
2925

buildpacks/java/java/function.go

-18
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ func (f Function) Contribute(layer libcnb.Layer) (libcnb.Layer, error) {
5959
layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_FUNCTION_CLASS", f.functionClass)
6060
}
6161

62-
if len(f.defaultFunctionName) > 0 {
63-
if f.overrideDefaultFunctionName {
64-
layer.LaunchEnvironment.Override("SPRING_CLOUD_FUNCTION_DEFINITION", f.defaultFunctionName)
65-
} else {
66-
layer.LaunchEnvironment.Default("SPRING_CLOUD_FUNCTION_DEFINITION", f.defaultFunctionName)
67-
}
68-
}
69-
7062
for envName, envValue := range f.funcYamlEnvs {
7163
layer.LaunchEnvironment.Default(envName, envValue)
7264
}
@@ -88,16 +80,6 @@ func WithLogger(logger bard.Logger) FunctionOpt {
8880
}
8981
}
9082

91-
func WithDefaultFunction(defaultFunctionName string, override bool) FunctionOpt {
92-
return func(fun *Function, metadata map[string]string) {
93-
fun.defaultFunctionName = defaultFunctionName
94-
fun.overrideDefaultFunctionName = override
95-
96-
metadata["bp-default-function"] = defaultFunctionName
97-
metadata["bp-default-function-override"] = strconv.FormatBool(override)
98-
}
99-
}
100-
10183
func WithFunctionClass(functionClass string, override bool) FunctionOpt {
10284
return func(fun *Function, metadata map[string]string) {
10385
fun.functionClass = functionClass

buildpacks/java/ytt/buildpack.yaml

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,4 @@ metadata:
2525
default: functions.Handler
2626
description: The function to run. It must be in the format of <package>.<class>, if it is in the default package then just <class>
2727
name: BP_FUNCTION
28-
- build: true
29-
default: ""
30-
description: "The default function name. In the event there are multiple functions. Specifying the name of the function will make it accessible through the root path '/'"
31-
name: "BP_DEFAULT_FUNCTION"
32-
dependencies: []
28+
dependencies: []

samples/java/cloudevents/txt-to-pdf-maven/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FUNCTION_IMAGE ?= us.gcr.io/daisy-284300/functions/demo:txttopdfjava
55
FUNCTION := out/image
66
$(FUNCTION):
77
@mkdir -p $(@D)
8-
pack build $(FUNCTION_IMAGE) --path ./spring-java-fn/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.0.10 --env BP_FUNCTION=com.example.demo.DemoApplication --env BP_DEFAULT_FUNCTION=func
8+
pack build $(FUNCTION_IMAGE) --path ./spring-java-fn/ --builder ghcr.io/vmware-tanzu/function-buildpacks-for-knative/functions-builder:0.0.10 --env BP_FUNCTION=com.example.demo.DemoApplication
99
printf $(FUNCTION_IMAGE) > $@
1010

1111
build: $(FUNCTION)
@@ -33,4 +33,4 @@ clean:
3333
rm -rf ./out/
3434

3535
docker: $(FUNCTION)
36-
docker run --env-file aws.env --rm -p 8080:8080 -e 8080 --entrypoint function $(FUNCTION_IMAGE)
36+
docker run --env-file aws.env --rm -p 8080:8080 -e 8080 --entrypoint function $(FUNCTION_IMAGE)

0 commit comments

Comments
 (0)