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

Use code-generated endpoint rules for all services, and remove the customization. #5410

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

millems
Copy link
Contributor

@millems millems commented Jul 18, 2024

Additional necessary changes to facilitate this:

  1. Fixed an issue where any region parameter was assumed to be the endpoint region. The fix also removes the region as a local variable and instead relies on reading the region from the parameters. A "{name}Id" method has been added to the endpoint and auth resolver's region parameters, which allows readingthe region ID as a string.
  2. Removed "auth scheme strategy" classes from code generated to just being in S3, because they're not used anywhere else, now. In the future, it would be nice to simplify this S3 logic.

This PR is split between the customization.config cleanups, and the codegen changes, to hopefully simplify the review.

millems added 2 commits July 18, 2024 10:38
…stomization.

Additional necessary changes to facilitate this:
1. Fixed an issue where any region parameter was assumed to be the endpoint region. The fix also removes the region as a local variable and instead relies on reading the region from the parameters. A "{name}Id" method has been added to the endpoint and auth resolver's region parameters, which allows readingthe region ID as a string.
2. Removed "auth scheme strategy" classes from code generated to just being in S3, because they're not used anywhere else, now. In the future, it would be nice to simplify this S3 logic.
@millems millems requested a review from a team as a code owner July 18, 2024 17:44
import software.amazon.awssdk.utils.CompletableFutureUtils;
import software.amazon.awssdk.utils.Logger;
import software.amazon.awssdk.utils.Validate;

public class EndpointProviderSpec implements ClassSpec {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like there are a lot of changes here, but this is actually just EndpointProviderSpec2, which has already been code reviewed and is listed as a deletion below. You can skip reviewing this class if you want, since it wasn't changed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it wasnt merged in ? Would be great if you could provide a PR link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

got it thanks

* permissions and limitations under the License.
*/

package software.amazon.awssdk.services.s3.endpoints.internal;
Copy link
Contributor Author

@millems millems Jul 18, 2024

Choose a reason for hiding this comment

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

These s3.endpoints.internal files look new, but they are just copies of the .java.resource files that used to be code generated. I just copied them into S3 because this is the only service that uses them.

You can skip reviewing these files if you want, because they were already reviewed. I didn't change them.

@millems millems enabled auto-merge (squash) July 18, 2024 17:56

SymbolTable(Builder builder) {
this.params = Collections.unmodifiableMap(new LinkedHashMap<>(builder.params));
this.locals = Collections.unmodifiableMap(new LinkedHashMap<>(builder.locals));
this.regionParamName = builder.regionParamName;
this.builtInParamTypes = Collections.unmodifiableMap(new LinkedHashMap<>(builder.builtInParamTypes));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need the overhead of maintaining a list with the LinkedHashMap ? I do not see us needing element ordering here in this class. Could we just do HashMap instead ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems reasonable. Let me see if there's any tests that assume order.

.forEach((k, v) -> {
b.property(k, Value.fromNode(v));
});
.forEach((k, v) -> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want indentation changes like these to go through ? Feels like we have a lot to indent if we start looking into our entire codebase. Would it be better to leave them as they are ? It also shows up in the "git blame" section

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It just did that since it was a copy+paste of code, which reformats things automatically in Intellij. I didn't do it intentionally. I can try to revert these types of changes. Hopefully I don't miss any.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually don't need all of these files! I've deleted a lot of them.

.map(Arn::accountId)
.orElse(null);
RuleArn arn = RuleArn.parse(assumedRoleUser.arn());
if (arn == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit : would be great to extract this into a method arnAccountId(RuleArn arn);

RuleArn arn = RuleArn.parse(assumedRoleUser.arn()); //or
RuleArn arn = RuleArn.parse(federatedUser.arn());

return arnAccountId(RuleArn arn);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since they're in different classes (so the code is harder to share) and there's only 2 places it's done like this (so the rule of three isn't satisfied), I'd usually leave it like this. I don't feel strongly about it, though, so LMK if you'd prefer it to be shared. I'd probably do a convenience method on RuleArn, like RuleArn.accountId(arn).

@millems millems disabled auto-merge July 22, 2024 20:46
@millems millems enabled auto-merge (squash) July 22, 2024 21:46
@millems millems disabled auto-merge July 23, 2024 15:22
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
59.4% Coverage on New Code (required ≥ 80%)
5.7% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

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.

2 participants