Skip to content

Commit 28395b1

Browse files
updated the blueprint UI
Signed-off-by: Dipankar Das <65275144+dipankardas011@users.noreply.github.com>
1 parent 53b80aa commit 28395b1

2 files changed

Lines changed: 21 additions & 44 deletions

File tree

cmd/create.go

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import (
1818
"os"
1919
"time"
2020

21-
"github.com/ksctl/ksctl/v2/pkg/addons"
2221
"github.com/ksctl/ksctl/v2/pkg/provider/optimizer"
2322

2423
"github.com/fatih/color"
@@ -46,42 +45,17 @@ ksctl create --help
4645
Long: "It is used to create cluster with the given name from user",
4746

4847
Run: func(cmd *cobra.Command, args []string) {
49-
meta := controller.Metadata{
50-
ClusterName: "ggg",
51-
ClusterType: consts.ClusterTypeSelfMang,
52-
Provider: consts.CloudAws,
53-
Region: "us-east-1",
54-
StateLocation: consts.StoreLocal,
55-
K8sDistro: consts.K8sK3s,
56-
K8sVersion: "v1.25.0",
57-
NoCP: 3,
58-
NoWP: 1,
59-
NoDS: 3,
60-
NoMP: 1,
61-
ControlPlaneNodeType: "t2.micro",
62-
WorkerPlaneNodeType: "t2.micro",
63-
DataStoreNodeType: "t2.micro",
64-
LoadBalancerNodeType: "t2.micro",
65-
Addons: addons.ClusterAddons{
66-
{
67-
Name: "cilium",
68-
Label: "ksctl",
69-
IsCNI: true,
70-
},
71-
},
72-
}
48+
meta := controller.Metadata{}
7349

74-
cli.NewBlueprintUI(os.Stdout).RenderClusterBlueprint(meta)
50+
k.baseMetadataFields(&meta)
7551

76-
// k.baseMetadataFields(&meta)
77-
78-
// if meta.ClusterType == consts.ClusterTypeMang {
79-
// k.metadataForManagedCluster(&meta)
80-
// } else {
81-
// k.metadataForSelfManagedCluster(&meta)
82-
// }
52+
if meta.ClusterType == consts.ClusterTypeMang {
53+
k.metadataForManagedCluster(&meta)
54+
} else {
55+
k.metadataForSelfManagedCluster(&meta)
56+
}
8357

84-
// k.l.Success(k.Ctx, "Created the cluster", "Name", meta.ClusterName)
58+
k.l.Success(k.Ctx, "Created the cluster", "Name", meta.ClusterName)
8559
},
8660
}
8761

pkg/cli/blueprint_ui.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,26 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
155155
MarginTop(1).
156156
Width(50)
157157

158-
for i, addon := range meta.Addons {
158+
for _, addon := range meta.Addons {
159159
addonTitle := color.HiMagentaString(addon.Name)
160160

161161
config := addon.Config
162162
vConfig := ""
163163
if config == nil {
164164
vConfig = "No configuration available"
165165
} else {
166-
vConfigBytes, _ := json.MarshalIndent(config, "", " ")
167-
vConfig = string(vConfigBytes)
166+
var v any
167+
if err := json.Unmarshal([]byte(*config), &v); err != nil {
168+
vConfig = "Invalid configuration format"
169+
} else {
170+
_v, _ := json.MarshalIndent(v, "\t", " ")
171+
vConfig = string(_v)
172+
}
168173
}
169174
addonInfo := fmt.Sprintf("%s\n\t%s: %s\n\t%s: %s",
170175
addonTitle,
171176
color.HiCyanString("From"),
172-
color.HiGreenString(addon.Label), // This would be replaced with actual type when available
177+
color.HiGreenString(addon.Label),
173178
color.HiCyanString("Config"),
174179
color.HiGreenString(vConfig),
175180
)
@@ -179,10 +184,9 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
179184

180185
fmt.Fprintln(ui.writer, addonBlock.Render(addonInfo))
181186

182-
// Add spacing between addons
183-
if i < len(meta.Addons)-1 {
184-
fmt.Fprintln(ui.writer)
185-
}
187+
// if i < len(meta.Addons)-1 {
188+
// fmt.Fprintln(ui.writer)
189+
// }
186190
}
187191
}
188192

@@ -192,8 +196,7 @@ func (ui *BlueprintUI) RenderClusterBlueprint(meta controller.Metadata) {
192196
Foreground(lipgloss.Color("#919191")).
193197
Padding(1, 0).
194198
MarginTop(1).
195-
Align(lipgloss.Center).
196-
Width(78)
199+
Align(lipgloss.Center)
197200

198201
fmt.Fprintln(ui.writer)
199202
fmt.Fprintln(ui.writer, noteStyle.Render("Your cluster will be provisioned with these specifications"))

0 commit comments

Comments
 (0)