Skip to content

Commit

Permalink
aws: Add support for non-camelcased version of two URL parameters. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
vangent authored Oct 9, 2024
1 parent 2cb18bb commit bbdd0b3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ func (co ConfigOverrider) ClientConfig(serviceName string, cfgs ...*aws.Config)
// The following query options are supported:
// - region: The AWS region for requests; sets aws.Config.Region.
// - endpoint: The endpoint URL (hostname only or fully qualified URI); sets aws.Config.Endpoint.
// - disableSSL: A value of "true" disables SSL when sending requests; sets aws.Config.DisableSSL.
// - s3ForcePathStyle: A value of "true" forces the request to use path-style addressing; sets aws.Config.S3ForcePathStyle.
// - disable_ssl (or disableSSL): A value of "true" disables SSL when sending requests; sets aws.Config.DisableSSL.
// - s3_force_path_style (or s3ForcePathStyle): A value of "true" forces the request to use path-style addressing; sets aws.Config.S3ForcePathStyle.
// - dualstack: A value of "true" enables dual stack (IPv4 and IPv6) endpoints
// - fips: A value of "true" enables the use of FIPS endpoints
func ConfigFromURLParams(q url.Values) (*aws.Config, error) {
Expand All @@ -93,13 +93,13 @@ func ConfigFromURLParams(q url.Values) (*aws.Config, error) {
cfg.Region = aws.String(value)
case "endpoint":
cfg.Endpoint = aws.String(value)
case "disableSSL":
case "disable_ssl", "disableSSL":
b, err := strconv.ParseBool(value)
if err != nil {
return nil, fmt.Errorf("invalid value for query parameter %q: %v", param, err)
}
cfg.DisableSSL = aws.Bool(b)
case "s3ForcePathStyle":
case "s3_force_path_style", "s3ForcePathStyle":
b, err := strconv.ParseBool(value)
if err != nil {
return nil, fmt.Errorf("invalid value for query parameter %q: %v", param, err)
Expand Down
10 changes: 10 additions & 0 deletions aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ func TestConfigFromURLParams(t *testing.T) {
query: url.Values{"endpoint": {"foo"}},
wantCfg: &aws.Config{Endpoint: aws.String("foo")},
},
{
name: "disable_ssl true",
query: url.Values{"disable_ssl": {"true"}},
wantCfg: &aws.Config{DisableSSL: aws.Bool(true)},
},
{
name: "DisableSSL true",
query: url.Values{"disableSSL": {"true"}},
Expand All @@ -68,6 +73,11 @@ func TestConfigFromURLParams(t *testing.T) {
query: url.Values{"disableSSL": {"invalid"}},
wantErr: true,
},
{
name: "s3_force_path_style true",
query: url.Values{"s3_force_path_style": {"true"}},
wantCfg: &aws.Config{S3ForcePathStyle: aws.Bool(true)},
},
{
name: "S3ForcePathStyle true",
query: url.Values{"s3ForcePathStyle": {"true"}},
Expand Down

0 comments on commit bbdd0b3

Please sign in to comment.