utils

package
v0.34.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GotrueImage   = "supabase/gotrue:v2.6.18"
	RealtimeImage = "supabase/realtime:v0.22.4"
	StorageImage  = "supabase/storage-api:v0.15.0"
)

Update initial schemas in internal/utils/templates/initial_schemas when updating any one of these.

View Source
const (
	ShadowDbName   = "supabase_shadow"
	KongImage      = "library/kong:2.1"
	InbucketImage  = "inbucket/inbucket:stable"
	PostgrestImage = "postgrest/postgrest:v9.0.0.20220211"
	DifferImage    = "supabase/pgadmin-schema-diff:cli-0.0.4"
	PgmetaImage    = "supabase/postgres-meta:v0.42.1"
	// TODO: Hardcode version once provided upstream.
	StudioImage    = "supabase/studio:latest"
	DenoRelayImage = "supabase/deno-relay:v1.2.0"

	// https://dba.stackexchange.com/a/11895
	// Args: dbname
	TerminateDbSqlFmt = `` /* 215-byte string literal not displayed */

	AnonKey        = "" /* 131-byte string literal not displayed */
	ServiceRoleKey = "" /* 141-byte string literal not displayed */

	ConfigPath     = "supabase/config.toml"
	ProjectRefPath = "supabase/.temp/project-ref"
	RemoteDbPath   = "supabase/.temp/remote-db-url"
	CurrBranchPath = "supabase/.branches/_current_branch"
)

Variables

View Source
var (
	DbImage     string
	NetId       string
	DbId        string
	KongId      string
	GotrueId    string
	InbucketId  string
	RealtimeId  string
	RestId      string
	StorageId   string
	DifferId    string
	PgmetaId    string
	StudioId    string
	DenoRelayId string

	InitialSchemaSql string
)
View Source
var (
	// 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:(.+)@(.+?)(:\d+)?/postgres$`)
	MigrateFilePattern = regexp.MustCompile(`([0-9]+)_.*\.sql`)
	BranchNamePattern  = regexp.MustCompile(`[[:word:]-]+`)

	// These schemas are ignored from schema diffs
	InternalSchemas = []string{"auth", "extensions", "graphql_public", "pgbouncer", "realtime", "storage", "supabase_functions", "supabase_migrations", "pg_catalog", "pg_toast", "information_schema"}
)
View Source
var Config config
View Source
var Docker = func() *client.Client {
	docker, err := client.NewClientWithOpts(
		client.WithAPIVersionNegotiation(),

		client.FromEnv,
	)
	if err != nil {
		fmt.Fprintln(os.Stderr, "Failed to initialize Docker client:", err)
		os.Exit(1)
	}
	return docker
}()
View Source
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)",
	"sa-east-1":      "South America (São Paulo)",
	"us-east-1":      "East US (North Virginia)",
	"us-west-1":      "West US (North California)",
}

Functions

func Aqua added in v0.15.6

func Aqua(str string) string

For commands & names.

func AssertDockerIsRunning

func AssertDockerIsRunning() error

func AssertIsLinked added in v0.20.0

func AssertIsLinked() error

func AssertIsLinkedFS added in v0.32.0

func AssertIsLinkedFS(fsys afero.Fs) error

func AssertSupabaseCliIsSetUp added in v0.19.0

func AssertSupabaseCliIsSetUp() error

func AssertSupabaseCliIsSetUpFS added in v0.32.0

func AssertSupabaseCliIsSetUpFS(fsys afero.Fs) error

func AssertSupabaseDbIsRunning added in v0.33.1

func AssertSupabaseDbIsRunning() error

func AssertSupabaseStartIsRunning

func AssertSupabaseStartIsRunning() error

func Bold added in v0.15.6

func Bold(str string) string

For paths & filenames.

func DockerAddFile added in v0.28.2

func DockerAddFile(ctx context.Context, container string, fileName string, content []byte) error

func DockerExec

func DockerExec(ctx context.Context, container string, cmd []string) (io.Reader, error)

func DockerRemoveAll

func DockerRemoveAll()

func DockerRun

func DockerRun(
	ctx context.Context,
	name string,
	config *container.Config,
	hostConfig *container.HostConfig,
) (io.Reader, error)

func GetCurrentBranch

func GetCurrentBranch() (string, error)

func GetCurrentBranchFS added in v0.32.0

func GetCurrentBranchFS(fsys afero.Fs) (string, error)

func GetCurrentTimestamp

func GetCurrentTimestamp() string

func GetGitRoot added in v0.8.0

func GetGitRoot() (*string, error)

func GetSupabaseAPIHost added in v0.31.1

func GetSupabaseAPIHost() string

func GetSupabaseDashboardURL added in v0.31.1

func GetSupabaseDashboardURL() string

func InstallOrUpgradeDeno added in v0.19.0

func InstallOrUpgradeDeno() error

func IsBranchNameReserved added in v0.13.0

func IsBranchNameReserved(branch string) bool

func LoadAccessToken added in v0.20.0

func LoadAccessToken() (string, error)

func LoadAccessTokenFS added in v0.31.0

func LoadAccessTokenFS(fsys afero.Fs) (string, error)

func LoadConfig

func LoadConfig() error

func LoadConfigFS added in v0.32.0

func LoadConfigFS(fsys afero.Fs) error

func MkdirIfNotExist added in v0.19.0

func MkdirIfNotExist(path string) error

func MkdirIfNotExistFS added in v0.31.0

func MkdirIfNotExistFS(fsys afero.Fs, path string) error

func NewError added in v0.18.0

func NewError(s string) error

TODO: Make all errors use this.

func ProcessDiffOutput added in v0.9.0

func ProcessDiffOutput(p Program, out io.Reader) ([]byte, error)

func ProcessPsqlOutput added in v0.10.0

func ProcessPsqlOutput(out io.Reader, p Program) error

func ProcessPullOutput added in v0.9.0

func ProcessPullOutput(out io.ReadCloser, p Program) error

func ShowStatus added in v0.26.0

func ShowStatus()

func ValidateFunctionSlug added in v0.20.6

func ValidateFunctionSlug(slug string) error

func WriteConfig added in v0.18.2

func WriteConfig(fsys afero.Fs, test bool) error

Types

type DiffDependencies added in v0.13.0

type DiffDependencies struct {
	Type string `json:"type"`
}

type DiffEntry

type DiffEntry struct {
	Type             string             `json:"type"`
	Status           string             `json:"status"`
	DiffDdl          string             `json:"diff_ddl"`
	GroupName        string             `json:"group_name"`
	Dependencies     []DiffDependencies `json:"dependencies"`
	SourceSchemaName *string            `json:"source_schema_name"`
}

type Program added in v0.17.1

type Program interface {
	Start() error
	Send(msg tea.Msg)
	Quit()
}

An interface describing the parts of BubbleTea's Program that we actually use.

func NewProgram added in v0.17.1

func NewProgram(model tea.Model, opts ...tea.ProgramOption) Program

type ProgressMsg added in v0.9.0

type ProgressMsg *float64

type PsqlMsg added in v0.10.0

type PsqlMsg *string

type StatusMsg added in v0.9.0

type StatusMsg string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL