github.com/supabase/cli@v1.168.1/internal/hostnames/reverify/reverify.go (about)

     1  package reverify
     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  	// 2. attempt to re-verify custom hostname config
    16  	{
    17  		resp, err := utils.GetSupabase().ReverifyWithResponse(ctx, projectRef)
    18  		if err != nil {
    19  			return errors.Errorf("failed to re-verify custom hostname: %w", err)
    20  		}
    21  		if resp.JSON201 == nil {
    22  			return errors.New("failed to re-verify custom hostname config: " + string(resp.Body))
    23  		}
    24  		status, err := hostnames.TranslateStatus(resp.JSON201, includeRawOutput)
    25  		if err != nil {
    26  			return err
    27  		}
    28  		fmt.Println(status)
    29  		return nil
    30  	}
    31  }