diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2024-07-24 21:27:31 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2024-07-24 21:27:31 -0400 |
| commit | 3ce81264fa4e87e4d26b3966778879fccce33998 (patch) | |
| tree | 7ee02e626b711bc6f4f7f21bc7b5bb79281fba85 /src | |
| parent | 3fbc6b94c7e4cad06902d01d5b14694d23fa71c9 (diff) | |
Use new route53 paginator support, get rid of ad-hoc pagination
Diffstat (limited to 'src')
| -rw-r--r-- | src/route53.rs | 45 |
1 files changed, 17 insertions, 28 deletions
diff --git a/src/route53.rs b/src/route53.rs index 3c34e9c..cf7277d 100644 --- a/src/route53.rs +++ b/src/route53.rs @@ -19,41 +19,30 @@ where { let names = suffixes(name.clone()); - // Outer pagination loop needs to be pulled out to a trait - this is some hot nonsense. let mut zone = None; let mut depth = None; - let mut zones_marker = None; - loop { - let zones_resp = aws_context - .route53() - .list_hosted_zones() - .set_marker(zones_marker) - .send() - .await?; + let mut zones = aws_context + .route53() + .list_hosted_zones() + .into_paginator() + .items() + .send(); - let zones = zones_resp.hosted_zones(); - for candidate_zone in zones.iter() { - let zone_name = Name::from_str(candidate_zone.name())?; - let match_position = names.iter().position(|name| *name == zone_name); - match (depth, match_position) { - (None, Some(matched_depth)) => { + while let Some(candidate_zone) = zones.try_next().await? { + let zone_name = Name::from_str(candidate_zone.name())?; + let match_position = names.iter().position(|name| *name == zone_name); + match (depth, match_position) { + (None, Some(matched_depth)) => { + zone = Some(candidate_zone.clone()); + depth = Some(matched_depth); + } + (Some(found_depth), Some(matched_depth)) => { + if matched_depth < found_depth { zone = Some(candidate_zone.clone()); depth = Some(matched_depth); } - (Some(found_depth), Some(matched_depth)) => { - if matched_depth < found_depth { - zone = Some(candidate_zone.clone()); - depth = Some(matched_depth); - } - } - (_, _) => {} } - } - - if zones_resp.is_truncated() { - zones_marker = zones_resp.next_marker().map(String::from); - } else { - break; + (_, _) => {} } } |
