github.com/supabase/cli@v1.168.1/internal/secrets/unset/unset.go (about)

     1  package unset
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"net/http"
     7  
     8  	"github.com/go-errors/errors"
     9  	"github.com/spf13/afero"
    10  	"github.com/supabase/cli/internal/utils"
    11  )
    12  
    13  func Run(ctx context.Context, projectRef string, args []string, fsys afero.Fs) error {
    14  	// 1. Sanity checks.
    15  	// 2. Unset secret(s).
    16  	{
    17  		resp, err := utils.GetSupabase().DeleteSecretsWithResponse(ctx, projectRef, args)
    18  		if err != nil {
    19  			return errors.Errorf("failed to delete secrets: %w", err)
    20  		}
    21  
    22  		if resp.StatusCode() != http.StatusOK {
    23  			return errors.New("Unexpected error unsetting project secrets: " + string(resp.Body))
    24  		}
    25  	}
    26  
    27  	fmt.Println("Finished " + utils.Aqua("supabase secrets unset") + ".")
    28  	return nil
    29  }