Skip to content

Commit

Permalink
Fix host prefix bug (#2200)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaiahvita authored Jul 21, 2023
1 parent 44a1c7e commit b799b27
Show file tree
Hide file tree
Showing 230 changed files with 668 additions and 941 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import software.amazon.smithy.go.codegen.SymbolUtils;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.shapes.OperationShape;
import software.amazon.smithy.model.shapes.ServiceShape;


Expand All @@ -36,7 +37,9 @@
public class AwsEndpointAuthSchemeGenerator implements GoIntegration {

@Override
public void renderPostEndpointResolutionHook(GoSettings settings, GoWriter writer, Model model) {
public void renderPostEndpointResolutionHook(
GoSettings settings, GoWriter writer, Model model, Optional<OperationShape> operation
) {
ServiceShape serviceShape = settings.getService(model);
writer.write(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class EndpointDisableHttps implements GoIntegration {

private final List<RuntimeClientPlugin> runtimeClientPlugins = new ArrayList<>();

public static final String MIDDLEWARE_ID = "EndpointDisableHTTPSMiddleware";
public static final String MIDDLEWARE_ID = "endpointDisableHTTPSMiddleware";
public static final String MIDDLEWARE_ADDER = String.format("add%s", MIDDLEWARE_ID);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class LegacyEndpointContextSetter implements GoIntegration {

private final List<RuntimeClientPlugin> runtimeClientPlugins = new ArrayList<>();

public static final String MIDDLEWARE_ID = "LegacyEndpointContextSetter";
public static final String MIDDLEWARE_ID = "legacyEndpointContextSetter";
public static final String MIDDLEWARE_ADDER = String.format("add%s", MIDDLEWARE_ID);

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,45 @@
package software.amazon.smithy.aws.go.codegen.customization;

import java.util.Optional;


import software.amazon.smithy.go.codegen.GoSettings;
import software.amazon.smithy.go.codegen.GoWriter;
import software.amazon.smithy.go.codegen.SmithyGoDependency;
import software.amazon.smithy.go.codegen.SymbolUtils;
import software.amazon.smithy.go.codegen.integration.GoIntegration;
import software.amazon.smithy.model.Model;
import software.amazon.smithy.model.pattern.SmithyPattern.Segment;
import software.amazon.smithy.model.traits.EndpointTrait;
import software.amazon.smithy.model.shapes.OperationShape;


public class DisableEndpointHostPrefix implements GoIntegration {
@Override
public void renderPostEndpointResolutionHook(GoSettings settings, GoWriter writer, Model model) {
writer.write(
"""
ctx = $T(ctx, true)
""",
SymbolUtils.createPointableSymbolBuilder("DisableEndpointHostPrefix", SmithyGoDependency.SMITHY_HTTP_TRANSPORT).build()
);
public void renderPostEndpointResolutionHook(
GoSettings settings, GoWriter writer, Model model, Optional<OperationShape> operation
) {
if (!S3ModelUtils.isServiceS3Control(model, settings.getService(model))) {
return;
}

if (operation.isPresent() && operation.get().getTrait(EndpointTrait.class).isPresent()) {
EndpointTrait endpointTrait = operation.get().getTrait(EndpointTrait.class).get();
boolean written = false;
for (Segment segment : endpointTrait.getHostPrefix().getLabels()) {
if (segment.isLabel() && segment.getContent().equals("AccountId") && !written) {
writer.write(
"""
ctx = $T(ctx, true)
""",
SymbolUtils.createPointableSymbolBuilder(
"DisableEndpointHostPrefix", SmithyGoDependency.SMITHY_HTTP_TRANSPORT).build()
);
// we only want the content above written ONCE per operation.
written = true;
}
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ software.amazon.smithy.aws.go.codegen.AwsEndpointResolverInitializerGenerator
software.amazon.smithy.aws.go.codegen.AwsEndpointResolverBuiltInGenerator
software.amazon.smithy.aws.go.codegen.customization.S3HttpPathBucketFilterIntegration
software.amazon.smithy.aws.go.codegen.customization.S3HttpLabelBucketFilterIntegration
software.amazon.smithy.aws.go.codegen.customization.DisableEndpointHostPrefix
software.amazon.smithy.aws.go.codegen.AwsEndpointAuthSchemeGenerator
software.amazon.smithy.aws.go.codegen.EndpointDisableHttps
software.amazon.smithy.aws.go.codegen.customization.S3Bucketer
software.amazon.smithy.aws.go.codegen.customization.S3SerializeImmutableHostnameBucket
software.amazon.smithy.aws.go.codegen.customization.S3UpdateOutpostArn
software.amazon.smithy.aws.go.codegen.LegacyEndpointContextSetter
software.amazon.smithy.aws.go.codegen.customization.DisableEndpointHostPrefix

24 changes: 12 additions & 12 deletions service/eventbridge/api_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_ActivateEventSource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CancelReplay.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreateApiDestination.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreateArchive.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreateConnection.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreateEndpoint.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreateEventBus.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions service/eventbridge/api_op_CreatePartnerEventSource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b799b27

Please sign in to comment.