-
Notifications
You must be signed in to change notification settings - Fork 8
feat: read func classname from the func.yaml file #86
Conversation
@dolfolife, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
I still do not know what could be the best path from config -> to build parameters, but I am happy to discuss |
buildpacks/java/java/build.go
Outdated
@@ -53,7 +53,7 @@ func (b Build) Build(context libcnb.BuildContext) (libcnb.BuildResult, error) { | |||
|
|||
functionLayer := NewFunction(context.Application.Path, | |||
WithLogger(b.Logger), | |||
WithFunctionClass(functionClass, isFuncDefDefault), | |||
WithFunctionClass(functionClass, isFuncDefDefault, e.Metadata["func_yaml_function_name"].(string)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you want here is to make func_yaml_function_name
to be the default function if it's not empty and isDefaultFuncDefault
is false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noticed I mis-named those variables isFuncDefDefault
and isDefaultFuncDefault
.
They should have been isFuncDefDefined
and isDefaultFuncDefined
.
cr.resolve
returns whether it was explicitly set or not. (false
== user did not set the value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well you want that variable if the ENV is not set, right? the order of precedence is environment -> config -> default
and roger to the isFuncDefault
I got confused by the variable name and I did not understand what it was.
buildpacks/java/tests/detect_test.go
Outdated
func withModuleName(value string) func(*libcnb.DetectContext) { | ||
return func(dc *libcnb.DetectContext) { | ||
dc.Platform.Environment["MODULE_NAME"] = value | ||
} | ||
} | ||
|
||
func withFunctionName(value string) func(*libcnb.DetectContext) { | ||
return func(dc *libcnb.DetectContext) { | ||
dc.Platform.Environment["FUNCTION_NAME"] = value | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are only relevant to Python
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, the only way in Java
to set the function name is with BP_FUNCTION
or the Spring property?
buildpacks/java/java/detect.go
Outdated
"func_yaml_options": funcYaml.Options, | ||
"launch": true, | ||
"func_yaml_envs": funcYaml.Envs, | ||
"func_yaml_function_name": funcYaml.Name, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would prefer it to just be func_yaml_name
to match the other keys better, as you store it in the struct as Name
and the getter is getName
.
buildpacks/java/java/func_yaml.go
Outdated
@@ -34,14 +35,33 @@ func ParseFuncYaml(filedir string, logger bard.Logger) FuncYaml { | |||
|
|||
options := optionsToMap(cfg.Options, logger) | |||
envs := envsToMap(cfg.Envs, logger) | |||
|
|||
name := getName(cfg.Envs, cfg.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would cfg.Name
be cleaner to get the name instead of iterating through cfg.Envs
? https://pkg.go.dev/knative.dev/kn-plugin-func#Function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to just using cfg.Name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a confusion that I think I have :) where there is an env variable that can be set as the name of the function and that would take precedence over the cfg.Name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cfg
pulls from func.yaml
though, while that env variable is a Python thing
buildpacks/java/java/func_yaml.go
Outdated
|
||
for _, e := range envs { | ||
key := *e.Name | ||
if key == "FUNCTION_NAME" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java doesn't make use of this environment variable, only the python invoker does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this framework-related logic? should we abstract it?
@dolfolife, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
@dolfolife, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
1 similar comment
@dolfolife, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
Signed-off-by: Rodolfo Sanchez <[email protected]>
bec819f
to
658bdb4
Compare
@dolfolife, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding
|
@dolfolife Has this gone stale or should it be merged in still? |
fixes #85
Signed-off-by: Rodolfo Sanchez [email protected]