Documentation
¶
Index ¶
- Constants
- Variables
- func Aqua(str string) string
- func AssertDockerIsRunning(ctx context.Context) error
- func AssertIsLinkedFS(fsys afero.Fs) error
- func AssertSupabaseCliIsSetUpFS(fsys afero.Fs) error
- func AssertSupabaseDbIsRunning() error
- func Bold(str string) string
- func ConnectByUrl(ctx context.Context, url string, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)
- func ConnectLocalPostgres(ctx context.Context, host string, port uint, database string, ...) (*pgx.Conn, error)
- func ConnectRemotePostgres(ctx context.Context, username, password, database, host string, ...) (*pgx.Conn, error)
- func DockerAddFile(ctx context.Context, container string, fileName string, content []byte) error
- func DockerExec(ctx context.Context, container string, cmd []string) (io.Reader, error)
- func DockerExecOnce(ctx context.Context, container string, env []string, cmd []string) (string, error)
- func DockerImagePull(ctx context.Context, image string, w io.Writer) error
- func DockerImagePullWithRetry(ctx context.Context, image string, retries int) error
- func DockerNetworkCreateIfNotExists(ctx context.Context, networkId string) error
- func DockerPullImageIfNotCached(ctx context.Context, imageName string) error
- func DockerRemove(containerId string)
- func DockerRemoveAll(ctx context.Context)
- func DockerRunOnce(ctx context.Context, image string, env []string, cmd []string) (string, error)
- func DockerRunOnceWithStream(ctx context.Context, image string, env, cmd, binds []string, ...) error
- func DockerStart(ctx context.Context, config container.Config, hostConfig container.HostConfig, ...) (string, error)
- func DockerStop(containerID string)
- func GetCurrentBranchFS(fsys afero.Fs) (string, error)
- func GetCurrentTimestamp() string
- func GetDenoPath() (string, error)
- func GetGitRoot(fsys afero.Fs) (*string, error)
- func GetProjectRoot(fsys afero.Fs) (string, error)
- func GetRegistryAuth() string
- func GetRegistryImageUrl(imageName string) string
- func GetSupabase() *supabase.ClientWithResponses
- func GetSupabaseAPIHost() string
- func GetSupabaseDashboardURL() string
- func GetSupabaseDbHost(projectRef string) string
- func GetSupabaseHost(projectRef string) string
- func InstallOrUpgradeDeno(ctx context.Context, fsys afero.Fs) error
- func IsBranchNameReserved(branch string) bool
- func LoadAccessToken() (string, error)
- func LoadAccessTokenFS(fsys afero.Fs) (string, error)
- func LoadConfig() error
- func LoadConfigFS(fsys afero.Fs) error
- func LoadProjectRef(fsys afero.Fs) (string, error)
- func MkdirIfNotExist(path string) error
- func MkdirIfNotExistFS(fsys afero.Fs, path string) error
- func NewDocker() *client.Client
- func NewError(s string) error
- func ProcessDiffOutput(diffBytes []byte) ([]byte, error)
- func ProcessDiffProgress(p Program, out io.Reader) error
- func ProcessPsqlOutput(out io.Reader, p Program) error
- func ProcessPullOutput(out io.ReadCloser, p Program) error
- func ResolveCNAME(ctx context.Context, host string) (string, error)
- func RunProgram(ctx context.Context, f func(p Program, ctx context.Context) error) error
- func ShortContainerImageName(imageName string) string
- func ValidateFunctionSlug(slug string) error
- func WaitAll(containers []string, exec func(container string))
- func WithTraceContext(ctx context.Context) context.Context
- func WriteConfig(fsys afero.Fs, test bool) error
- type DenoScriptDir
- type DiffDependencies
- type DiffEntry
- type DiffStream
- type EnumFlag
- type Program
- type ProgressMsg
- type PromptItem
- type PsqlMsg
- type StatusMsg
- type StatusWriter
Constants ¶
const ( Pg13Image = "supabase/postgres:13.3.0" Pg14Image = "supabase/postgres:14.1.0.89" Pg15Image = "supabase/postgres:15.1.0.33" // Append to ServiceImages when adding new dependencies below KongImage = "library/kong:2.8.1" InbucketImage = "inbucket/inbucket:3.0.3" PostgrestImage = "postgrest/postgrest:v10.1.1.20221215" DifferImage = "supabase/pgadmin-schema-diff:cli-0.0.5" MigraImage = "djrobstep/migra:3.0.1621480950" PgmetaImage = "supabase/postgres-meta:v0.60.7" StudioImage = "supabase/studio:20230127-6bfd87b" DenoRelayImage = "supabase/deno-relay:v1.5.0" ImageProxyImage = "darthsim/imgproxy:v3.8.0" EdgeRuntimeImage = "supabase/edge-runtime:v1.0.9" // Update initial schemas in internal/utils/templates/initial_schemas when // updating any one of these. GotrueImage = "supabase/gotrue:v2.40.1" RealtimeImage = "supabase/realtime:v2.4.0" StorageImage = "supabase/storage-api:v0.26.1" // Should be kept in-sync with DenoRelayImage DenoVersion = "1.28.0" )
const ( // https://dba.stackexchange.com/a/11895 // Args: dbname TerminateDbSqlFmt = `` /* 244-byte string literal not displayed */ AnonKey = "" /* 153-byte string literal not displayed */ ServiceRoleKey = "" /* 164-byte string literal not displayed */ JWTSecret = "super-secret-jwt-token-with-at-least-32-characters-long" AccessTokenKey = "access-token" )
Variables ¶
var ( DbImage string NetId string DbId string KongId string GotrueId string InbucketId string RealtimeId string RestId string StorageId string ImgProxyId string DifferId string PgmetaId string StudioId string DenoRelayId string InitialSchemaSql string //go:embed templates/initial_schemas/13.sql InitialSchemaPg13Sql string //go:embed templates/initial_schemas/14.sql InitialSchemaPg14Sql string //go:embed templates/initial_schemas/15.sql InitialSchemaPg15Sql string )
var ( Containers []string Volumes []string )
Used by unit tests NOTE: There's a risk of data race with reads & writes from `DockerRun` and reads from `DockerRemoveAll`, but since they're expected to be run on the same thread, this is fine.
var ( CmdSuggestion string // pg_dumpall --globals-only --no-role-passwords --dbname $DB_URL \ // | sed '/^CREATE ROLE postgres;/d' \ // | sed '/^ALTER ROLE postgres WITH /d' \ // | sed "/^ALTER ROLE .* WITH .* LOGIN /s/;$/ PASSWORD 'postgres';/" //go:embed templates/globals.sql GlobalsSql string AccessTokenPattern = regexp.MustCompile(`^sbp_[a-f0-9]{40}$`) ProjectRefPattern = regexp.MustCompile(`^[a-z]{20}$`) PostgresUrlPattern = regexp.MustCompile(`^postgres(?:ql)?:\/\/postgres:(.*)@(.+)\/postgres$`) MigrateFilePattern = regexp.MustCompile(`^([0-9]+)_.*\.sql$`) BranchNamePattern = regexp.MustCompile(`[[:word:]-]+`) FuncSlugPattern = regexp.MustCompile(`^[A-Za-z][A-Za-z0-9_-]*$`) ImageNamePattern = regexp.MustCompile(`\/(.*):`) // These schemas are ignored from schema diffs SystemSchemas = []string{ "information_schema", "pg_catalog", "pg_toast", "cron", "graphql", "graphql_public", "net", "pgsodium", "pgsodium_masks", "vault", } InternalSchemas = append([]string{ "auth", "extensions", "pgbouncer", "realtime", "_realtime", "storage", "supabase_functions", "supabase_migrations", }, SystemSchemas...) SupabaseDirPath = "supabase" ConfigPath = filepath.Join(SupabaseDirPath, "config.toml") ProjectRefPath = filepath.Join(SupabaseDirPath, ".temp", "project-ref") RemoteDbPath = filepath.Join(SupabaseDirPath, ".temp", "remote-db-url") CurrBranchPath = filepath.Join(SupabaseDirPath, ".branches", "_current_branch") MigrationsDir = filepath.Join(SupabaseDirPath, "migrations") FunctionsDir = filepath.Join(SupabaseDirPath, "functions") FallbackImportMapPath = filepath.Join(FunctionsDir, "import_map.json") DbTestsDir = filepath.Join(SupabaseDirPath, "tests") SeedDataPath = filepath.Join(SupabaseDirPath, "seed.sql") )
var Config config
var (
DenoPathOverride string
)
Used by unit tests
var Docker = NewDocker()
TODO: refactor to initialise lazily
var RegionMap = map[string]string{
"ap-northeast-1": "Northeast Asia (Tokyo)",
"ap-northeast-2": "Northeast Asia (Seoul)",
"ap-south-1": "South Asia (Mumbai)",
"ap-southeast-1": "Southeast Asia (Singapore)",
"ap-southeast-2": "Oceania (Sydney)",
"ca-central-1": "Canada (Central)",
"eu-central-1": "Central EU (Frankfurt)",
"eu-west-1": "West EU (Ireland)",
"eu-west-2": "West EU (London)",
"eu-west-3": "West EU (Paris)",
"sa-east-1": "South America (São Paulo)",
"us-east-1": "East US (North Virginia)",
"us-west-1": "West US (North California)",
}
var ServiceImages = []string{ GotrueImage, RealtimeImage, StorageImage, ImageProxyImage, KongImage, InbucketImage, PostgrestImage, DifferImage, MigraImage, PgmetaImage, StudioImage, DenoRelayImage, }
Functions ¶
func AssertDockerIsRunning ¶
func AssertIsLinkedFS ¶
func AssertSupabaseDbIsRunning ¶
func AssertSupabaseDbIsRunning() error
func ConnectByUrl ¶
func ConnectLocalPostgres ¶
func ConnectLocalPostgres(ctx context.Context, host string, port uint, database string, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)
Connnect to local Postgres with optimised settings. The caller is responsible for closing the connection returned.
func ConnectRemotePostgres ¶
func ConnectRemotePostgres(ctx context.Context, username, password, database, host string, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)
Connnect to remote Postgres with optimised settings. The caller is responsible for closing the connection returned.
func DockerAddFile ¶
func DockerExec ¶
func DockerExecOnce ¶
func DockerExecOnce(ctx context.Context, container string, env []string, cmd []string) (string, error)
Exec a command once inside a container, returning stdout and throwing error on non-zero exit code.
func DockerRemove ¶
func DockerRemove(containerId string)
func DockerRemoveAll ¶
func DockerRunOnce ¶
Runs a container image exactly once, returning stdout and throwing error on non-zero exit code.
func DockerRunOnceWithStream ¶
func DockerStart ¶
func DockerStop ¶
func DockerStop(containerID string)
func GetCurrentTimestamp ¶
func GetCurrentTimestamp() string
func GetDenoPath ¶
func GetProjectRoot ¶
If the `os.Getwd()` is within a supabase project, this will return the root of the given project as the current working directory. Otherwise, the `os.Getwd()` is kept as is.
func GetRegistryAuth ¶
func GetRegistryAuth() string
func GetRegistryImageUrl ¶
func GetSupabase ¶
func GetSupabase() *supabase.ClientWithResponses
func GetSupabaseAPIHost ¶
func GetSupabaseAPIHost() string
func GetSupabaseDashboardURL ¶
func GetSupabaseDashboardURL() string
func GetSupabaseDbHost ¶
func GetSupabaseHost ¶
func IsBranchNameReserved ¶
func LoadAccessToken ¶
func LoadConfig ¶
func LoadConfig() error
func LoadConfigFS ¶
func MkdirIfNotExist ¶
func ProcessDiffOutput ¶
func ProcessPullOutput ¶
func ProcessPullOutput(out io.ReadCloser, p Program) error
func RunProgram ¶
func ShortContainerImageName ¶
func ValidateFunctionSlug ¶
Types ¶
type DenoScriptDir ¶
func CopyDenoScripts ¶
Copy Deno scripts needed for function deploy and downloads, returning a DenoScriptDir struct or an error.
type DiffDependencies ¶
type DiffDependencies struct {
Type string `json:"type"`
}
type DiffStream ¶
type DiffStream struct {
// contains filtered or unexported fields
}
func NewDiffStream ¶
func NewDiffStream(p Program) *DiffStream
func (DiffStream) Collect ¶
func (c DiffStream) Collect() ([]byte, error)
func (DiffStream) Stderr ¶
func (c DiffStream) Stderr() io.Writer
func (DiffStream) Stdout ¶
func (c DiffStream) Stdout() io.Writer
type Program ¶
An interface describing the parts of BubbleTea's Program that we actually use.
func NewProgram ¶
func NewProgram(model tea.Model, opts ...tea.ProgramOption) Program
type ProgressMsg ¶
type ProgressMsg *float64
type PromptItem ¶
PromptItem is exposed as prompt input, empty summary + details will be excluded.
func PromptChoice ¶
func PromptChoice(ctx context.Context, title string, items []PromptItem) (PromptItem, error)
Prompt user to choose from a list of items, returns the chosen index.
func (PromptItem) Description ¶
func (i PromptItem) Description() string
func (PromptItem) FilterValue ¶
func (i PromptItem) FilterValue() string
func (PromptItem) Title ¶
func (i PromptItem) Title() string
type StatusWriter ¶
type StatusWriter struct {
Program
}