diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fdc32c4a7..390b1ec66 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,6 +79,21 @@ jobs: env: SUPABASE_INTERNAL_IMAGE_REGISTRY: ghcr.io + link: + name: Link + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-go@v6 + with: + go-version-file: go.mod + cache: true + - run: go build main.go + - run: ./main link + env: + SUPABASE_ACCESS_TOKEN: ${{ secrets.SUPABASE_ACCESS_TOKEN }} + SUPABASE_PROJECT_ID: ${{ secrets.SUPABASE_PROJECT_ID }} + codegen: name: Codegen runs-on: ubuntu-latest diff --git a/fsevents/fsevents.go b/fsevents/fsevents.go new file mode 100644 index 000000000..d75d31932 --- /dev/null +++ b/fsevents/fsevents.go @@ -0,0 +1,117 @@ +//go:build darwin + +// Package fsevents provides file system notifications on macOS. +package fsevents + +import ( + "syscall" + "time" +) + +// Event represents a single file system notification. +type Event struct { + // Path holds the path to the item that's changed, relative + // to its device's root. + // Use DeviceForPath to determine the absolute path that's + // being referred to. + Path string + + // Flags holds details what has happened. + Flags EventFlags + + // ID holds the event ID. + // + // Each event ID comes from the most recent event being reported + // in the corresponding directory named in the EventStream.Paths field + // Event IDs all come from a single global source. + // They are guaranteed to always be increasing, usually in leaps + // and bounds, even across system reboots and moving drives from + // one machine to another. If you were to + // stop processing events from this stream after this event + // and resume processing them later from a newly-created + // EventStream, this is the value you would pass for the + // EventStream.EventID along with Resume=true. + ID uint64 +} + +// DeviceForPath returns the device ID for the specified volume. +func DeviceForPath(path string) (int32, error) { + stat := syscall.Stat_t{} + if err := syscall.Lstat(path, &stat); err != nil { + return 0, err + } + return stat.Dev, nil +} + +// EventStream is the primary interface to FSEvents +// You can provide your own event channel if you wish (or one will be +// created on Start). +// +// es := &EventStream{Paths: []string{"/tmp"}, Flags: 0} +// es.Start() +// es.Stop() +// ... +type EventStream struct { + // Events holds the channel on which events will be sent. + // It's initialized by EventStream.Start if nil. + Events chan []Event + + // Paths holds the set of paths to watch, each + // specifying the root of a filesystem hierarchy to be + // watched for modifications. + Paths []string + + // Flags specifies what events to receive on the stream. + Flags CreateFlags + + // Resume specifies that watching should resume from the event + // specified by EventID. + Resume bool + + // EventID holds the most recent event ID. + // + // NOTE: this is updated asynchronously by the + // watcher and should not be accessed while + // the stream has been started. + EventID uint64 + + // Latency holds the number of seconds the service should wait after hearing + // about an event from the kernel before passing it along to the + // client via its callback. Specifying a larger value may result + // in more effective temporal coalescing, resulting in fewer + // callbacks and greater overall efficiency. + Latency time.Duration + + // When Device is non-zero, the watcher will watch events on the + // device with this ID, and the paths in the Paths field are + // interpreted relative to the device's root. + // + // The device ID is the same as the st_dev field from a stat + // structure of a file on that device or the f_fsid[0] field of + // a statfs structure. + Device int32 +} + +// Start listening to an event stream. This creates es.Events if it's not already +// a valid channel. +func (es *EventStream) Start() error { + return nil +} + +// Flush flushes events that have occurred but haven't been delivered. +// If sync is true, it will block until all the events have been delivered, +// otherwise it will return immediately. +func (es *EventStream) Flush(sync bool) { +} + +// Stop stops listening to the event stream. +func (es *EventStream) Stop() { +} + +// Restart restarts the event listener. This +// can be used to change the current watch flags. +func (es *EventStream) Restart() error { + es.Stop() + es.Resume = true + return es.Start() +} diff --git a/fsevents/go.mod b/fsevents/go.mod new file mode 100644 index 000000000..41e670c56 --- /dev/null +++ b/fsevents/go.mod @@ -0,0 +1,3 @@ +go 1.24.10 + +module github.com/fsnotify/fsevents diff --git a/fsevents/wrap.go b/fsevents/wrap.go new file mode 100644 index 000000000..f12125b7e --- /dev/null +++ b/fsevents/wrap.go @@ -0,0 +1,40 @@ +//go:build darwin + +package fsevents + +// CreateFlags specifies what events will be seen in an event stream. +type CreateFlags uint32 + +const ( + // IgnoreSelf doesn't send events triggered by the current process (macOS 10.6+). + // + // Don't send events that were triggered by the current process. + // This is useful for reducing the volume of events that are + // sent. It is only useful if your process might modify the file + // system hierarchy beneath the path(s) being monitored. Note: + // this has no effect on historical events, i.e., those + // delivered before the HistoryDone sentinel event. + IgnoreSelf = CreateFlags(0) + + // FileEvents sends events about individual files, generating significantly + // more events (macOS 10.7+) than directory level notifications. + FileEvents = CreateFlags(1) +) + +// EventFlags passed to the FSEventStreamCallback function. +// These correspond directly to the flags as described here: +// https://developer.apple.com/documentation/coreservices/1455361-fseventstreameventflags +type EventFlags uint32 + +const ( + // ItemCreated indicates that a file or directory has been created. + ItemCreated = EventFlags(0) + + // ItemIsDir indicates that the item is a directory. + ItemIsDir = EventFlags(1) +) + +// LatestEventID returns the most recently generated event ID, system-wide. +func LatestEventID() uint64 { + return 0 +} diff --git a/go.mod b/go.mod index 862365979..5ce13247d 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/supabase/cli -go 1.24.9 +go 1.24.10 require ( github.com/BurntSushi/toml v1.5.0 @@ -129,7 +129,7 @@ require ( github.com/cloudflare/circl v1.6.1 // indirect github.com/containerd/console v1.0.5 // indirect github.com/containerd/containerd/api v1.9.0 // indirect - github.com/containerd/containerd/v2 v2.1.4 // indirect + github.com/containerd/containerd/v2 v2.1.5 // indirect github.com/containerd/continuity v0.4.5 // indirect github.com/containerd/errdefs/pkg v0.3.0 // indirect github.com/containerd/log v0.1.0 // indirect @@ -455,6 +455,8 @@ require ( replace github.com/supabase/cli/pkg v1.0.0 => ./pkg +replace github.com/fsnotify/fsevents v0.2.0 => ./fsevents + tool ( github.com/golangci/golangci-lint/v2/cmd/golangci-lint github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen diff --git a/go.sum b/go.sum index 732a1190e..c18199eef 100644 --- a/go.sum +++ b/go.sum @@ -206,8 +206,8 @@ github.com/containerd/console v1.0.5 h1:R0ymNeydRqH2DmakFNdmjR2k0t7UPuiOV/N/27/q github.com/containerd/console v1.0.5/go.mod h1:YynlIjWYF8myEu6sdkwKIvGQq+cOckRm6So2avqoYAk= github.com/containerd/containerd/api v1.9.0 h1:HZ/licowTRazus+wt9fM6r/9BQO7S0vD5lMcWspGIg0= github.com/containerd/containerd/api v1.9.0/go.mod h1:GhghKFmTR3hNtyznBoQ0EMWr9ju5AqHjcZPsSpTKutI= -github.com/containerd/containerd/v2 v2.1.4 h1:/hXWjiSFd6ftrBOBGfAZ6T30LJcx1dBjdKEeI8xucKQ= -github.com/containerd/containerd/v2 v2.1.4/go.mod h1:8C5QV9djwsYDNhxfTCFjWtTBZrqjditQ4/ghHSYjnHM= +github.com/containerd/containerd/v2 v2.1.5 h1:pWSmPxUszaLZKQPvOx27iD4iH+aM6o0BoN9+hg77cro= +github.com/containerd/containerd/v2 v2.1.5/go.mod h1:8C5QV9djwsYDNhxfTCFjWtTBZrqjditQ4/ghHSYjnHM= github.com/containerd/continuity v0.4.5 h1:ZRoN1sXq9u7V6QoHMcVWGhOwDFqZ4B9i5H6un1Wh0x4= github.com/containerd/continuity v0.4.5/go.mod h1:/lNJvtJKUQStBzpVQ1+rasXO1LAWtUQssk28EZvJ3nE= github.com/containerd/errdefs v1.0.0 h1:tg5yIfIlQIrxYtu9ajqY42W3lpS19XqdxRQeEwYG8PI= @@ -327,8 +327,6 @@ github.com/firefart/nonamedreturns v1.0.6 h1:vmiBcKV/3EqKY3ZiPxCINmpS431OcE1S47A github.com/firefart/nonamedreturns v1.0.6/go.mod h1:R8NisJnSIpvPWheCq0mNRXJok6D8h7fagJTF8EMEwCo= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/fsnotify/fsevents v0.2.0 h1:BRlvlqjvNTfogHfeBOFvSC9N0Ddy+wzQCQukyoD7o/c= -github.com/fsnotify/fsevents v0.2.0/go.mod h1:B3eEk39i4hz8y1zaWS/wPrAP4O6wkIl7HQwKBr1qH/w= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= diff --git a/internal/utils/flags/db_url.go b/internal/utils/flags/db_url.go index 4dca1d936..26282d346 100644 --- a/internal/utils/flags/db_url.go +++ b/internal/utils/flags/db_url.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "strings" + "time" "github.com/cenkalti/backoff/v4" "github.com/go-errors/errors" @@ -131,17 +132,22 @@ func NewDbConfigWithPassword(ctx context.Context, projectRef string) (pgconn.Con } logger := utils.GetDebugLogger() // Use pooler if host is not reachable directly - if _, err := net.DefaultResolver.LookupIPAddr(ctx, config.Host); err != nil { - if poolerConfig := utils.GetPoolerConfig(projectRef); poolerConfig != nil { - if len(config.Password) > 0 { - fmt.Fprintln(logger, "Using database password from env var...") - poolerConfig.Password = config.Password - } else if err := initPoolerLogin(ctx, projectRef, poolerConfig); err != nil { - utils.CmdSuggestion = suggestEnvVar - return *poolerConfig, err - } - return *poolerConfig, nil + d := net.Dialer{Timeout: 5 * time.Second} + if conn, err := d.DialContext(ctx, "udp", config.Host+":53"); err == nil { + if err := conn.Close(); err != nil { + fmt.Fprintln(logger, err) + } + fmt.Fprintf(logger, "Resolved DNS: %v\n", conn.RemoteAddr()) + } else if poolerConfig := utils.GetPoolerConfig(projectRef); poolerConfig != nil { + if len(config.Password) > 0 { + fmt.Fprintln(logger, "Using database password from env var...") + poolerConfig.Password = config.Password + } else if err := initPoolerLogin(ctx, projectRef, poolerConfig); err != nil { + utils.CmdSuggestion = suggestEnvVar + return *poolerConfig, err } + return *poolerConfig, nil + } else { utils.CmdSuggestion = fmt.Sprintf("Run %s to setup IPv4 connection.", utils.Aqua("supabase link --project-ref "+projectRef)) return config, errors.Errorf("IPv6 is not supported on your current network: %w", err) } diff --git a/pkg/api/client.gen.go b/pkg/api/client.gen.go index 46557d73f..bf73deb2a 100644 --- a/pkg/api/client.gen.go +++ b/pkg/api/client.gen.go @@ -178,6 +178,11 @@ type ClientInterface interface { // V1GetProject request V1GetProject(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1UpdateAProjectWithBody request with any body + V1UpdateAProjectWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1UpdateAProject(ctx context.Context, ref string, body V1UpdateAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1ListActionRuns request V1ListActionRuns(ctx context.Context, ref string, params *V1ListActionRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -459,6 +464,11 @@ type ClientInterface interface { V1PatchAMigration(ctx context.Context, ref string, version string, body V1PatchAMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1UpdateDatabasePasswordWithBody request with any body + V1UpdateDatabasePasswordWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + V1UpdateDatabasePassword(ctx context.Context, ref string, body V1UpdateDatabasePasswordJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // V1RunAQueryWithBody request with any body V1RunAQueryWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1018,6 +1028,30 @@ func (c *Client) V1GetProject(ctx context.Context, ref string, reqEditors ...Req return c.Client.Do(req) } +func (c *Client) V1UpdateAProjectWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateAProjectRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1UpdateAProject(ctx context.Context, ref string, body V1UpdateAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateAProjectRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1ListActionRuns(ctx context.Context, ref string, params *V1ListActionRunsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1ListActionRunsRequest(c.Server, ref, params) if err != nil { @@ -2232,6 +2266,30 @@ func (c *Client) V1PatchAMigration(ctx context.Context, ref string, version stri return c.Client.Do(req) } +func (c *Client) V1UpdateDatabasePasswordWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateDatabasePasswordRequestWithBody(c.Server, ref, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) V1UpdateDatabasePassword(ctx context.Context, ref string, body V1UpdateDatabasePasswordJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewV1UpdateDatabasePasswordRequest(c.Server, ref, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) V1RunAQueryWithBody(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewV1RunAQueryRequestWithBody(c.Server, ref, contentType, body) if err != nil { @@ -4323,6 +4381,53 @@ func NewV1GetProjectRequest(server string, ref string) (*http.Request, error) { return req, nil } +// NewV1UpdateAProjectRequest calls the generic V1UpdateAProject builder with application/json body +func NewV1UpdateAProjectRequest(server string, ref string, body V1UpdateAProjectJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1UpdateAProjectRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewV1UpdateAProjectRequestWithBody generates requests for V1UpdateAProject with any type of body +func NewV1UpdateAProjectRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1ListActionRunsRequest generates requests for V1ListActionRuns func NewV1ListActionRunsRequest(server string, ref string, params *V1ListActionRunsParams) (*http.Request, error) { var err error @@ -7784,6 +7889,53 @@ func NewV1PatchAMigrationRequestWithBody(server string, ref string, version stri return req, nil } +// NewV1UpdateDatabasePasswordRequest calls the generic V1UpdateDatabasePassword builder with application/json body +func NewV1UpdateDatabasePasswordRequest(server string, ref string, body V1UpdateDatabasePasswordJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewV1UpdateDatabasePasswordRequestWithBody(server, ref, "application/json", bodyReader) +} + +// NewV1UpdateDatabasePasswordRequestWithBody generates requests for V1UpdateDatabasePassword with any type of body +func NewV1UpdateDatabasePasswordRequestWithBody(server string, ref string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "ref", runtime.ParamLocationPath, ref) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/v1/projects/%s/database/password", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewV1RunAQueryRequest calls the generic V1RunAQuery builder with application/json body func NewV1RunAQueryRequest(server string, ref string, body V1RunAQueryJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -10174,6 +10326,11 @@ type ClientWithResponsesInterface interface { // V1GetProjectWithResponse request V1GetProjectWithResponse(ctx context.Context, ref string, reqEditors ...RequestEditorFn) (*V1GetProjectResponse, error) + // V1UpdateAProjectWithBodyWithResponse request with any body + V1UpdateAProjectWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateAProjectResponse, error) + + V1UpdateAProjectWithResponse(ctx context.Context, ref string, body V1UpdateAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateAProjectResponse, error) + // V1ListActionRunsWithResponse request V1ListActionRunsWithResponse(ctx context.Context, ref string, params *V1ListActionRunsParams, reqEditors ...RequestEditorFn) (*V1ListActionRunsResponse, error) @@ -10455,6 +10612,11 @@ type ClientWithResponsesInterface interface { V1PatchAMigrationWithResponse(ctx context.Context, ref string, version string, body V1PatchAMigrationJSONRequestBody, reqEditors ...RequestEditorFn) (*V1PatchAMigrationResponse, error) + // V1UpdateDatabasePasswordWithBodyWithResponse request with any body + V1UpdateDatabasePasswordWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateDatabasePasswordResponse, error) + + V1UpdateDatabasePasswordWithResponse(ctx context.Context, ref string, body V1UpdateDatabasePasswordJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateDatabasePasswordResponse, error) + // V1RunAQueryWithBodyWithResponse request with any body V1RunAQueryWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RunAQueryResponse, error) @@ -11153,6 +11315,28 @@ func (r V1GetProjectResponse) StatusCode() int { return 0 } +type V1UpdateAProjectResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *V1ProjectRefResponse +} + +// Status returns HTTPResponse.Status +func (r V1UpdateAProjectResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1UpdateAProjectResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1ListActionRunsResponse struct { Body []byte HTTPResponse *http.Response @@ -12832,6 +13016,28 @@ func (r V1PatchAMigrationResponse) StatusCode() int { return 0 } +type V1UpdateDatabasePasswordResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *V1UpdatePasswordResponse +} + +// Status returns HTTPResponse.Status +func (r V1UpdateDatabasePasswordResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r V1UpdateDatabasePasswordResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type V1RunAQueryResponse struct { Body []byte HTTPResponse *http.Response @@ -14110,6 +14316,23 @@ func (c *ClientWithResponses) V1GetProjectWithResponse(ctx context.Context, ref return ParseV1GetProjectResponse(rsp) } +// V1UpdateAProjectWithBodyWithResponse request with arbitrary body returning *V1UpdateAProjectResponse +func (c *ClientWithResponses) V1UpdateAProjectWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateAProjectResponse, error) { + rsp, err := c.V1UpdateAProjectWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateAProjectResponse(rsp) +} + +func (c *ClientWithResponses) V1UpdateAProjectWithResponse(ctx context.Context, ref string, body V1UpdateAProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateAProjectResponse, error) { + rsp, err := c.V1UpdateAProject(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateAProjectResponse(rsp) +} + // V1ListActionRunsWithResponse request returning *V1ListActionRunsResponse func (c *ClientWithResponses) V1ListActionRunsWithResponse(ctx context.Context, ref string, params *V1ListActionRunsParams, reqEditors ...RequestEditorFn) (*V1ListActionRunsResponse, error) { rsp, err := c.V1ListActionRuns(ctx, ref, params, reqEditors...) @@ -14997,6 +15220,23 @@ func (c *ClientWithResponses) V1PatchAMigrationWithResponse(ctx context.Context, return ParseV1PatchAMigrationResponse(rsp) } +// V1UpdateDatabasePasswordWithBodyWithResponse request with arbitrary body returning *V1UpdateDatabasePasswordResponse +func (c *ClientWithResponses) V1UpdateDatabasePasswordWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1UpdateDatabasePasswordResponse, error) { + rsp, err := c.V1UpdateDatabasePasswordWithBody(ctx, ref, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateDatabasePasswordResponse(rsp) +} + +func (c *ClientWithResponses) V1UpdateDatabasePasswordWithResponse(ctx context.Context, ref string, body V1UpdateDatabasePasswordJSONRequestBody, reqEditors ...RequestEditorFn) (*V1UpdateDatabasePasswordResponse, error) { + rsp, err := c.V1UpdateDatabasePassword(ctx, ref, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseV1UpdateDatabasePasswordResponse(rsp) +} + // V1RunAQueryWithBodyWithResponse request with arbitrary body returning *V1RunAQueryResponse func (c *ClientWithResponses) V1RunAQueryWithBodyWithResponse(ctx context.Context, ref string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*V1RunAQueryResponse, error) { rsp, err := c.V1RunAQueryWithBody(ctx, ref, contentType, body, reqEditors...) @@ -16129,6 +16369,32 @@ func ParseV1GetProjectResponse(rsp *http.Response) (*V1GetProjectResponse, error return response, nil } +// ParseV1UpdateAProjectResponse parses an HTTP response from a V1UpdateAProjectWithResponse call +func ParseV1UpdateAProjectResponse(rsp *http.Response) (*V1UpdateAProjectResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1UpdateAProjectResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest V1ProjectRefResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1ListActionRunsResponse parses an HTTP response from a V1ListActionRunsWithResponse call func ParseV1ListActionRunsResponse(rsp *http.Response) (*V1ListActionRunsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -17981,6 +18247,32 @@ func ParseV1PatchAMigrationResponse(rsp *http.Response) (*V1PatchAMigrationRespo return response, nil } +// ParseV1UpdateDatabasePasswordResponse parses an HTTP response from a V1UpdateDatabasePasswordWithResponse call +func ParseV1UpdateDatabasePasswordResponse(rsp *http.Response) (*V1UpdateDatabasePasswordResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &V1UpdateDatabasePasswordResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest V1UpdatePasswordResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParseV1RunAQueryResponse parses an HTTP response from a V1RunAQueryWithResponse call func ParseV1RunAQueryResponse(rsp *http.Response) (*V1RunAQueryResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) diff --git a/pkg/api/types.gen.go b/pkg/api/types.gen.go index 807a266ce..27402ad64 100644 --- a/pkg/api/types.gen.go +++ b/pkg/api/types.gen.go @@ -4318,6 +4318,16 @@ type V1UpdateFunctionBody struct { VerifyJwt *bool `json:"verify_jwt,omitempty"` } +// V1UpdatePasswordBody defines model for V1UpdatePasswordBody. +type V1UpdatePasswordBody struct { + Password string `json:"password"` +} + +// V1UpdatePasswordResponse defines model for V1UpdatePasswordResponse. +type V1UpdatePasswordResponse struct { + Message string `json:"message"` +} + // V1UpdatePostgrestConfigBody defines model for V1UpdatePostgrestConfigBody. type V1UpdatePostgrestConfigBody struct { DbExtraSearchPath *string `json:"db_extra_search_path,omitempty"` @@ -4326,6 +4336,11 @@ type V1UpdatePostgrestConfigBody struct { MaxRows *int `json:"max_rows,omitempty"` } +// V1UpdateProjectBody defines model for V1UpdateProjectBody. +type V1UpdateProjectBody struct { + Name string `json:"name"` +} + // V1UpsertMigrationBody defines model for V1UpsertMigrationBody. type V1UpsertMigrationBody struct { Name *string `json:"name,omitempty"` @@ -4653,6 +4668,9 @@ type V1CreateAnOrganizationJSONRequestBody = CreateOrganizationV1 // V1CreateAProjectJSONRequestBody defines body for V1CreateAProject for application/json ContentType. type V1CreateAProjectJSONRequestBody = V1CreateProjectBody +// V1UpdateAProjectJSONRequestBody defines body for V1UpdateAProject for application/json ContentType. +type V1UpdateAProjectJSONRequestBody = V1UpdateProjectBody + // V1UpdateActionRunStatusJSONRequestBody defines body for V1UpdateActionRunStatus for application/json ContentType. type V1UpdateActionRunStatusJSONRequestBody = UpdateRunStatusBody @@ -4725,6 +4743,9 @@ type V1UpsertAMigrationJSONRequestBody = V1UpsertMigrationBody // V1PatchAMigrationJSONRequestBody defines body for V1PatchAMigration for application/json ContentType. type V1PatchAMigrationJSONRequestBody = V1PatchMigrationBody +// V1UpdateDatabasePasswordJSONRequestBody defines body for V1UpdateDatabasePassword for application/json ContentType. +type V1UpdateDatabasePasswordJSONRequestBody = V1UpdatePasswordBody + // V1RunAQueryJSONRequestBody defines body for V1RunAQuery for application/json ContentType. type V1RunAQueryJSONRequestBody = V1RunQueryBody diff --git a/pkg/go.mod b/pkg/go.mod index 1d4cb6c85..2dfb67c77 100644 --- a/pkg/go.mod +++ b/pkg/go.mod @@ -1,6 +1,6 @@ module github.com/supabase/cli/pkg -go 1.24.4 +go 1.24.10 require ( github.com/BurntSushi/toml v1.5.0