Skip to content

Commit 5a6e89c

Browse files
improved the cluster summary
Signed-off-by: Dipankar Das <[email protected]>
1 parent c4cae2d commit 5a6e89c

File tree

1 file changed

+40
-79
lines changed

1 file changed

+40
-79
lines changed

pkg/cli/blueprint_ui.go

Lines changed: 40 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,16 @@ func NewBlueprintUI(w io.Writer) *BlueprintUI {
3939

4040
// RenderClusterBlueprint renders the cluster metadata with enhanced UI
4141
func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
42-
// Border styles
43-
banner := lipgloss.NewStyle().
42+
parentBox := lipgloss.NewStyle().
4443
BorderStyle(lipgloss.RoundedBorder()).
45-
BorderForeground(lipgloss.Color("10")).
44+
BorderForeground(lipgloss.Color("8")).
45+
Padding(1, 2).
46+
Width(80).
47+
Align(lipgloss.Center)
48+
49+
banner := lipgloss.NewStyle().
4650
Padding(0, 1).
47-
Width(50).
51+
Width(70).
4852
Align(lipgloss.Center)
4953

5054
sectionTitle := lipgloss.NewStyle().
@@ -58,7 +62,7 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
5862
BorderForeground(lipgloss.Color("10")).
5963
Padding(1, 2).
6064
MarginTop(1).
61-
Width(50)
65+
Width(70)
6266

6367
keyValueRow := func(key, value string) string {
6468
return lipgloss.JoinHorizontal(lipgloss.Top,
@@ -67,105 +71,98 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
6771
)
6872
}
6973

70-
// Header banner
74+
var parentBoxContent strings.Builder
75+
7176
bannerContent := fmt.Sprintf("✨ %s ✨\n\n%s",
7277
lipgloss.NewStyle().Bold(true).Align(lipgloss.Center).Foreground(lipgloss.Color("#FFFFFF")).Render("Cluster Blueprint"),
7378
lipgloss.NewStyle().Italic(true).Align(lipgloss.Center).Foreground(lipgloss.Color("#DDDDDD")).Render("Your Kubernetes cluster plan"))
7479

75-
fmt.Fprintln(ui.writer, banner.Render(bannerContent))
76-
fmt.Fprintln(ui.writer)
77-
78-
// Define a container for all sections
79-
gridContainer := lipgloss.NewStyle().
80-
Width(120). // Double the width to accommodate two sections side by side
81-
Align(lipgloss.Center)
82-
83-
// Create slices to hold our sections and their titles
84-
var sectionBlocks []string
80+
parentBoxContent.WriteString(banner.Render(bannerContent))
81+
parentBoxContent.WriteString("\n\n")
8582

86-
// Key Attributes section
8783
{
8884
var content strings.Builder
89-
content.WriteString(keyValueRow("🔖 Cluster Name", meta.ClusterName))
85+
content.WriteString(keyValueRow("Name", meta.ClusterName))
9086
content.WriteString("\n")
91-
content.WriteString(keyValueRow("📍 Region", meta.Region))
87+
content.WriteString(keyValueRow("Region", meta.Region))
9288
content.WriteString("\n")
93-
content.WriteString(keyValueRow("🌐 Cloud Provider", string(meta.Provider)))
89+
content.WriteString(keyValueRow("Cloud", string(meta.Provider)))
9490
content.WriteString("\n")
95-
content.WriteString(keyValueRow("🔧 Cluster Type", string(meta.ClusterType)))
91+
content.WriteString(keyValueRow("Type", string(meta.ClusterType)))
9692

9793
contentBlock := infoBlock.Render(content.String())
9894
titleBlock := sectionTitle.Render("🔑 Key Attributes")
9995
fullSection := lipgloss.JoinVertical(lipgloss.Left, titleBlock, contentBlock)
10096

101-
sectionBlocks = append(sectionBlocks, fullSection)
97+
parentBoxContent.WriteString(fullSection)
98+
parentBoxContent.WriteString("\n")
10299
}
103100

104101
// Infrastructure section
105102
if meta.NoCP > 0 || meta.NoWP > 0 || meta.NoDS > 0 || len(meta.ManagedNodeType) > 0 {
106103
var content strings.Builder
107104
if meta.NoCP > 0 {
108-
content.WriteString(keyValueRow("🎮 Control Plane", fmt.Sprintf("%d × %s", meta.NoCP, color.HiMagentaString(meta.ControlPlaneNodeType))))
105+
content.WriteString(keyValueRow("Control Plane", fmt.Sprintf("%d × %s", meta.NoCP, color.HiMagentaString(meta.ControlPlaneNodeType))))
109106
content.WriteString("\n")
110107
}
111108
if meta.NoWP > 0 {
112-
content.WriteString(keyValueRow("🔋 Worker Nodes", fmt.Sprintf("%d × %s", meta.NoWP, color.HiMagentaString(meta.WorkerPlaneNodeType))))
109+
content.WriteString(keyValueRow("Worker Nodes", fmt.Sprintf("%d × %s", meta.NoWP, color.HiMagentaString(meta.WorkerPlaneNodeType))))
113110
content.WriteString("\n")
114111
}
115112
if meta.NoDS > 0 {
116-
content.WriteString(keyValueRow("💾 Etcd Nodes", fmt.Sprintf("%d × %s", meta.NoDS, color.HiMagentaString(meta.DataStoreNodeType))))
113+
content.WriteString(keyValueRow("Etcd Nodes", fmt.Sprintf("%d × %s", meta.NoDS, color.HiMagentaString(meta.DataStoreNodeType))))
117114
content.WriteString("\n")
118115
}
119116
if meta.LoadBalancerNodeType != "" {
120-
content.WriteString(keyValueRow("🔀 Load Balancer", color.HiMagentaString(meta.LoadBalancerNodeType)))
117+
content.WriteString(keyValueRow("Load Balancer", color.HiMagentaString(meta.LoadBalancerNodeType)))
121118
content.WriteString("\n")
122119
}
123120
if len(meta.ManagedNodeType) > 0 {
124-
content.WriteString(keyValueRow("🌐 Managed Nodes", fmt.Sprintf("%d × %s", meta.NoMP, color.HiMagentaString(meta.ManagedNodeType))))
121+
content.WriteString(keyValueRow("Managed Nodes", fmt.Sprintf("%d × %s", meta.NoMP, color.HiMagentaString(meta.ManagedNodeType))))
125122
}
126123

127124
// Trim trailing newline if present
128125
contentStr := strings.TrimSuffix(content.String(), "\n")
129126
contentBlock := infoBlock.Render(contentStr)
130-
titleBlock := sectionTitle.Render("🖥️ Infrastructure")
127+
titleBlock := sectionTitle.Render("💻 Infrastructure")
131128
fullSection := lipgloss.JoinVertical(lipgloss.Left, titleBlock, contentBlock)
132129

133-
sectionBlocks = append(sectionBlocks, fullSection)
130+
parentBoxContent.WriteString(fullSection)
131+
parentBoxContent.WriteString("\n")
134132
}
135133

136134
// Kubernetes configuration section
137135
if meta.K8sDistro != "" || meta.EtcdVersion != "" || meta.K8sVersion != "" {
138136
var content strings.Builder
139137
if meta.K8sDistro != "" {
140-
content.WriteString(keyValueRow("🚀 Bootstrap Provider", string(meta.K8sDistro)))
138+
content.WriteString(keyValueRow("Bootstrap Provider", string(meta.K8sDistro)))
141139
content.WriteString("\n")
142140
}
143141
if meta.K8sVersion != "" {
144-
content.WriteString(keyValueRow("🔄 Kubernetes Version", meta.K8sVersion))
142+
content.WriteString(keyValueRow("Kubernetes Version", meta.K8sVersion))
145143
content.WriteString("\n")
146144
}
147145
if meta.EtcdVersion != "" {
148-
content.WriteString(keyValueRow("📦 Etcd Version", meta.EtcdVersion))
146+
content.WriteString(keyValueRow("Etcd Version", meta.EtcdVersion))
149147
}
150148

151-
// Trim trailing newline if present
152149
contentStr := strings.TrimSuffix(content.String(), "\n")
153150
contentBlock := infoBlock.Render(contentStr)
154-
titleBlock := sectionTitle.Render("⚙️ Kubernetes Configuration")
151+
titleBlock := sectionTitle.Render("🔧 Kubernetes Configuration")
155152
fullSection := lipgloss.JoinVertical(lipgloss.Left, titleBlock, contentBlock)
156153

157-
sectionBlocks = append(sectionBlocks, fullSection)
154+
parentBoxContent.WriteString(fullSection)
155+
parentBoxContent.WriteString("\n")
158156
}
159157

160-
// Addons section
161158
if len(meta.Addons) > 0 {
162159
var sectionContent strings.Builder
163160
addonBlock := lipgloss.NewStyle().
164161
BorderStyle(lipgloss.RoundedBorder()).
165162
BorderForeground(lipgloss.Color("10")).
166163
Padding(1, 2).
167164
MarginTop(1).
168-
Width(50)
165+
Width(70)
169166

170167
for i, addon := range meta.Addons {
171168
addonTitle := color.HiMagentaString(addon.Name)
@@ -200,57 +197,21 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
200197
}
201198
}
202199

203-
titleBlock := sectionTitle.Render("🧩 Cluster Add-ons")
200+
titleBlock := sectionTitle.Render("🧩 Add-ons")
204201
fullSection := lipgloss.JoinVertical(lipgloss.Left, titleBlock, sectionContent.String())
205202

206-
sectionBlocks = append(sectionBlocks, fullSection)
203+
parentBoxContent.WriteString(fullSection)
207204
}
208205

209-
// Render the grid layout with 2 sections per row
210-
var gridRows []string
211-
212-
// Process sections in pairs
213-
for i := 0; i < len(sectionBlocks); i += 2 {
214-
row := ""
215-
216-
if i+1 < len(sectionBlocks) {
217-
// If we have a pair, join them horizontally with padding
218-
left := sectionBlocks[i]
219-
right := sectionBlocks[i+1]
220-
221-
// Create padding between columns
222-
spacing := lipgloss.NewStyle().PaddingLeft(1).PaddingRight(1).Render("")
223-
224-
row = lipgloss.JoinHorizontal(
225-
lipgloss.Top, // Align top edges of sections
226-
left,
227-
spacing,
228-
right,
229-
)
230-
} else {
231-
// If we have an odd number of sections, center the last one
232-
row = lipgloss.NewStyle().Align(lipgloss.Center).Render(sectionBlocks[i])
233-
}
234-
235-
gridRows = append(gridRows, row)
236-
}
237-
238-
// Join all rows vertically with padding
239-
finalGrid := lipgloss.JoinVertical(
240-
lipgloss.Center,
241-
gridRows...,
242-
)
243-
244-
fmt.Fprintln(ui.writer, gridContainer.Render(finalGrid))
245-
246-
// Footer note
247206
noteStyle := lipgloss.NewStyle().
248207
Italic(true).
249208
Foreground(lipgloss.Color("#919191")).
250209
Padding(1, 0).
251210
MarginTop(1).
252211
Align(lipgloss.Center)
253212

254-
fmt.Fprintln(ui.writer)
255-
fmt.Fprintln(ui.writer, noteStyle.Render("Your cluster will be provisioned with these specifications"))
213+
parentBoxContent.WriteString("\n\n")
214+
parentBoxContent.WriteString(noteStyle.Render("Your cluster will be provisioned with these specifications"))
215+
216+
fmt.Fprintln(ui.writer, parentBox.Render(parentBoxContent.String()))
256217
}

0 commit comments

Comments
 (0)