utils

package
v1.144.7 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 71 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DNS_GO_NATIVE  = "native"
	DNS_OVER_HTTPS = "https"
)
View Source
const (
	DefaultApiHost = "https://api.supabase.com"
	// DEPRECATED
	DeprecatedApiHost = "https://api.supabase.io"
)
View Source
const (
	DockerDenoDir     = "/home/deno"
	DockerModsDir     = DockerDenoDir + "/modules"
	DockerFuncDirPath = DockerDenoDir + "/functions"
)
View Source
const (
	Pg13Image = "supabase/postgres:13.3.0"
	Pg14Image = "supabase/postgres:14.1.0.89"
	Pg15Image = "supabase/postgres:15.1.0.147"
	// Append to ServiceImages when adding new dependencies below
	KongImage        = "library/kong:2.8.1"
	InbucketImage    = "inbucket/inbucket:3.0.3"
	PostgrestImage   = "postgrest/postgrest:v12.0.1"
	DifferImage      = "supabase/pgadmin-schema-diff:cli-0.0.5"
	MigraImage       = "supabase/migra:3.0.1663481299"
	PgmetaImage      = "supabase/postgres-meta:v0.75.0"
	StudioImage      = "supabase/studio:20240205-b145c86"
	ImageProxyImage  = "darthsim/imgproxy:v3.8.0"
	EdgeRuntimeImage = "supabase/edge-runtime:v1.36.1"
	VectorImage      = "timberio/vector:0.28.1-alpine"
	PgbouncerImage   = "bitnami/pgbouncer:1.20.1-debian-11-r39"
	PgProveImage     = "supabase/pg_prove:3.36"
	GotrueImage      = "supabase/gotrue:v2.132.3"
	RealtimeImage    = "supabase/realtime:v2.25.50"
	StorageImage     = "supabase/storage-api:v0.46.4"
	LogflareImage    = "supabase/logflare:1.4.0"
	// Should be kept in-sync with EdgeRuntimeImage
	DenoVersion = "1.30.3"
)
View Source
const (
	// https://dba.stackexchange.com/a/11895
	// Args: dbname
	TerminateDbSqlFmt = `` /* 244-byte string literal not displayed */

	SuggestDebugFlag = "Try rerunning the command with --debug to troubleshoot the error."
)
View Source
const (
	OutputEnv    = "env"
	OutputJson   = "json"
	OutputPretty = "pretty"
	OutputToml   = "toml"
	OutputYaml   = "yaml"

	// OutputMetadata is used with certain SSO commands only.
	OutputMetadata = "metadata"
)
View Source
const AccessTokenKey = "access-token"
View Source
const (
	CliProjectLabel = "com.supabase.cli.project"
)

Variables

View Source
var (
	AccessTokenPattern = regexp.MustCompile(`^sbp_[a-f0-9]{40}$`)
	ErrInvalidToken    = errors.New("Invalid access token format. Must be like `sbp_0102...1920`.")
	ErrMissingToken    = errors.Errorf("Access token not provided. Supply an access token by running %s or setting the SUPABASE_ACCESS_TOKEN environment variable.", Aqua("supabase login"))
	ErrNotLoggedIn     = errors.New("You were not logged in, nothing to do.")
)
View Source
var (
	NetId         string
	DbId          string
	ConfigId      string
	KongId        string
	GotrueId      string
	InbucketId    string
	RealtimeId    string
	RestId        string
	StorageId     string
	ImgProxyId    string
	DifferId      string
	PgmetaId      string
	StudioId      string
	EdgeRuntimeId string
	LogflareId    string
	VectorId      string
	PoolerId      string

	DbAliases          = []string{"db", "db.supabase.internal"}
	KongAliases        = []string{"kong", "api.supabase.internal"}
	GotrueAliases      = []string{"auth"}
	InbucketAliases    = []string{"inbucket"}
	RealtimeAliases    = []string{"realtime"}
	RestAliases        = []string{"rest"}
	StorageAliases     = []string{"storage"}
	ImgProxyAliases    = []string{"imgproxy"}
	PgmetaAliases      = []string{"pg_meta"}
	StudioAliases      = []string{"studio"}
	EdgeRuntimeAliases = []string{"edge_runtime"}
	LogflareAliases    = []string{"analytics"}
	VectorAliases      = []string{"vector"}
	PoolerAliases      = []string{"pooler"}

	InitialSchemaSql string
	//go:embed templates/initial_schemas/13.sql
	InitialSchemaPg13Sql string
	//go:embed templates/initial_schemas/14.sql
	InitialSchemaPg14Sql string
)
View Source
var (
	Version   string
	SentryDsn string
)

Assigned using `-ldflags` https://stackoverflow.com/q/11354518

View Source
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

	ProjectRefPattern  = regexp.MustCompile(`^[a-z]{20}$`)
	UUIDPattern        = regexp.MustCompile(`^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$`)
	ProjectHostPattern = regexp.MustCompile(`^(db\.)([a-z]{20})\.supabase\.(co|red)$`)
	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 db diff and db dump
	SystemSchemas = []string{
		"information_schema",
		"pg_*",

		"cron",
		"graphql",
		"graphql_public",
		"net",
		"pgsodium",
		"pgsodium_masks",
		"pgtle",
		"repack",
		"tiger",
		"tiger_data",
		"timescaledb_*",
		"_timescaledb_*",
		"topology",
		"vault",
	}
	InternalSchemas = append([]string{
		"auth",
		"extensions",
		"pgbouncer",
		"realtime",
		"_realtime",
		"storage",
		"_analytics",
		"supabase_functions",
		"supabase_migrations",
	}, SystemSchemas...)
	ReservedRoles = []string{
		"anon",
		"authenticated",
		"authenticator",
		"dashboard_user",
		"pgbouncer",
		"postgres",
		"service_role",
		"supabase_admin",
		"supabase_auth_admin",
		"supabase_functions_admin",
		"supabase_read_only_user",
		"supabase_replication_admin",
		"supabase_storage_admin",

		"pgsodium_keyholder",
		"pgsodium_keyiduser",
		"pgsodium_keymaker",
		"pgtle_admin",
	}
	AllowedConfigs = []string{

		"pgaudit.*",
		"pgrst.*",
		"session_replication_role",
		"statement_timeout",
		"track_io_timing",
	}

	SupabaseDirPath       = "supabase"
	ConfigPath            = filepath.Join(SupabaseDirPath, "config.toml")
	GitIgnorePath         = filepath.Join(SupabaseDirPath, ".gitignore")
	TempDir               = filepath.Join(SupabaseDirPath, ".temp")
	ImportMapsDir         = filepath.Join(TempDir, "import_maps")
	ProjectRefPath        = filepath.Join(TempDir, "project-ref")
	PoolerUrlPath         = filepath.Join(TempDir, "pooler-url")
	PostgresVersionPath   = filepath.Join(TempDir, "postgres-version")
	GotrueVersionPath     = filepath.Join(TempDir, "gotrue-version")
	RestVersionPath       = filepath.Join(TempDir, "rest-version")
	StorageVersionPath    = filepath.Join(TempDir, "storage-version")
	CurrBranchPath        = filepath.Join(SupabaseDirPath, ".branches", "_current_branch")
	MigrationsDir         = filepath.Join(SupabaseDirPath, "migrations")
	FunctionsDir          = filepath.Join(SupabaseDirPath, "functions")
	FallbackImportMapPath = filepath.Join(FunctionsDir, "import_map.json")
	FallbackEnvFilePath   = filepath.Join(FunctionsDir, ".env")
	DbTestsDir            = filepath.Join(SupabaseDirPath, "tests")
	SeedDataPath          = filepath.Join(SupabaseDirPath, "seed.sql")
	CustomRolesPath       = filepath.Join(SupabaseDirPath, "roles.sql")

	ErrNotLinked   = errors.Errorf("Cannot find project ref. Have you run %s?", Aqua("supabase link"))
	ErrInvalidRef  = errors.New("Invalid project ref format. Must be like `abcdefghijklmnopqrst`.")
	ErrInvalidSlug = errors.New("Invalid Function name. Must start with at least one letter, and only include alphanumeric characters, underscores, and hyphens. (^[A-Za-z][A-Za-z0-9_-]*$)")
	ErrNotRunning  = errors.Errorf("%s is not running.", Aqua("supabase start"))
)
View Source
var Config = config{
	Api: api{
		Image: PostgrestImage,
	},
	Db: db{
		Image:    Pg15Image,
		Password: "postgres",
		RootKey:  "d4dc5b6d4a1d6a10b2c1e76112c994d65db7cec380572cc1839624d4be3fa275",
	},
	Realtime: realtime{
		IpVersion:       AddressIPv6,
		MaxHeaderLength: 4096,
	},
	Storage: storage{
		Image: StorageImage,
	},
	Auth: auth{
		Image: GotrueImage,
		Email: email{
			Template: map[string]emailTemplate{
				"invite":       {},
				"confirmation": {},
				"recovery":     {},
				"magic_link":   {},
				"email_change": {},
			},
		},
		Sms: sms{
			Template: "Your code is {{ .Code }} .",
		},
		External: map[string]provider{
			"apple":         {},
			"azure":         {},
			"bitbucket":     {},
			"discord":       {},
			"facebook":      {},
			"github":        {},
			"gitlab":        {},
			"google":        {},
			"keycloak":      {},
			"linkedin":      {},
			"linkedin_oidc": {},
			"notion":        {},
			"twitch":        {},
			"twitter":       {},
			"slack":         {},
			"spotify":       {},
			"workos":        {},
			"zoom":          {},
		},
		Hook:      hook{},
		JwtExpiry: 3600,
		JwtSecret: defaultJwtSecret,
	},
	Analytics: analytics{
		ApiKey: "api-key",

		Backend: LogflareBigQuery,
	},
}
View Source
var (
	DNSResolver = EnumFlag{
		Allowed: []string{DNS_GO_NATIVE, DNS_OVER_HTTPS},
		Value:   DNS_GO_NATIVE,
	}
)
View Source
var (

	// Used by unit tests
	DenoPathOverride string
)
View Source
var Docker = NewDocker()
View Source
var FlyRegions = map[string]string{
	"ams": "Amsterdam, Netherlands",
	"arn": "Stockholm, Sweden",
	"bog": "Bogotá, Colombia",
	"bos": "Boston, Massachusetts (US)",
	"cdg": "Paris, France",
	"den": "Denver, Colorado (US)",
	"dfw": "Dallas, Texas (US",
	"ewr": "Secaucus, NJ (US)",
	"fra": "Frankfurt, Germany",
	"gdl": "Guadalajara, Mexico",
	"gig": "Rio de Janeiro, Brazil",
	"gru": "Sao Paulo, Brazil",
	"hkg": "Hong Kong, Hong Kong",
	"iad": "Ashburn, Virginia (US",
	"jnb": "Johannesburg, South Africa",
	"lax": "Los Angeles, California (US",
	"lhr": "London, United Kingdom",
	"maa": "Chennai (Madras), India",
	"mad": "Madrid, Spain",
	"mia": "Miami, Florida (US)",
	"nrt": "Tokyo, Japan",
	"ord": "Chicago, Illinois (US",
	"otp": "Bucharest, Romania",
	"qro": "Querétaro, Mexico",
	"scl": "Santiago, Chile",
	"sea": "Seattle, Washington (US",
	"sin": "Singapore, Singapore",
	"sjc": "San Jose, California (US",
	"syd": "Sydney, Australia",
	"waw": "Warsaw, Poland",
	"yul": "Montreal, Canada",
	"yyz": "Toronto, Canada",
}
View Source
var NoBackupVolume = false

NoBackupVolume TODO: encapsulate this state in a class

View Source
var (
	OutputDefaultAllowed = []string{
		OutputPretty,
		OutputJson,
		OutputToml,
		OutputYaml,
	}
)
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)",
	"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)",
	"us-west-2":      "West US (Oregon)",
}

Functions

func AbsImportMapPath added in v1.59.0

func AbsImportMapPath(importMapPath, slug string, fsys afero.Fs) (string, error)

func AbsTempImportMapPath added in v1.120.0

func AbsTempImportMapPath(cwd, hostPath string) string

func Aqua added in v0.15.6

func Aqua(str string) string

For commands & names.

func AssertDockerIsRunning

func AssertDockerIsRunning(ctx context.Context) error

func AssertProjectRefIsValid added in v1.58.0

func AssertProjectRefIsValid(projectRef string) 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 BindImportMap added in v1.120.0

func BindImportMap(hostImportMapPath, dockerImportMapPath string, fsys afero.Fs) ([]string, error)

func Bold added in v0.15.6

func Bold(str string) string

For paths & filenames.

func CliProjectFilter added in v1.123.0

func CliProjectFilter() filters.Args

func ConnectByConfig added in v1.110.1

func ConnectByConfig(ctx context.Context, config pgconn.Config, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)

func ConnectByUrl added in v1.28.0

func ConnectByUrl(ctx context.Context, url string, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)

func ConnectLocalPostgres added in v1.17.4

func ConnectLocalPostgres(ctx context.Context, config pgconn.Config, 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 added in v1.17.4

func ConnectRemotePostgres(ctx context.Context, config pgconn.Config, options ...func(*pgx.ConnConfig)) (*pgx.Conn, error)

Connnect to remote Postgres with optimised settings. The caller is responsible for closing the connection returned.

func DeleteAccessToken added in v1.118.0

func DeleteAccessToken(fsys afero.Fs) error

func DockerExecOnce added in v0.37.0

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 DockerExecOnceWithStream added in v1.50.13

func DockerExecOnceWithStream(ctx context.Context, container, workdir string, env, cmd []string, stdout, stderr io.Writer) error

func DockerImagePull added in v1.26.9

func DockerImagePull(ctx context.Context, image string, w io.Writer) error

func DockerImagePullWithRetry added in v1.5.2

func DockerImagePullWithRetry(ctx context.Context, image string, retries int) error

func DockerNetworkCreateIfNotExists added in v1.16.0

func DockerNetworkCreateIfNotExists(ctx context.Context, networkId string) error

func DockerPullImageIfNotCached added in v0.37.0

func DockerPullImageIfNotCached(ctx context.Context, imageName string) error

func DockerRemove added in v1.27.1

func DockerRemove(containerId string)

func DockerRemoveAll

func DockerRemoveAll(ctx context.Context, w io.Writer) error

func DockerRunOnce added in v0.37.0

func DockerRunOnce(ctx context.Context, image string, env []string, cmd []string) (string, error)

Runs a container image exactly once, returning stdout and throwing error on non-zero exit code.

func DockerRunOnceWithConfig added in v1.41.4

func DockerRunOnceWithConfig(ctx context.Context, config container.Config, hostConfig container.HostConfig, networkingConfig network.NetworkingConfig, containerName string, stdout, stderr io.Writer) error

func DockerRunOnceWithStream added in v1.27.2

func DockerRunOnceWithStream(ctx context.Context, image string, env, cmd []string, stdout, stderr io.Writer) error

func DockerStart added in v1.11.2

func DockerStart(ctx context.Context, config container.Config, hostConfig container.HostConfig, networkingConfig network.NetworkingConfig, containerName string) (string, error)

func DockerStreamLogs added in v1.49.0

func DockerStreamLogs(ctx context.Context, container string, stdout, stderr io.Writer) error

func EncodeOutput added in v1.46.0

func EncodeOutput(format string, w io.Writer, value any) error

func FallbackLookupIP added in v1.41.0

func FallbackLookupIP(ctx context.Context, host string) ([]string, error)

Performs DNS lookup via HTTPS, in case firewall blocks native netgo resolver.

func FormatTimestamp added in v1.79.0

func FormatTimestamp(timestamp string) string

func GetCurrentBranchFS added in v0.32.0

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

func GetCurrentTimestamp

func GetCurrentTimestamp() string

func GetDenoPath added in v1.4.7

func GetDenoPath() (string, error)

func GetHostname added in v1.134.3

func GetHostname() string

func GetId added in v1.102.0

func GetId(name string) string

func GetPathHash added in v1.53.0

func GetPathHash(path string) string

func GetPoolerConfig added in v1.141.1

func GetPoolerConfig(projectRef string) *pgconn.Config

func GetProjectRoot added in v1.8.2

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

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 GetRegistry added in v1.126.0

func GetRegistry() string

func GetRegistryAuth added in v1.16.2

func GetRegistryAuth() string

func GetRegistryImageUrl added in v1.0.1

func GetRegistryImageUrl(imageName string) string

func GetSupabase added in v0.38.5

func GetSupabase() *supabase.ClientWithResponses

func GetSupabaseAPIHost added in v0.31.1

func GetSupabaseAPIHost() string

func GetSupabaseDashboardURL added in v0.31.1

func GetSupabaseDashboardURL() string

func GetSupabaseDbHost added in v1.4.10

func GetSupabaseDbHost(projectRef string) string

func GetSupabaseHost added in v1.10.0

func GetSupabaseHost(projectRef string) string

func InitConfig added in v1.38.1

func InitConfig(params InitParams, fsys afero.Fs) error

func InstallOrUpgradeDeno added in v0.19.0

func InstallOrUpgradeDeno(ctx context.Context, fsys afero.Fs) error

func IsBranchNameReserved added in v0.13.0

func IsBranchNameReserved(branch string) bool

func IsGitRepo added in v1.63.1

func IsGitRepo() bool

func IsLoopback added in v1.110.1

func IsLoopback(host string) bool

func JsonResponse added in v1.107.0

func JsonResponse[T any](ctx context.Context, method, url string, reqBody any, reqEditors ...openapi.RequestEditorFn) (*T, error)

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 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 NewDocker added in v0.37.0

func NewDocker() *client.Client

func ProcessDiffOutput added in v0.9.0

func ProcessDiffOutput(diffBytes []byte) ([]byte, error)

func ProcessDiffProgress added in v1.27.2

func ProcessDiffProgress(p Program, out io.Reader) 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 PromptText added in v1.144.0

func PromptText(label string, stdin io.Reader) (string, error)

func PromptYesNo added in v1.52.0

func PromptYesNo(label string, def bool, stdin *os.File) bool

PromptYesNo asks yes/no questions using the label.

func Ptr added in v1.109.0

func Ptr[T any](v T) *T

func Red added in v1.75.3

func Red(str string) string

For errors.

func RemoveDuplicates added in v1.144.3

func RemoveDuplicates(slice []string) (result []string)

func ResolveCNAME added in v1.10.0

func ResolveCNAME(ctx context.Context, host string) (string, error)

func RunProgram added in v1.27.2

func RunProgram(ctx context.Context, f func(p Program, ctx context.Context) error) error

func SaveAccessToken added in v1.50.15

func SaveAccessToken(accessToken string, fsys afero.Fs) error

func ShortContainerImageName added in v1.19.0

func ShortContainerImageName(imageName string) string

func SliceContains added in v1.87.0

func SliceContains[T comparable](s []T, e T) bool

func SliceEqual added in v1.87.0

func SliceEqual[T comparable](a, b []T) bool

func TextResponse added in v1.107.0

func TextResponse(ctx context.Context, method, url string, body io.Reader, reqEditors ...openapi.RequestEditorFn) (string, error)

func ToPostgresURL added in v1.42.0

func ToPostgresURL(config pgconn.Config) string

func UpdateDockerIds added in v1.123.0

func UpdateDockerIds()

func ValidateFunctionSlug added in v0.20.6

func ValidateFunctionSlug(slug string) error

func WaitAll added in v1.31.1

func WaitAll[T any](containers []T, exec func(container T) error) []error

func WithTraceContext added in v1.4.1

func WithTraceContext(ctx context.Context) context.Context

func WriteConfig added in v0.18.2

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

func WriteFile added in v1.53.0

func WriteFile(path string, contents []byte, fsys afero.Fs) error

func Yellow added in v1.61.0

func Yellow(str string) string

Types

type AddressFamily added in v1.92.0

type AddressFamily string
const (
	AddressIPv6 AddressFamily = "IPv6"
	AddressIPv4 AddressFamily = "IPv4"
)

type CustomClaims added in v1.126.2

type CustomClaims struct {
	// Overrides Issuer to maintain json order when marshalling
	Issuer string `json:"iss,omitempty"`
	Ref    string `json:"ref,omitempty"`
	Role   string `json:"role"`
	jwt.RegisteredClaims
}

func (CustomClaims) NewToken added in v1.126.2

func (c CustomClaims) NewToken() *jwt.Token

type DenoScriptDir added in v1.34.0

type DenoScriptDir struct {
	ExtractPath string
	BuildPath   string
}

func CopyDenoScripts added in v1.34.0

func CopyDenoScripts(ctx context.Context, fsys afero.Fs) (*DenoScriptDir, error)

Copy Deno scripts needed for function deploy and downloads, returning a DenoScriptDir struct or an error.

type DialContextFunc added in v1.41.1

type DialContextFunc func(context.Context, string, string) (net.Conn, error)

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 DiffStream added in v1.27.2

type DiffStream struct {
	// contains filtered or unexported fields
}

func NewDiffStream added in v1.27.2

func NewDiffStream(p Program) *DiffStream

func (DiffStream) Collect added in v1.27.2

func (c DiffStream) Collect() ([]byte, error)

func (DiffStream) Stderr added in v1.27.2

func (c DiffStream) Stderr() io.Writer

func (DiffStream) Stdout added in v1.27.2

func (c DiffStream) Stdout() io.Writer

type EnumFlag added in v0.39.0

type EnumFlag struct {
	Allowed []string
	Value   string
}

Ref: https://github.com/spf13/pflag/issues/236#issuecomment-931600452

func (*EnumFlag) Set added in v0.39.0

func (a *EnumFlag) Set(p string) error

func (EnumFlag) String added in v0.39.0

func (a EnumFlag) String() string

func (*EnumFlag) Type added in v0.39.0

func (a *EnumFlag) Type() string

type ImportMap added in v1.53.0

type ImportMap struct {
	Imports map[string]string            `json:"imports"`
	Scopes  map[string]map[string]string `json:"scopes"`
}

func NewFromReader added in v1.53.0

func NewFromReader(r io.Reader) (*ImportMap, error)

func NewImportMap added in v1.53.0

func NewImportMap(path string, fsys afero.Fs) (*ImportMap, error)

func (*ImportMap) BindModules added in v1.53.0

func (m *ImportMap) BindModules(resolved ImportMap) []string

func (*ImportMap) Resolve added in v1.53.0

func (m *ImportMap) Resolve(fsys afero.Fs) ImportMap

type InitParams added in v1.115.0

type InitParams struct {
	ProjectId   string
	UseOrioleDB bool
}

type JobQueue added in v1.137.0

type JobQueue struct {
	// contains filtered or unexported fields
}

JobQueue implements a background job processor using a single channel and wait group.

The channel is initialised with a maximum number of concurrent workers. Adding a new job consumes a worker from the channel. After finishing a job, the worker is added back to the channel. When all workers are consumed, adding new job will block.

Example usage:

jq := NewJobQueue(5)
err := jq.Put(func() error {
	return nil
})
errors.Join(err, jq.Collect())

func NewJobQueue added in v1.137.0

func NewJobQueue(maxConcurrency uint) *JobQueue

func (*JobQueue) Collect added in v1.137.0

func (q *JobQueue) Collect() error

Collect waits for all jobs to finish, returning any errors.

func (*JobQueue) Put added in v1.137.0

func (q *JobQueue) Put(job func() error) error

Put runs a job in the background, returning any error from the previous job.

type LogflareBackend added in v1.83.7

type LogflareBackend string
const (
	LogflarePostgres LogflareBackend = "postgres"
	LogflareBigQuery LogflareBackend = "bigquery"
)

type PoolMode added in v1.87.0

type PoolMode string
const (
	TransactionMode PoolMode = "transaction"
	SessionMode     PoolMode = "session"
)

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 PromptItem added in v0.39.0

type PromptItem struct {
	Summary string
	Details string
}

PromptItem is exposed as prompt input, empty summary + details will be excluded.

func PromptChoice added in v0.39.0

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 added in v0.39.0

func (i PromptItem) Description() string

func (PromptItem) FilterValue added in v0.39.0

func (i PromptItem) FilterValue() string

func (PromptItem) Title added in v0.39.0

func (i PromptItem) Title() string

type PsqlMsg added in v0.10.0

type PsqlMsg *string

type StatusMsg added in v0.9.0

type StatusMsg string

type StatusWriter added in v1.28.0

type StatusWriter struct {
	Program
}

func (StatusWriter) Write added in v1.28.0

func (t StatusWriter) Write(p []byte) (int, error)

Directories

Path Synopsis
Backported from pgx/v5: https://github.com/jackc/pgx/blob/v5.3.1/rows.go#L408
Backported from pgx/v5: https://github.com/jackc/pgx/blob/v5.3.1/rows.go#L408

Jump to

Keyboard shortcuts

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