-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update presign post URL resolution to use the exact result from Endpo…
…intResolverV2 (#2842) * Update presign post URL resolution to use the exact result from EndpointResolverV2
- Loading branch information
Showing
7 changed files
with
131 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "5702f383-099a-47a5-860f-5ab25cda67a1", | ||
"type": "bugfix", | ||
"description": "Update presign post URL resolution to use the exact result from EndpointResolverV2", | ||
"modules": [ | ||
"service/s3" | ||
] | ||
} |
42 changes: 42 additions & 0 deletions
42
...rc/main/java/software/amazon/smithy/aws/go/codegen/customization/s3/StoreResolvedUri.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.smithy.aws.go.codegen.customization.s3; | ||
|
||
import software.amazon.smithy.aws.go.codegen.AwsGoDependency; | ||
import software.amazon.smithy.aws.go.codegen.customization.S3ModelUtils; | ||
import software.amazon.smithy.go.codegen.GoSettings; | ||
import software.amazon.smithy.go.codegen.GoWriter; | ||
import software.amazon.smithy.go.codegen.integration.GoIntegration; | ||
import software.amazon.smithy.model.Model; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Stores the endpoint resolved by EndpointResolverV2 | ||
*/ | ||
public class StoreResolvedUri implements GoIntegration { | ||
@Override | ||
public void renderPostEndpointResolutionHook(GoSettings settings, GoWriter writer, Model model) { | ||
if (!S3ModelUtils.isServiceS3(model, settings.getService(model))) return; | ||
writer.writeGoTemplate( | ||
""" | ||
ctx = $setFunc:L(ctx, endpt.URI.String()) | ||
""", | ||
Map.of( | ||
"setFunc", "setS3ResolvedURI") | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package s3 | ||
|
||
// This contains helper methods to set resolver URI into the context object. If they are ever used for | ||
// something other than S3, they should be moved to internal/context/context.go | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/smithy-go/middleware" | ||
) | ||
|
||
type s3resolvedURI struct{} | ||
|
||
// setS3ResolvedURI sets the URI as resolved by the EndpointResolverV2 | ||
func setS3ResolvedURI(ctx context.Context, value string) context.Context { | ||
return middleware.WithStackValue(ctx, s3resolvedURI{}, value) | ||
} | ||
|
||
// getS3ResolvedURI gets the URI as resolved by EndpointResolverV2 | ||
func getS3ResolvedURI(ctx context.Context) string { | ||
v, _ := middleware.GetStackValue(ctx, s3resolvedURI{}).(string) | ||
return v | ||
} |