@@ -740,6 +740,8 @@ func mergeSections(dst *ini.Sections, src ini.Sections) error {
740
740
defaultsModeKey ,
741
741
retryModeKey ,
742
742
caBundleKey ,
743
+ roleDurationSecondsKey ,
744
+ retryMaxAttemptsKey ,
743
745
744
746
ssoSessionNameKey ,
745
747
ssoAccountIDKey ,
@@ -753,16 +755,6 @@ func mergeSections(dst *ini.Sections, src ini.Sections) error {
753
755
}
754
756
}
755
757
756
- intKeys := []string {
757
- roleDurationSecondsKey ,
758
- retryMaxAttemptsKey ,
759
- }
760
- for i := range intKeys {
761
- if err := mergeIntKey (& srcSection , & dstSection , sectionName , intKeys [i ]); err != nil {
762
- return err
763
- }
764
- }
765
-
766
758
// set srcSection on dst srcSection
767
759
* dst = dst .SetSection (sectionName , dstSection )
768
760
}
@@ -789,26 +781,6 @@ func mergeStringKey(srcSection *ini.Section, dstSection *ini.Section, sectionNam
789
781
return nil
790
782
}
791
783
792
- func mergeIntKey (srcSection * ini.Section , dstSection * ini.Section , sectionName , key string ) error {
793
- if srcSection .Has (key ) {
794
- srcValue := srcSection .Int (key )
795
- v , err := ini .NewIntValue (srcValue )
796
- if err != nil {
797
- return fmt .Errorf ("error merging %s, %w" , key , err )
798
- }
799
-
800
- if dstSection .Has (key ) {
801
- dstSection .Logs = append (dstSection .Logs , newMergeKeyLogMessage (sectionName , key ,
802
- dstSection .SourceFile [key ], srcSection .SourceFile [key ]))
803
-
804
- }
805
-
806
- dstSection .UpdateValue (key , v )
807
- dstSection .UpdateSourceFile (key , srcSection .SourceFile [key ])
808
- }
809
- return nil
810
- }
811
-
812
784
func newMergeKeyLogMessage (sectionName , key , dstSourceFile , srcSourceFile string ) string {
813
785
return fmt .Sprintf ("For profile: %v, overriding %v value, defined in %v " +
814
786
"with a %v value found in a duplicate profile defined at file %v. \n " ,
@@ -962,9 +934,16 @@ func (c *SharedConfig) setFromIniSection(profile string, section ini.Section) er
962
934
updateString (& c .SSOAccountID , section , ssoAccountIDKey )
963
935
updateString (& c .SSORoleName , section , ssoRoleNameKey )
964
936
937
+ // we're retaining a behavioral quirk with this field that existed before
938
+ // the removal of literal parsing for #2276:
939
+ // - if the key is missing, the config field will not be set
940
+ // - if the key is set to a non-numeric, the config field will be set to 0
965
941
if section .Has (roleDurationSecondsKey ) {
966
- d := time .Duration (section .Int (roleDurationSecondsKey )) * time .Second
967
- c .RoleDurationSeconds = & d
942
+ if v , ok := section .Int (roleDurationSecondsKey ); ok {
943
+ c .RoleDurationSeconds = aws .Duration (time .Duration (v ) * time .Second )
944
+ } else {
945
+ c .RoleDurationSeconds = aws .Duration (time .Duration (0 ))
946
+ }
968
947
}
969
948
970
949
updateString (& c .CredentialProcess , section , credentialProcessKey )
@@ -1314,12 +1293,13 @@ func updateInt(dst *int, section ini.Section, key string) error {
1314
1293
if ! section .Has (key ) {
1315
1294
return nil
1316
1295
}
1317
- if vt , _ := section .ValueType (key ); vt != ini .IntegerType {
1318
- return fmt .Errorf ("invalid value %s=%s, expect integer" ,
1319
- key , section .String (key ))
1320
1296
1297
+ v , ok := section .Int (key )
1298
+ if ! ok {
1299
+ return fmt .Errorf ("invalid value %s=%s, expect integer" , key , section .String (key ))
1321
1300
}
1322
- * dst = int (section .Int (key ))
1301
+
1302
+ * dst = int (v )
1323
1303
return nil
1324
1304
}
1325
1305
@@ -1329,7 +1309,10 @@ func updateBool(dst *bool, section ini.Section, key string) {
1329
1309
if ! section .Has (key ) {
1330
1310
return
1331
1311
}
1332
- * dst = section .Bool (key )
1312
+
1313
+ // retains pre-#2276 behavior where non-bool value would resolve to false
1314
+ v , _ := section .Bool (key )
1315
+ * dst = v
1333
1316
}
1334
1317
1335
1318
// updateBoolPtr will only update the dst with the value in the section key,
@@ -1338,8 +1321,11 @@ func updateBoolPtr(dst **bool, section ini.Section, key string) {
1338
1321
if ! section .Has (key ) {
1339
1322
return
1340
1323
}
1324
+
1325
+ // retains pre-#2276 behavior where non-bool value would resolve to false
1326
+ v , _ := section .Bool (key )
1341
1327
* dst = new (bool )
1342
- * * dst = section . Bool ( key )
1328
+ * * dst = v
1343
1329
}
1344
1330
1345
1331
// updateEndpointDiscoveryType will only update the dst with the value in the section, if
@@ -1371,7 +1357,8 @@ func updateUseDualStackEndpoint(dst *aws.DualStackEndpointState, section ini.Sec
1371
1357
return
1372
1358
}
1373
1359
1374
- if section .Bool (key ) {
1360
+ // retains pre-#2276 behavior where non-bool value would resolve to false
1361
+ if v , _ := section .Bool (key ); v {
1375
1362
* dst = aws .DualStackEndpointStateEnabled
1376
1363
} else {
1377
1364
* dst = aws .DualStackEndpointStateDisabled
@@ -1387,7 +1374,8 @@ func updateUseFIPSEndpoint(dst *aws.FIPSEndpointState, section ini.Section, key
1387
1374
return
1388
1375
}
1389
1376
1390
- if section .Bool (key ) {
1377
+ // retains pre-#2276 behavior where non-bool value would resolve to false
1378
+ if v , _ := section .Bool (key ); v {
1391
1379
* dst = aws .FIPSEndpointStateEnabled
1392
1380
} else {
1393
1381
* dst = aws .FIPSEndpointStateDisabled
0 commit comments