@@ -28,7 +28,31 @@ func promptOrganizationID(ctx context.Context) (string, error) {
28
28
})
29
29
}
30
30
31
+ func promptManualProjectID (ctx context.Context , defaultProjectID string ) (string , error ) {
32
+ _ , _ = interactive .Println ()
33
+ return interactive .PromptStringWithConfig (& interactive.PromptStringConfig {
34
+ Ctx : ctx ,
35
+ Prompt : "Choose your default project ID" ,
36
+ DefaultValue : defaultProjectID ,
37
+ DefaultValueDoc : defaultProjectID ,
38
+ ValidateFunc : func (s string ) error {
39
+ if ! validation .IsProjectID (s ) {
40
+ return fmt .Errorf ("organization id is not a valid uuid" )
41
+ }
42
+ return nil
43
+ },
44
+ })
45
+ }
46
+
31
47
func promptProjectID (ctx context.Context , accessKey string , secretKey string , organizationID string , defaultProjectID string ) (string , error ) {
48
+ if defaultProjectID == "" {
49
+ defaultProjectID = organizationID
50
+ }
51
+
52
+ if ! interactive .IsInteractive {
53
+ return defaultProjectID , nil
54
+ }
55
+
32
56
client := core .ExtractClient (ctx )
33
57
api := account .NewAPI (client )
34
58
@@ -39,6 +63,10 @@ func promptProjectID(ctx context.Context, accessKey string, secretKey string, or
39
63
return "" , fmt .Errorf ("failed to list projects: %w" , err )
40
64
}
41
65
66
+ if len (res .Projects ) == 0 {
67
+ return promptManualProjectID (ctx , defaultProjectID )
68
+ }
69
+
42
70
defaultIndex := 0
43
71
44
72
projects := make ([]string , len (res .Projects ))
0 commit comments