github.com/supabase/cli@v1.168.1/internal/ssl_enforcement/update/update.go (about) 1 package update 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/utils" 10 "github.com/supabase/cli/pkg/api" 11 ) 12 13 func Run(ctx context.Context, projectRef string, enforceDbSsl bool, fsys afero.Fs) error { 14 // 1. sanity checks 15 // 2. update restrictions 16 { 17 resp, err := utils.GetSupabase().UpdateSslEnforcementConfigWithResponse(ctx, projectRef, api.UpdateSslEnforcementConfigJSONRequestBody{ 18 RequestedConfig: api.SslEnforcements{ 19 Database: enforceDbSsl, 20 }, 21 }) 22 if err != nil { 23 return errors.Errorf("failed to update ssl enforcement: %w", err) 24 } 25 if resp.JSON200 == nil { 26 return errors.New("failed to update SSL enforcement confnig: " + string(resp.Body)) 27 } 28 if resp.JSON200.CurrentConfig.Database && resp.JSON200.AppliedSuccessfully { 29 fmt.Println("SSL is now being enforced.") 30 } else { 31 fmt.Println("SSL is *NOT* being enforced.") 32 } 33 return nil 34 } 35 }