github.com/supabase/cli@v1.168.1/internal/branches/get/get.go (about) 1 package get 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/go-errors/errors" 8 "github.com/supabase/cli/internal/migration/list" 9 "github.com/supabase/cli/internal/utils" 10 ) 11 12 func Run(ctx context.Context, branchId string) error { 13 resp, err := utils.GetSupabase().GetBranchDetailsWithResponse(ctx, branchId) 14 if err != nil { 15 return errors.Errorf("failed to retrieve preview branch: %w", err) 16 } 17 if resp.JSON200 == nil { 18 return errors.New("Unexpected error retrieving preview branch: " + string(resp.Body)) 19 } 20 21 masked := "******" 22 if resp.JSON200.DbUser == nil { 23 resp.JSON200.DbUser = &masked 24 } 25 if resp.JSON200.DbPass == nil { 26 resp.JSON200.DbPass = &masked 27 } 28 if resp.JSON200.JwtSecret == nil { 29 resp.JSON200.JwtSecret = &masked 30 } 31 32 table := `|HOST|PORT|USER|PASSWORD|JWT SECRET|POSTGRES VERSION|STATUS| 33 |-|-|-|-|-|-|-| 34 ` + fmt.Sprintf( 35 "|`%s`|`%d`|`%s`|`%s`|`%s`|`%s`|`%s`|\n", 36 resp.JSON200.DbHost, 37 resp.JSON200.DbPort, 38 *resp.JSON200.DbUser, 39 *resp.JSON200.DbPass, 40 *resp.JSON200.JwtSecret, 41 resp.JSON200.PostgresVersion, 42 resp.JSON200.Status, 43 ) 44 return list.RenderTable(table) 45 }