github.com/supabase/cli@v1.168.1/internal/hostnames/activate/activate.go (about) 1 package activate 2 3 import ( 4 "context" 5 "fmt" 6 7 "github.com/go-errors/errors" 8 "github.com/spf13/afero" 9 "github.com/supabase/cli/internal/hostnames" 10 "github.com/supabase/cli/internal/utils" 11 ) 12 13 func Run(ctx context.Context, projectRef string, includeRawOutput bool, fsys afero.Fs) error { 14 // 1. Sanity checks. 15 { 16 resp, err := hostnames.GetCustomHostnameConfig(ctx, projectRef) 17 if err != nil { 18 return err 19 } 20 err = hostnames.VerifyCNAME(ctx, projectRef, resp.JSON200.CustomHostname) 21 if err != nil { 22 return err 23 } 24 } 25 26 // 2. activate custom hostname config 27 { 28 resp, err := utils.GetSupabase().ActivateWithResponse(ctx, projectRef) 29 if err != nil { 30 return errors.Errorf("failed to active custom hostname: %w", err) 31 } 32 if resp.JSON201 == nil { 33 return errors.New("failed to activate custom hostname config: " + string(resp.Body)) 34 } 35 status, err := hostnames.TranslateStatus(resp.JSON201, includeRawOutput) 36 if err != nil { 37 return err 38 } 39 fmt.Println(status) 40 return nil 41 } 42 }