Skip to content

Commit

Permalink
pre-allocate diag error accumulator slice
Browse files Browse the repository at this point in the history
Signed-off-by: Erhan Cagirici <erhan@upbound.io>
  • Loading branch information
erhancagirici committed Jan 30, 2024
1 parent 13e848e commit 25e29bd
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/controller/external_terraform_plugin_framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,9 @@ func getFatalDiagnostics(diags []*tfprotov5.Diagnostic) error {
}

func frameworkDiagnosticsToString(fwdiags fwdiag.Diagnostics) string {
var diagErrors []string
for _, tfdiag := range fwdiags.Errors() {
frameworkErrorDiags := fwdiags.Errors()
diagErrors := make([]string, 0, len(frameworkErrorDiags))
for _, tfdiag := range frameworkErrorDiags {
diagErrors = append(diagErrors, fmt.Sprintf("%s: %s", tfdiag.Summary(), tfdiag.Detail()))
}
return strings.Join(diagErrors, "\n")
Expand Down

0 comments on commit 25e29bd

Please sign in to comment.