Skip to content

Export go config types #3162

Open
Open
@efitzkiwi

Description

@efitzkiwi

Is your feature request related to a problem? Please describe.
I'm trying to use the CLI source code in my Go application to make API calls and config updates to my supabase instance

Describe the solution you'd like
Export the Go fields for auth config, storage config, etc

Describe alternatives you've considered
Manually editing the source code

Additional context
For example

import (
	"context"
	"net/http"
	"time"

	"github.com/supabase/cli/pkg/api"
	"github.com/supabase/cli/pkg/config"
)

func NewApiClient(token string) api.ClientWithResponses {
	header := func(ctx context.Context, req *http.Request) error {
		req.Header.Set("Authorization", "Bearer "+token)
		return nil
	}
	client := api.ClientWithResponses{ClientInterface: &api.Client{
		// Ensure the server URL always has a trailing slash
		Server: "https://api.supabase.com/",
		Client: &http.Client{
			Timeout: 10 * time.Second,
		},
		RequestEditors: []api.RequestEditorFn{header},
	}}
	return client
}

func NewConfigClient(token string) config.ConfigUpdater {
	return config.NewConfigUpdater(NewApiClient(token))
}

func main() {
        // config.auth (among other types) is not exported... impossible to use this
        supabaseClient := NewConfigClient(supabaseToken)
        supabaseClient.UpdateAuthConfig(context.Background(), os.Getenv("SUPABASE_PROJECT_ID"), config.auth{})
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions