11package auth
22
33import (
4- "fmt "
4+ "errors "
55 "strings"
66
77 "github.com/verda-cloud/verdagostack/pkg/tui/wizard"
88)
99
10- const defaultBaseURL = "https://api.verda.com/v1"
10+ const (
11+ defaultBaseURL = "https://api.verda.com/v1"
12+ defaultProfileName = "default"
13+ )
1114
1215// buildLoginFlow builds the interactive wizard flow for auth login.
1316//
@@ -34,16 +37,16 @@ func loginStepProfile(opts *loginOptions) wizard.Step {
3437 Description : "Profile name" ,
3538 Prompt : wizard .TextInputPrompt ,
3639 Required : true ,
37- Default : func (_ map [string ]any ) any { return "default" },
40+ Default : func (_ map [string ]any ) any { return defaultProfileName },
3841 Validate : func (v any ) error {
3942 if strings .TrimSpace (v .(string )) == "" {
40- return fmt . Errorf ("profile name cannot be empty" )
43+ return errors . New ("profile name cannot be empty" )
4144 }
4245 return nil
4346 },
4447 Setter : func (v any ) { opts .Profile = strings .TrimSpace (v .(string )) },
45- Resetter : func () { opts .Profile = "default" },
46- IsSet : func () bool { return opts .Profile != "" && opts .Profile != "default" },
48+ Resetter : func () { opts .Profile = defaultProfileName },
49+ IsSet : func () bool { return opts .Profile != "" && opts .Profile != defaultProfileName },
4750 Value : func () any { return opts .Profile },
4851 }
4952}
@@ -58,10 +61,10 @@ func loginStepBaseURL(opts *loginOptions) wizard.Step {
5861 Validate : func (v any ) error {
5962 s := strings .TrimSpace (v .(string ))
6063 if s == "" {
61- return fmt . Errorf ("base URL cannot be empty" )
64+ return errors . New ("base URL cannot be empty" )
6265 }
6366 if ! strings .HasPrefix (s , "http://" ) && ! strings .HasPrefix (s , "https://" ) {
64- return fmt . Errorf ("base URL must start with http:// or https://" )
67+ return errors . New ("base URL must start with http:// or https://" )
6568 }
6669 return nil
6770 },
@@ -80,7 +83,7 @@ func loginStepClientID(opts *loginOptions) wizard.Step {
8083 Required : true ,
8184 Validate : func (v any ) error {
8285 if strings .TrimSpace (v .(string )) == "" {
83- return fmt . Errorf ("client ID cannot be empty" )
86+ return errors . New ("client ID cannot be empty" )
8487 }
8588 return nil
8689 },
0 commit comments