From f2d288fd5d1054075374f3f7229f8a9332adf61c Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 24 Jul 2024 19:39:46 -0400 Subject: Be more specific about zero vs. two or more ASGs matching the name. This also lets me remove the clever-but-silly Single trait. --- src/autoscaling.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/autoscaling.rs') diff --git a/src/autoscaling.rs b/src/autoscaling.rs index 327a4f7..ea76dc0 100644 --- a/src/autoscaling.rs +++ b/src/autoscaling.rs @@ -1,9 +1,7 @@ -use anyhow::{anyhow, Result}; +use anyhow::{bail, Result}; use aws_sdk_autoscaling as autoscaling; use aws_sdk_autoscaling::types::AutoScalingGroup; -use crate::single::Single; - pub trait AutoScaling { fn autoscaling(&self) -> &autoscaling::Client; } @@ -12,22 +10,19 @@ pub async fn asg_by_name(aws_context: &C, name: &str) -> Result group, + (None, _) => bail!("No autoscaling group found with name: {name}"), + (Some(_), Some(_)) => bail!("Multiple autoscaling groups found with name: {name}"), + }; - Ok(auto_scaling_group) + Ok(group.to_owned()) } -- cgit v1.2.3