Skip to content
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

Merged
merged 3 commits into from
Nov 25, 2020
Merged

Conversation

muvaf
Copy link
Contributor

@muvaf muvaf commented Nov 13, 2020

Description of changes: This PR adds a new ignore rule to Config object where users can define which specific field they want to ignore, like CreateApiInput.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.

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{}
Copy link
Contributor Author

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.

}
}
}
}
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

@jaypipes jaypipes left a 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

@jaypipes jaypipes merged commit 23e1073 into aws-controllers-k8s:main Nov 25, 2020
@muvaf muvaf deleted the ignore-more branch November 25, 2020 21:19
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.

Ability to ignore specific fields in the API
2 participants