@@ -26,8 +26,12 @@ const (
2626 ProfileDemo = "demo"
2727)
2828
29+ var (
30+ Profiles = []string {ProfileMinimal , ProfileDemo }
31+ )
32+
2933// installChart installs or upgrades a Helm chart with the given parameters
30- func installChart (ctx context.Context , chartName string , namespace string , registry string , version string , setValues []string , s * spinner.Spinner ) (string , error ) {
34+ func installChart (ctx context.Context , chartName string , namespace string , registry string , version string , setValues []string , valuesFile string , s * spinner.Spinner ) (string , error ) {
3135 args := []string {
3236 "upgrade" ,
3337 "--install" ,
@@ -50,14 +54,18 @@ func installChart(ctx context.Context, chartName string, namespace string, regis
5054 args = append (args , "--set" , setValue )
5155 }
5256
57+ if valuesFile != "" {
58+ args = append (args , "-f" , valuesFile )
59+ }
60+
5361 cmd := exec .CommandContext (ctx , "helm" , args ... )
5462 if byt , err := cmd .CombinedOutput (); err != nil {
5563 return string (byt ), err
5664 }
5765 return "" , nil
5866}
5967
60- func InstallCmd (ctx context.Context , cfg * config.Config ) * PortForward {
68+ func InstallCmd (ctx context.Context , cfg * config.Config , profile string ) * PortForward {
6169 if version .Version == "dev" {
6270 fmt .Fprintln (os .Stderr , "Installation requires released version of kagent" )
6371 return nil
@@ -94,14 +102,27 @@ func InstallCmd(ctx context.Context, cfg *config.Config) *PortForward {
94102 values = append (values , hev )
95103 }
96104
105+ // Validate and normalize profile input
106+ profile = strings .TrimSpace (profile )
107+ switch profile {
108+ case "" :
109+ // default to minimal. no warning as this is the default
110+ profile = ProfileMinimal
111+ case ProfileDemo , ProfileMinimal :
112+ // valid, no change
113+ default :
114+ fmt .Fprintln (os .Stderr , "Invalid --profile value, defaulting to minimal" )
115+ profile = ProfileMinimal
116+ }
117+
97118 // spinner for installation progress
98119 s := spinner .New (spinner .CharSets [35 ], 100 * time .Millisecond )
99120
100121 // First install kagent-crds
101122 s .Suffix = " Installing kagent-crds from " + helmRegistry
102123 defer s .Stop ()
103124 s .Start ()
104- if output , err := installChart (ctx , "kagent-crds" , cfg .Namespace , helmRegistry , helmVersion , nil , s ); err != nil {
125+ if output , err := installChart (ctx , "kagent-crds" , cfg .Namespace , helmRegistry , helmVersion , nil , "" , s ); err != nil {
105126 // Always stop the spinner before printing error messages
106127 s .Stop ()
107128
@@ -120,24 +141,8 @@ func InstallCmd(ctx context.Context, cfg *config.Config) *PortForward {
120141 }
121142
122143 // Update status
123- var profile string
124- fmt .Fprintln (os .Stdout , "Select a profile:" )
125- fmt .Fprintln (os .Stdout , "1. Minimal (no agents enabled, default)" )
126- fmt .Fprintln (os .Stdout , "2. Demo (all agents enabled)" )
127- fmt .Fprint (os .Stdout , "Enter the profile number: " )
128- fmt .Scanln (& profile )
129- switch profile {
130- case "1" :
131- values = append (values , "-f" , GetHelmProfileUrl (ProfileMinimal ))
132- case "2" :
133- values = append (values , "-f" , GetHelmProfileUrl (ProfileDemo ))
134- default :
135- fmt .Fprintln (os .Stderr , "Invalid profile number, defaulting to minimal profile" )
136- values = append (values , "-f" , GetHelmProfileUrl (ProfileMinimal ))
137- }
138-
139- s .Suffix = fmt .Sprintf (" Installing kagent [%s] Using %s:%s %v" , modelProvider , helmRegistry , helmVersion , extraValues )
140- if output , err := installChart (ctx , "kagent" , cfg .Namespace , helmRegistry , helmVersion , values , s ); err != nil {
144+ s .Suffix = fmt .Sprintf (" Installing kagent with %s profile [%s] Using %s:%s %v" , profile , modelProvider , helmRegistry , helmVersion , extraValues )
145+ if output , err := installChart (ctx , "kagent" , cfg .Namespace , helmRegistry , helmVersion , values , GetHelmProfileUrl (profile ), s ); err != nil {
141146 // Always stop the spinner before printing error messages
142147 s .Stop ()
143148 fmt .Fprintln (os .Stderr , "Error installing kagent:" , output )
@@ -195,14 +200,18 @@ func InteractiveInstallCmd(ctx context.Context, c *ishell.Context) *PortForward
195200 values = append (values , hev )
196201 }
197202
203+ // Add profile selection
204+ profileIdx := c .MultiChoice (Profiles , "Select a profile:" )
205+ selectedProfile := Profiles [profileIdx ]
206+
198207 // spinner for installation progress
199208 s := spinner .New (spinner .CharSets [35 ], 100 * time .Millisecond )
200209
201210 // First install kagent-crds
202211 s .Suffix = " Installing kagent-crds from " + helmRegistry
203212 defer s .Stop ()
204213 s .Start ()
205- if output , err := installChart (ctx , "kagent-crds" , cfg .Namespace , helmRegistry , helmVersion , nil , s ); err != nil {
214+ if output , err := installChart (ctx , "kagent-crds" , cfg .Namespace , helmRegistry , helmVersion , nil , "" , s ); err != nil {
206215 // Always stop the spinner before printing error messages
207216 s .Stop ()
208217
@@ -220,14 +229,9 @@ func InteractiveInstallCmd(ctx context.Context, c *ishell.Context) *PortForward
220229 }
221230 }
222231
223- // Add profile selection
224- profiles := []string {ProfileMinimal , ProfileDemo }
225- profileIdx := c .MultiChoice (profiles , "Select a profile:" )
226- values = append (values , "-f" , GetHelmProfileUrl (profiles [profileIdx ]))
227-
228232 // Update status
229233 s .Suffix = fmt .Sprintf (" Installing kagent [%s] Using %s:%s %v" , modelProvider , helmRegistry , helmVersion , extraValues )
230- if output , err := installChart (ctx , "kagent" , cfg .Namespace , helmRegistry , helmVersion , values , s ); err != nil {
234+ if output , err := installChart (ctx , "kagent" , cfg .Namespace , helmRegistry , helmVersion , values , GetHelmProfileUrl ( selectedProfile ), s ); err != nil {
231235 // Always stop the spinner before printing error messages
232236 s .Stop ()
233237 fmt .Fprintln (os .Stderr , "Error installing kagent:" , output )
0 commit comments