github.com/supabase/cli@v1.168.1/internal/encryption/update/update.go (about) 1 package update 2 3 import ( 4 "context" 5 "fmt" 6 "os" 7 "strings" 8 9 "github.com/go-errors/errors" 10 "github.com/supabase/cli/internal/utils" 11 "github.com/supabase/cli/internal/utils/credentials" 12 "github.com/supabase/cli/pkg/api" 13 ) 14 15 func Run(ctx context.Context, projectRef string, stdin *os.File) error { 16 fmt.Fprintf(os.Stderr, "Enter a new root key: ") 17 input := credentials.PromptMasked(stdin) 18 resp, err := utils.GetSupabase().UpdatePgsodiumConfigWithResponse(ctx, projectRef, api.UpdatePgsodiumConfigBody{ 19 RootKey: strings.TrimSpace(input), 20 }) 21 if err != nil { 22 return errors.Errorf("failed to update pgsodium config: %w", err) 23 } 24 25 if resp.JSON200 == nil { 26 return errors.New("Unexpected error updating project root key: " + string(resp.Body)) 27 } 28 29 fmt.Println("Finished " + utils.Aqua("supabase root-key update") + ".") 30 return nil 31 }