-
Notifications
You must be signed in to change notification settings - Fork 262
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
Add FieldPaths to ignore rules #501
Conversation
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
fields of some operations are ignored. Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@@ -403,51 +403,51 @@ func TestRDS_DBInstance(t *testing.T) { | |||
ko.Status.DBParameterGroups = f14 | |||
} | |||
if resp.DBInstance.DBSubnetGroup != nil { | |||
f16 := &svcapitypes.DBSubnetGroup_SDK{} | |||
f15 := &svcapitypes.DBSubnetGroup_SDK{} |
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.
The numbers are shifted since the shape is not considered at all during the count, hence the diff here is no-op.
} | ||
} | ||
} | ||
} |
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.
I'm actually not sure how I feel about this. In one sense, it's nice that removing the shapes and members in one place enables you to remove a bunch of "ignore this" conditionals. On the other hand, I did actually like being able to correlate the number in the generated variable names to the 0-based index of the field within a Shape.
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.
Hmm I haven't really paid much attention to the numbers in the generated variable names. But if it's something that's useful when it's consistent with the 0-based index in some context, I can have a function similar to this to be called in place of IsIgnoredShape
.
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.
chatted with @muvaf about this. I'm good with this simpler approach for now. just need to keep an eye on weird edge cases in future
Description of changes: This PR adds a new ignore rule to
Config
object where users can define which specific field they want to ignore, likeCreateApiInput.Name
. It also moves the shape ignore rule to the same function that is run only once during the beginning.Tested this with APIGatewayv2 resources generated here.
This is necessary for Crossplane code generation where we need to ignore the field we use external-name annotation for and the fields that are required but could be referenced; those fields should be marked as non-required since they could be fulfilled by the controller after reference resolution. For the referenced fields, we could possibly have another config rule where we can point the fields that can be referenced and use that information to generate the two additional fields (
*Ref
and*Selector
fields) but I'd like to defer that to another PR. Ignoring field paths is necessary for external-name annotation anyway.Fixes #510
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.