Skip to content

Commit

Permalink
Fix Bolt Terraform has_applied for disabled plans (#351)
Browse files Browse the repository at this point in the history
<!-- Please make sure there is an issue that this PR is correlated to. -->

## Changes

<!-- If there are frontend changes, please include screenshots. -->
  • Loading branch information
NathanFlurry committed Jan 17, 2024
1 parent d1cf19d commit 3a9a4d7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **Infra** Redis Kubernetes error when using non-Kubernetes provider
- **api-helper** Remove excess logging
- `user_identity.identities` not getting purged on create & delete
- **Bolt** Error when applying Terraform when a plan is no longer required

## [23.2.0-rc.1] - 2023-12-01

Expand Down
8 changes: 8 additions & 0 deletions lib/bolt/core/src/dep/terraform/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ pub async fn state_list(ctx: &ProjectContext, plan_id: &str) -> Option<Vec<Strin
}

pub async fn has_applied(ctx: &ProjectContext, plan_id: &str) -> bool {
// Check if Terraform plan is required for both:
// - Return false if the plan was disabled for any reason
// - Faster performance
let terraform_plans = crate::tasks::infra::all_terraform_plans(ctx).unwrap();
if terraform_plans.iter().all(|x| x != plan_id) {
return false;
}

// Check if there is any output
//
// HACK: This will have a false negative for plans that have no output variables
Expand Down

0 comments on commit 3a9a4d7

Please sign in to comment.