Skip to content

Commit

Permalink
rename RiskCalculationStatus to ChangeCalculationStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
tphoney committed Dec 16, 2024
1 parent ccd83ea commit aa2f05e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions cmd/changes_get_change.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,22 @@ fetch:
}
}

if riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus() == sdp.RiskCalculationStatus_STATUS_INPROGRESS {
if riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus() == sdp.ChangeAnalysisStatus_STATUS_INPROGRESS {
// Extract the currently running milestone if you can
milestones := riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetProgressMilestones()
milestones := riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetProgressMilestones()
var currentMilestone string
for _, milestone := range milestones {
if milestone == nil {
continue
}

if milestone.GetStatus() == sdp.RiskCalculationStatus_ProgressMilestone_STATUS_INPROGRESS {
if milestone.GetStatus() == sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_INPROGRESS {
currentMilestone = milestone.GetDescription()
}
}

log.WithContext(ctx).WithFields(log.Fields{
"status": riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus().String(),
"status": riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus().String(),
"milestone": currentMilestone,
}).Info("Waiting for risk calculation")

Expand Down
18 changes: 9 additions & 9 deletions cmd/terraform_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI
return nil
}

for i, ms := range riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetProgressMilestones() {
for i, ms := range riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetProgressMilestones() {
if i <= len(milestoneSpinners) {
new := pterm.DefaultSpinner.
WithWriter(multi.NewWriter()).
Expand All @@ -397,31 +397,31 @@ func TerraformPlanImpl(ctx context.Context, cmd *cobra.Command, oi sdp.OvermindI
}

switch ms.GetStatus() {
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_PENDING:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_PENDING:
continue
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_INPROGRESS:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_INPROGRESS:
if !milestoneSpinners[i].IsActive {
milestoneSpinners[i], _ = milestoneSpinners[i].Start()
}
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_ERROR:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_ERROR:
milestoneSpinners[i].Fail()
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_DONE:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_DONE:
milestoneSpinners[i].Success()
case sdp.RiskCalculationStatus_ProgressMilestone_STATUS_SKIPPED:
case sdp.ChangeAnalysisStatus_ProgressMilestone_STATUS_SKIPPED:
milestoneSpinners[i].Warning(fmt.Sprintf("%v: skipped", ms.GetDescription()))
}
}

status := riskRes.Msg.GetChangeRiskMetadata().GetRiskCalculationStatus().GetStatus()
if status == sdp.RiskCalculationStatus_STATUS_UNSPECIFIED || status == sdp.RiskCalculationStatus_STATUS_INPROGRESS {
status := riskRes.Msg.GetChangeRiskMetadata().GetChangeAnalysisStatus().GetStatus()
if status == sdp.ChangeAnalysisStatus_STATUS_UNSPECIFIED || status == sdp.ChangeAnalysisStatus_STATUS_INPROGRESS {
if !riskSpinner.IsActive {
// restart after a Fail()
riskSpinner, _ = riskSpinner.Start("Calculating Risks")
}
// retry
time.Sleep(time.Second)

} else if status == sdp.RiskCalculationStatus_STATUS_ERROR {
} else if status == sdp.ChangeAnalysisStatus_STATUS_ERROR {
riskSpinner.Fail("Calculating Risks: waiting for a retry")
} else {
// it's done
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/overmindtech/discovery v0.33.4
github.com/overmindtech/k8s-source v0.9.1
github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297
github.com/overmindtech/sdp-go v0.102.4
github.com/overmindtech/sdp-go v0.102.5-0.20241216101827-31ab7b07f9d8
github.com/overmindtech/stdlib-source v0.0.0-20241211162909-1bb8eb048964
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/sirupsen/logrus v1.9.3
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297 h1:ih4bqBMHTCtg
github.com/overmindtech/pterm v0.0.0-20240919144758-04d94ccb2297/go.mod h1:bRQZYnvLrW1S5wYT6tbQnun8NpO5X6zP5cY3VKuDc4U=
github.com/overmindtech/sdp-go v0.102.4 h1:PENbGxfoOvh7L3yCeOH1bWtFNfCGeYg/22iF0JeYPdw=
github.com/overmindtech/sdp-go v0.102.4/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdp-go v0.102.5-0.20241216101827-31ab7b07f9d8 h1:7V7SYUvxFq8IaLXoeX/2j8Q8iwdbCN3dmEwenQlUi7Y=
github.com/overmindtech/sdp-go v0.102.5-0.20241216101827-31ab7b07f9d8/go.mod h1:Lx2DtTLaroGuVTq5CL1SBT19zzudhLF6jdRkwXDJXRk=
github.com/overmindtech/sdpcache v1.6.4 h1:MJoYBDqDE3s8FrRzZ0RPgFiH39HWI/Mv2ImH1NdLT8k=
github.com/overmindtech/sdpcache v1.6.4/go.mod h1:/F9XStVdntRJEQjlZ86BPuB1Y7VPo1PFcsCNiU1IoGE=
github.com/overmindtech/stdlib-source v0.0.0-20241211162909-1bb8eb048964 h1:StLQfDPOlAHecZtIItkHiYO3ZArKrP1dv3t2Z/n4N1U=
Expand Down

0 comments on commit aa2f05e

Please sign in to comment.