Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion pkg/apis/clickhouse.altinity.com/v1/action_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ type ActionPlan struct {
attributesEqual bool

skipTaskID bool

// str is the plan rendered once at construction time - re-rendering is
// expensive and not deterministic (map iteration order)
str string
}

func NewActionPlan() *ActionPlan {
Expand Down Expand Up @@ -106,6 +110,9 @@ func MakeActionPlan(old, new ICustomResource) IActionPlan {

ap.excludePaths()

// Render the plan exactly once, after the diffs are finalized
ap.str = ap.render()

return ap
}

Expand Down Expand Up @@ -233,8 +240,13 @@ func (ap *ActionPlan) Log(tag string) string {
)
}

// String stringifies ActionPlan
// String returns the ActionPlan rendering produced at construction time.
func (ap *ActionPlan) String() string {
return ap.str
}

// render stringifies the ActionPlan. Called exactly once from MakeActionPlan.
func (ap *ActionPlan) render() string {
if !ap.HasActionsToDo() {
return ""
}
Expand Down