-
Notifications
You must be signed in to change notification settings - Fork 219
feat: return error on missing required fields #613
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
base: main
Are you sure you want to change the base?
feat: return error on missing required fields #613
Conversation
/retest |
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.
noice! thanks @michaelhtm
pkg/generate/code/set_resource.go
Outdated
@@ -847,6 +847,7 @@ func identifierNameOrIDGuardConstructor( | |||
// return ackerrors.MissingNameIdentifier | |||
// } | |||
func requiredFieldGuardContructor( | |||
holdingVar 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.
what does holdingVar mean? does it need to be the first param?
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.
yes, it's just the var name for the requiredKey..
@@ -847,6 +847,7 @@ func identifierNameOrIDGuardConstructor( | |||
// return ackerrors.MissingNameIdentifier | |||
// } |
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.
maybe this comment needs to be updated?
pkg/generate/code/set_resource.go
Outdated
// The variable used for primary key | ||
requiredFieldVarName 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.
is this variable needed a this level? doc updates?
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.
yes, we construct it inside the PopulateResourceFromAnnotation, where we find out if a field is a primary key or it's just a required field.
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.
doc updates?
831f5ac
to
5e72da5
Compare
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.
Q: Is a field being required always a field we need to adopt a resource? It seems like a field could be considered required to create/update a resource, but not necessarily to identify it.
During resource Adoption, the ACK controllers only returned an error when there was a missing PrimaryKey. If a Resource requires more than 1 field to describe a Resource (eg. Lambda alias requires Name and FunctionName), the controller only verifies the Primary identifier (ARN, ID, Name) and nothing else. With this change, we look into the SDK model to retrieve the required fields and return an error if all are not defined during `PopulateResourceFromAnnotation`
5e72da5
to
6f0d5cd
Compare
// if !ok { | ||
// return ackerrors.MissingNameIdentifier |
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.
how about return ackerrors.MissingNameIdentifier(fieldNames...)
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.
So for a longtime this wasn't considered a terminal error?
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.
MissingNameIdentifier is an error introduced by SetIdentifiers (Adopted CRD). It was mainly used when NameOrID was nil.
This error message fix was introduced here
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.
@michaelhtm thanks for resolving my. Holding of on lgtm so that @a-hilaly can verify that their comments have been resolved.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: knottnt, michaelhtm The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
@michaelhtm: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Issue #2557
Description of changes:
During resource Adoption, the ACK controllers only returned an error
when there was a missing PrimaryKey. If a Resource requires more than 1
field to describe a Resource (eg. Lambda alias requires Name and
FunctionName), the controller only verifies the Primary identifier (ARN,
ID, Name) and nothing else.
With this change, we look into the SDK model to retrieve the required
fields and return an error if all are not defined during
PopulateResourceFromAnnotation
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.