New plans.Quality type for display-relevant facts about a plan

This commit replaces the existing jsonformat.PlanRendererOpt type with a new
type with identical semantics, located in the plans package.

We needed to be able to exchange the facts represented by
`jsonformat.PlanRendererOpt` across some package boundaries, but the jsonformat
package is implicated in too many dependency chains to be safe for that purpose!
So, we had to make a new one. The plans package seems safe to import from all
the places that must emit or accept this info, and already contains plans.Mode,
which is effectively a sibling of this type.
This commit is contained in:
Nick Fagerlund
2023-06-30 12:24:57 -07:00
committed by Sebastian Rivera
parent da963a13b9
commit 0df3c143bb
6 changed files with 56 additions and 17 deletions

View File

@@ -67,12 +67,12 @@ func (v *ShowHuman) Display(config *configs.Config, plan *plans.Plan, stateFile
RelevantAttributes: attrs,
}
var opts []jsonformat.PlanRendererOpt
var opts []plans.Quality
if !plan.CanApply() {
opts = append(opts, jsonformat.CanNotApply)
opts = append(opts, plans.NoChanges)
}
if plan.Errored {
opts = append(opts, jsonformat.Errored)
opts = append(opts, plans.Errored)
}
renderer.RenderHumanPlan(jplan, plan.UIMode, opts...)