Skip to content

Refactor reference resolution into Go code #417

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

Merged
merged 16 commits into from
Feb 16, 2023

Conversation

RedbackThomson
Copy link
Contributor

Continuation of #401

Refactors the resolveReferenceFor<Field> Go template code into direct Go code. This way we can be more intelligent about nested field references and support unit testing its output.

Breaking change:
The previous Go template produced valid, but ultimately faulty, code for references within lists of structs. These are not supported (see aws-controllers-k8s/community#1291). As such, this update produces a panic when it detects those types of references.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and vijtrip2 February 13, 2023 20:51
@ack-prow
Copy link

ack-prow bot commented Feb 13, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RedbackThomson

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot added the approved label Feb 13, 2023
@RedbackThomson RedbackThomson requested review from jljaco and removed request for vijtrip2 February 13, 2023 20:53
@RedbackThomson
Copy link
Contributor Author

/test iam-controller-test
/test lambda-controller-test

@RedbackThomson
Copy link
Contributor Author

I expect that ec2-controller fails the integration tests, since it unfortunately uses structs with references within lists - which is a known error condition for references. aws-controllers-k8s/community#1291

This pull request puts a panic condition in, so that no new controllers can add fields before this condition is possible.

@RedbackThomson
Copy link
Contributor Author

All 3 test failures of the IAM controller are due to missing policy ARNs - unrelated to these changes but worthy of an investigation.

All the failures of the Lambda controller are within the TestEventSourceMapping class, none of which seem to be related to these changes either. There are other tests for references that are still passing.

@a-hilaly
Copy link
Member

All 3 test failures of the IAM controller are due to missing policy ARNs - unrelated to these changes but worthy of an investigation.
All the failures of the Lambda controller are within the TestEventSourceMapping class, none of which seem to be related to these changes either. There are other tests for references that are still passing.

Regarding IAM, tests are not failing in this PR @RedbackThomson maybe let's test with one commit earlier? #394

@RedbackThomson
Copy link
Contributor Author

Regarding IAM, tests are not failing in this PR @RedbackThomson maybe let's test with one commit earlier? #394

You were right to suspect this. Thank you for pointing out that we were overwriting the ko.Spec.Policies list even if there were no references - always leading to an empty policy list. I have replaced it with a length check for the references slice, so that if there are no references, then nothing will change. I have also updated the code to put the resolved references into a new string slice and then only apply it to the spec if there are no errors.

@ack-prow
Copy link

ack-prow bot commented Feb 15, 2023

@RedbackThomson: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ec2-controller-test c2635c9 link true /test ec2-controller-test

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.

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

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

Nice and neat!

Comment on lines +72 to +74
"Nil": func() interface{} {
return nil
},
Copy link
Member

Choose a reason for hiding this comment

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

Interesting how this is returning an interface{} and plays well with AddToMap

@a-hilaly
Copy link
Member

/lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants