Skip to content

Commit a8575bb

Browse files
authored
Updating partition to pass implicitGlobalRegion (#3705)
## Motivation and Context <!--- Why is this change required? What problem does it solve? --> <!--- If it fixes an open issue, please link to the issue here --> Our endpoint partition parsing was dropping the `implicitGlobalRegion` value ## Description <!--- Describe your changes in detail --> Updated our Partition structs to include that value and update the parser to include it. ## Testing <!--- Please describe in detail how you tested your changes --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> Added check for `implicitGlobalRegion` to existing partition unit tests ## Checklist <!--- If a checkbox below is not applicable, then please DELETE it rather than leaving it unchecked --> - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the smithy-rs codegen or runtime crates - [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates ---- _By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice._
1 parent 217af48 commit a8575bb

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

rust-runtime/inlineable/src/endpoint_lib/partition.rs

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub(crate) struct Partition<'a> {
3535
dual_stack_dns_suffix: &'a str,
3636
supports_fips: bool,
3737
supports_dual_stack: bool,
38+
implicit_global_region: &'a str,
3839
}
3940

4041
#[allow(unused)]
@@ -58,6 +59,10 @@ impl<'a> Partition<'a> {
5859
pub(crate) fn supports_dual_stack(&self) -> bool {
5960
self.supports_dual_stack
6061
}
62+
63+
pub(crate) fn implicit_global_region(&self) -> &str {
64+
self.implicit_global_region
65+
}
6166
}
6267

6368
static DEFAULT_OVERRIDE: &PartitionOutputOverride = &PartitionOutputOverride {
@@ -66,6 +71,7 @@ static DEFAULT_OVERRIDE: &PartitionOutputOverride = &PartitionOutputOverride {
6671
dual_stack_dns_suffix: None,
6772
supports_fips: None,
6873
supports_dual_stack: None,
74+
implicit_global_region: None,
6975
};
7076

7177
/// Merge the base output and the override output, dealing with `Cow`s
@@ -145,6 +151,7 @@ impl PartitionResolver {
145151
supports_dual_stack: region_override
146152
.supports_dual_stack
147153
.unwrap_or(base.outputs.supports_dual_stack),
154+
implicit_global_region: merge!(base, region_override, implicit_global_region),
148155
})
149156
}
150157
}
@@ -211,6 +218,7 @@ pub(crate) struct PartitionOutput {
211218
dual_stack_dns_suffix: Str,
212219
supports_fips: bool,
213220
supports_dual_stack: bool,
221+
implicit_global_region: Str,
214222
}
215223

216224
#[derive(Clone, Debug, Default)]
@@ -220,6 +228,7 @@ pub(crate) struct PartitionOutputOverride {
220228
dual_stack_dns_suffix: Option<Str>,
221229
supports_fips: Option<bool>,
222230
supports_dual_stack: Option<bool>,
231+
implicit_global_region: Option<Str>,
223232
}
224233

225234
impl PartitionOutputOverride {
@@ -236,6 +245,9 @@ impl PartitionOutputOverride {
236245
supports_dual_stack: self
237246
.supports_dual_stack
238247
.ok_or("missing supportsDualstack")?,
248+
implicit_global_region: self
249+
.implicit_global_region
250+
.ok_or("missing implicitGlobalRegion")?,
239251
})
240252
}
241253
}
@@ -432,6 +444,9 @@ mod deser {
432444
"supportsDualStack" => {
433445
builder.supports_dual_stack = expect_bool_or_null(tokens.next())?;
434446
}
447+
"implicitGlobalRegion" => {
448+
builder.implicit_global_region = token_to_str(tokens.next())?;
449+
}
435450
_ => skip_value(tokens)?,
436451
},
437452
other => {
@@ -502,7 +517,8 @@ mod test {
502517
"dnsSuffix": "amazonaws.com",
503518
"dualStackDnsSuffix": "api.aws",
504519
"supportsFIPS": true,
505-
"supportsDualStack": true
520+
"supportsDualStack": true,
521+
"implicitGlobalRegion": "us-east-1"
506522
}
507523
},
508524
{
@@ -518,7 +534,8 @@ mod test {
518534
"dnsSuffix": "amazonaws.com",
519535
"dualStackDnsSuffix": "api.aws",
520536
"supportsFIPS": true,
521-
"supportsDualStack": true
537+
"supportsDualStack": true,
538+
"implicitGlobalRegion": "us-gov-east-1"
522539
}
523540
},
524541
{
@@ -534,7 +551,8 @@ mod test {
534551
"dnsSuffix": "amazonaws.com.cn",
535552
"dualStackDnsSuffix": "api.amazonwebservices.com.cn",
536553
"supportsFIPS": true,
537-
"supportsDualStack": true
554+
"supportsDualStack": true,
555+
"implicitGlobalRegion": "cn-north-1"
538556
}
539557
},
540558
{
@@ -545,7 +563,8 @@ mod test {
545563
"dnsSuffix": "c2s.ic.gov",
546564
"supportsFIPS": true,
547565
"supportsDualStack": false,
548-
"dualStackDnsSuffix": "c2s.ic.gov"
566+
"dualStackDnsSuffix": "c2s.ic.gov",
567+
"implicitGlobalRegion": "us-iso-foo-1"
549568
},
550569
"regions": {}
551570
},
@@ -557,7 +576,8 @@ mod test {
557576
"dnsSuffix": "sc2s.sgov.gov",
558577
"supportsFIPS": true,
559578
"supportsDualStack": false,
560-
"dualStackDnsSuffix": "sc2s.sgov.gov"
579+
"dualStackDnsSuffix": "sc2s.sgov.gov",
580+
"implicitGlobalRegion": "us-isob-foo-1"
561581
},
562582
"regions": {}
563583
}
@@ -571,6 +591,10 @@ mod test {
571591
"amazonaws.com.cn"
572592
);
573593
assert_eq!(resolver.partitions.len(), 5);
594+
assert_eq!(
595+
resolve(&resolver, "af-south-1").implicit_global_region,
596+
"us-east-1"
597+
);
574598
}
575599

576600
#[test]
@@ -590,6 +614,7 @@ mod test {
590614
dual_stack_dns_suffix: "api.aws".into(),
591615
supports_fips: true,
592616
supports_dual_stack: true,
617+
implicit_global_region: "us-east-1".into(),
593618
},
594619
});
595620
resolver.add_partition(PartitionMetadata {
@@ -602,6 +627,7 @@ mod test {
602627
dual_stack_dns_suffix: "other.aws".into(),
603628
supports_fips: false,
604629
supports_dual_stack: true,
630+
implicit_global_region: "other-south-2".into(),
605631
},
606632
});
607633
assert_eq!(resolve(&resolver, "us-east-1").name, "aws");

0 commit comments

Comments
 (0)