Skip to content

Commit

Permalink
Switch to using function calls for aws RestApi objects
Browse files Browse the repository at this point in the history
  • Loading branch information
EricGhildyal committed Nov 26, 2024
1 parent f909c8e commit 8d2e9af
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/adapters/ingresses/apig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl AwsApiGateway {
let api = all_apis
.items()
.iter()
.find(|api| api.name.clone().unwrap() == api_name)
.find(|api| api.name().unwrap() == api_name)
.ok_or(miette!(
"Could not find an API Gateway with the name: {}",
api_name
Expand Down Expand Up @@ -117,13 +117,13 @@ impl Ingress for AwsApiGateway {
.ok_or(miette!("Couldn't get version of deployed lambda"))?;

let api = self.get_api_id_by_name(&self.gateway_name).await?;
let api_id = api.id.ok_or(miette!("Couldn't get ID of deployed API"))?;
let api_id = api.id().ok_or(miette!("Couldn't get ID of deployed API"))?;

// Next, we need to create a new deployment, pointing at our
// new lambda version with canary settings
self.apig_client
.put_integration()
.rest_api_id(&api_id)
.rest_api_id(api_id)
.uri(format!("{}:{}", lambda_arn, version))
.send()
.await
Expand All @@ -132,7 +132,7 @@ impl Ingress for AwsApiGateway {
// Create a deployment with canary settings to deploy our new lambda
self.apig_client
.create_deployment()
.rest_api_id(&api_id)
.rest_api_id(api_id)
.stage_name(&self.stage_name)
.canary_settings(
DeploymentCanarySettings::builder()
Expand All @@ -150,7 +150,7 @@ impl Ingress for AwsApiGateway {

async fn set_canary_traffic(&mut self, percent: WholePercent) -> Result<()> {
let api = self.get_api_id_by_name(&self.gateway_name).await?;
let api_id = api.id.ok_or(miette!("Couldn't get ID of deployed API"))?;
let api_id = api.id().ok_or(miette!("Couldn't get ID of deployed API"))?;

let patch_op = PatchOperation::builder()
.op(Op::Replace)
Expand All @@ -172,7 +172,7 @@ impl Ingress for AwsApiGateway {

async fn rollback_canary(&mut self) -> Result<()> {
let api = self.get_api_id_by_name(&self.gateway_name).await?;
let api_id = api.id.ok_or(miette!("Couldn't get ID of deployed API"))?;
let api_id = api.id().ok_or(miette!("Couldn't get ID of deployed API"))?;

// Updates the stage to delete any canary settings from the API Gateway
let patch_op = PatchOperation::builder()
Expand All @@ -194,7 +194,7 @@ impl Ingress for AwsApiGateway {

async fn promote_canary(&mut self) -> Result<()> {
let api = self.get_api_id_by_name(&self.gateway_name).await?;
let api_id = api.id.ok_or(miette!("Couldn't get ID of deployed API"))?;
let api_id = api.id().ok_or(miette!("Couldn't get ID of deployed API"))?;

// Overwrite the main deployment's ID with the canary's
let replace_deployment_op = PatchOperation::builder()
Expand Down

0 comments on commit 8d2e9af

Please sign in to comment.