Skip to content

Commit 896a214

Browse files
authored
internal/ini: Normalize Section keys to lowercase (#495)
Updates the SDK's ini utility to read all keys as case-insensitive, and store them as lowercase for lookup. This is to match the behavior of the parsing in Python, and the boto based AWS CLI, where the keys are normalized to lowercase.
1 parent 109e066 commit 896a214

File tree

7 files changed

+31
-2
lines changed

7 files changed

+31
-2
lines changed

CHANGELOG_PENDING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ SDK Features
2121

2222
SDK Enhancements
2323
---
24+
* `internal/ini`: Normalize Section keys to lowercase ([#495](https://github.com/aws/aws-sdk-go-v2/pull/495))
25+
* Update's SDK's ini utility to store all keys as lowercase. This brings the SDK inline with the AWS CLI's behavior.
2426

2527
SDK Bugs
2628
---

aws/external/shared_config_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,16 @@ func TestLoadSharedConfigFromFile(t *testing.T) {
335335
Err: nil,
336336
},
337337
},
338+
{
339+
Profile: "with_mixed_case_keys",
340+
Expected: SharedConfig{
341+
Credentials: aws.Credentials{
342+
AccessKeyID: "accessKey",
343+
SecretAccessKey: "secret",
344+
Source: fmt.Sprintf("SharedConfigCredentials: %s", testConfigFilename),
345+
},
346+
},
347+
},
338348
}
339349

340350
for i, c := range cases {

aws/external/testdata/shared_config

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ s3_use_arn_region=true
8484
[endpoint_discovery]
8585
endpoint_discovery_enabled=true
8686

87+
88+
[with_mixed_case_keys]
89+
aWs_AcCeSs_kEy_ID = accessKey
90+
aWs_SecrEt_AccEsS_kEY = secret
91+
8792
[assume_role_with_credential_source]
8893
role_arn = assume_role_with_credential_source_role_arn
8994
credential_source = Ec2InstanceMetadata
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[with_mixed_case_keys]
2+
sTring_Value = secret
3+
iNt_Value = 60
4+
flOAt_Value = 12.3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"with_mixed_case_keys": {
3+
"int_value": 60,
4+
"string_value": "secret",
5+
"float_value": 12.3
6+
}
7+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ʃʉʍΡιξ": {
3-
"ϰϪϧ": "Ϯϴϖ",
3+
"ϰϫϧ": "Ϯϴϖ",
44
"ϝϧ": "ϟΞ΅"
55
}
66
}

internal/ini/visitor.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package ini
33
import (
44
"fmt"
55
"sort"
6+
"strings"
67
)
78

89
// Visitor is an interface used by walkers that will
@@ -60,7 +61,7 @@ func (v *DefaultVisitor) VisitExpr(expr AST) error {
6061
return err
6162
}
6263

63-
t.values[key] = v
64+
t.values[strings.ToLower(key)] = v
6465
default:
6566
return NewParseError(fmt.Sprintf("unsupported expression %v", expr))
6667
}

0 commit comments

Comments
 (0)