Skip to content

Commit

Permalink
Logging resource generator errors to make debugging issues easier.
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofferahl committed Dec 7, 2022
1 parent f4f41b5 commit 00c4070
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion internal/pkg/tenant/resource_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ func (e *GenerateError) Error() string {
return fmt.Sprintf("failed to generate resources from blueprint, encountered %d error(s)", len(e.Errors))
}

func (e *GenerateError) ErrorMessages() []string {
errors := make([]string, 0)
for i, err := range e.Errors {
errors = append(errors, fmt.Sprintf("%d) %s ;", i+1, err.Error()))
}
return errors
}

type sum struct {
BlueprintName string
Resources []resourceSum
Expand Down Expand Up @@ -128,9 +136,11 @@ func (r *ResourceGenerator) Generate(state State, blueprint corev1alpha1.Bluepri
}

if len(errors) > 0 {
err = &GenerateError{
ge := &GenerateError{
Errors: errors,
}
r.ctx.Log.V(1).Info(ge.Error(), "errors", ge.ErrorMessages())
err = ge
}

return result, err
Expand Down

0 comments on commit 00c4070

Please sign in to comment.