Skip to content

Conversation

@yuwenma
Copy link
Contributor

@yuwenma yuwenma commented Oct 6, 2022

This PR depends on #631

  • Change the panic style code flow control. Use specific errors
  • Propagate the KubeObject GVK to SubObject; track fieldspec paths. This will give users very helpful message to target the problematic KRM resource. TODO: include names, namespace.
  • Add NestedResource, NestedInt64 and deprecate the Get methods. Get can be overused and cause inefficiency of KRM function editing. we should not encourage such pattern
  • Delete all NestedXXOrDie and SetNestedXXXOrDie functions. Update the return error with the specific KRM resource GVK and field paths.

@yuwenma yuwenma force-pushed the no-or-die branch 4 times, most recently from e89de98 to 5de5ada Compare October 7, 2022 18:39
Copy link

@droot droot left a comment

Choose a reason for hiding this comment

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

Looks good.

Copy link
Contributor

@natasha41575 natasha41575 left a comment

Choose a reason for hiding this comment

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

lgtm, small nit

go/fn/errors.go Outdated
func (e *ErrInternalAnnotation) Error() string {
return e.Message
}
func NewErrUnmatchedField(obj SubObject, fields []string, dt any) *ErrUnmatchedField {
Copy link
Contributor

@natasha41575 natasha41575 Oct 7, 2022

Choose a reason for hiding this comment

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

nit: Should this have a doc comment, and the below ErrUnmatchedField type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. also changed the arg dt to expectedFieldType

@yuwenma yuwenma force-pushed the no-or-die branch 5 times, most recently from 0dca0a9 to b89ad53 Compare October 7, 2022 21:06
- Avoid panic style error handling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants