Skip to content

handle custom templates #671

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 7 additions & 15 deletions base-java/ub/ub.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,17 @@ func path(filePath string, operation string) (bool, error) {
}

func renderTemplate(templateFilePath string) error {
// Define a function map to handle custom template functions
Copy link
Preview

Copilot AI Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated renderTemplate function no longer parses the template file or returns a value, which could result in runtime errors. Please restore the parsing logic and a return statement to ensure the function completes its intended operation.

Copilot uses AI. Check for mistakes.

funcs := template.FuncMap{
"getEnv": getEnvOrDefault,
"splitToMapDefaults": splitToMapDefaults,
}
t, err := template.New(pt.Base(templateFilePath)).Funcs(funcs).ParseFiles(templateFilePath)
if err != nil {
err = fmt.Errorf("error %q: %w", templateFilePath, err)
return err
}
return buildTemplate(os.Stdout, *t)
}

func buildTemplate(writer io.Writer, template template.Template) error {
err := template.Execute(writer, GetEnvironment())
if err != nil {
func buildTemplate(writer io.Writer, template template.Template) error{
err := template.Execute(writer, GetEnvironment())
if err != nil{
err = fmt.Errorf("error building template file : %w", err)
return err
}
return nil
return nil
}
}
}

func renderConfig(writer io.Writer, configSpec ConfigSpec) error {
Expand Down