Skip to content

Commit

Permalink
Merge branch 'main' into feat-protocol-test-2
Browse files Browse the repository at this point in the history
Sync main into current branch
.
  • Loading branch information
Tianyi Wang committed Aug 16, 2023
2 parents c981668 + 4682b6a commit d0122b9
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changelog/7c8973c1e65d45e59ef349859b24026a.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "7c8973c1-e65d-45e5-9ef3-49859b24026a",
"type": "announcement",
"description": "BREAKFIX: corrected function spelling in environment config from GetS3DisableMultRegionAccessPoints to GetS3DisableMultiRegionAccessPoints",
"modules": [
"service/s3control"
]
}
8 changes: 8 additions & 0 deletions .changelog/8e145919b32d4a33816ceb4aa78031ac.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "8e145919-b32d-4a33-816c-eb4aa78031ac",
"type": "bugfix",
"description": "Adds DisableMRAP option to config loader, and DisableMRAP client resolver to achieve parity with other S3 options in the config loader. Additionally, added breakfix to correct spelling.",
"modules": [
"service/s3control"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ public class ResolveClientConfigFromSources implements GoIntegration {
private static final Logger LOGGER = Logger.getLogger(AddAwsConfigFields.class.getName());

private static final String CONFIG_SOURCE_CONFIG_NAME = "ConfigSources";
// UseARNRegion

private static final String USE_ARN_REGION_OPTION = "UseARNRegion";
private static final String USE_ARN_REGION_CONFIG_RESOLVER = "resolveUseARNRegion";
private static final String RESOLVE_USE_ARN_REGION = "ResolveUseARNRegion";

private static final String DISABLE_MRAP_OPTION = "DisableMultiRegionAccessPoints";
private static final String DISABLE_MRAP_CONFIG_RESOLVER = "resolveDisableMultiRegionAccessPoints";
private static final String RESOLVE_DISABLE_MRAP = "ResolveDisableMultiRegionAccessPoints";

// EndpointDiscovery options
private static final String ENDPOINT_DISCOVERY_OPTION = "EndpointDiscovery";
private static final Symbol ENDPOINT_DISCOVERY_OPTION_TYPE = SymbolUtils.createValueSymbolBuilder(
Expand All @@ -54,6 +58,14 @@ public class ResolveClientConfigFromSources implements GoIntegration {
.awsResolveFunction(SymbolUtils.createValueSymbolBuilder(USE_ARN_REGION_CONFIG_RESOLVER)
.build())
.build(),
AddAwsConfigFields.AwsConfigField.builder()
.name(DISABLE_MRAP_OPTION)
.type(getUniversalSymbol("bool"))
.generatedOnClient(false)
.servicePredicate(ResolveClientConfigFromSources::isS3Service)
.awsResolveFunction(SymbolUtils.createValueSymbolBuilder(DISABLE_MRAP_CONFIG_RESOLVER)
.build())
.build(),
AddAwsConfigFields.AwsConfigField.builder()
.name(ENDPOINT_DISCOVERY_OPTION)
.type(ENDPOINT_DISCOVERY_OPTION_TYPE)
Expand Down Expand Up @@ -89,6 +101,7 @@ public void writeAdditionalFiles(
ServiceShape serviceShape = settings.getService(model);
goDelegator.useShapeWriter(serviceShape, writer -> {
generateUseARNRegionResolver(model, serviceShape, writer);
generateDisableMrapResolver(model, serviceShape, writer);
generateEnableEndpointDiscoveryResolver(model, serviceShape, writer);
generateUseUseDualStackResolver(model, serviceShape, writer);
generateUseUseFIPSEndpointResolver(model, serviceShape, writer);
Expand Down Expand Up @@ -128,6 +141,22 @@ private static void generateUseARNRegionResolver(Model model, ServiceShape servi
writer.write("");
}

private static void generateDisableMrapResolver(Model model, ServiceShape serviceShape, GoWriter writer) {
if (!isS3Service(model, serviceShape)) {
return;
}
generatedResolverFunction(writer, DISABLE_MRAP_CONFIG_RESOLVER, "resolves DisableMultiRegionAccessPoints S3 configuration", () -> {
writer.addUseImports(SmithyGoDependency.CONTEXT);
Symbol resolverFunc = SymbolUtils.createValueSymbolBuilder(RESOLVE_DISABLE_MRAP,
AwsGoDependency.S3_SHARED_CONFIG).build();
writer.write("value, found, err := $T(context.Background(), cfg.$L)", resolverFunc,
CONFIG_SOURCE_CONFIG_NAME);
writer.write("if err != nil { return err }");
writer.write("if found { o.$L = value }", DISABLE_MRAP_OPTION);
});
writer.write("");
}

private static void generateEnableEndpointDiscoveryResolver(
Model model,
ServiceShape serviceShape,
Expand Down
4 changes: 2 additions & 2 deletions config/env_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ func (c EnvConfig) GetS3UseARNRegion(ctx context.Context) (value, ok bool, err e
return *c.S3UseARNRegion, true, nil
}

// GetS3DisableMultRegionAccessPoints returns whether to disable multi-region access point
// GetS3DisableMultiRegionAccessPoints returns whether to disable multi-region access point
// support for the S3 client.
func (c EnvConfig) GetS3DisableMultRegionAccessPoints(ctx context.Context) (value, ok bool, err error) {
func (c EnvConfig) GetS3DisableMultiRegionAccessPoints(ctx context.Context) (value, ok bool, err error) {
if c.S3DisableMultiRegionAccessPoints == nil {
return false, false, nil
}
Expand Down
24 changes: 24 additions & 0 deletions config/load_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ type LoadOptions struct {
// the region, the client's requests are sent to.
S3UseARNRegion *bool

// S3DisableMultiRegionAccessPoints specifies if the S3 service should disable
// the S3 Multi-Region access points feature.
S3DisableMultiRegionAccessPoints *bool

// EnableEndpointDiscovery specifies if endpoint discovery is enable for
// the client.
EnableEndpointDiscovery aws.EndpointDiscoveryEnableState
Expand Down Expand Up @@ -876,6 +880,26 @@ func WithS3UseARNRegion(v bool) LoadOptionsFunc {
}
}

// GetS3DisableMultiRegionAccessPoints returns whether to disable
// the S3 multi-region access points feature.
func (o LoadOptions) GetS3DisableMultiRegionAccessPoints(ctx context.Context) (v bool, found bool, err error) {
if o.S3DisableMultiRegionAccessPoints == nil {
return false, false, nil
}
return *o.S3DisableMultiRegionAccessPoints, true, nil
}

// WithS3DisableMultiRegionAccessPoints is a helper function to construct functional options
// that can be used to set S3DisableMultiRegionAccessPoints on LoadOptions.
// If multiple WithS3DisableMultiRegionAccessPoints calls are made, the last call overrides
// the previous call values.
func WithS3DisableMultiRegionAccessPoints(v bool) LoadOptionsFunc {
return func(o *LoadOptions) error {
o.S3DisableMultiRegionAccessPoints = &v
return nil
}
}

// GetEnableEndpointDiscovery returns if the EnableEndpointDiscovery flag is set.
func (o LoadOptions) GetEnableEndpointDiscovery(ctx context.Context) (value aws.EndpointDiscoveryEnableState, ok bool, err error) {
if o.EnableEndpointDiscovery == aws.EndpointDiscoveryUnset {
Expand Down
19 changes: 19 additions & 0 deletions service/internal/s3shared/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ type UseARNRegionProvider interface {
GetS3UseARNRegion(ctx context.Context) (value bool, found bool, err error)
}

// DisableMultiRegionAccessPointsProvider is an interface for retrieving external configuration value for DisableMultiRegionAccessPoints
type DisableMultiRegionAccessPointsProvider interface {
GetS3DisableMultiRegionAccessPoints(ctx context.Context) (value bool, found bool, err error)
}

// ResolveUseARNRegion extracts the first instance of a UseARNRegion from the config slice.
// Additionally returns a boolean to indicate if the value was found in provided configs, and error if one is encountered.
func ResolveUseARNRegion(ctx context.Context, configs []interface{}) (value bool, found bool, err error) {
Expand All @@ -20,3 +25,17 @@ func ResolveUseARNRegion(ctx context.Context, configs []interface{}) (value bool
}
return
}

// ResolveDisableMultiRegionAccessPoints extracts the first instance of a DisableMultiRegionAccessPoints from the config slice.
// Additionally returns a boolean to indicate if the value was found in provided configs, and error if one is encountered.
func ResolveDisableMultiRegionAccessPoints(ctx context.Context, configs []interface{}) (value bool, found bool, err error) {
for _, cfg := range configs {
if p, ok := cfg.(DisableMultiRegionAccessPointsProvider); ok {
value, found, err = p.GetS3DisableMultiRegionAccessPoints(ctx)
if err != nil || found {
break
}
}
}
return
}
16 changes: 16 additions & 0 deletions service/s3/api_client.go

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

0 comments on commit d0122b9

Please sign in to comment.