Documentation
¶
Index ¶
- Variables
- func AwsInEnv() string
- func AzureInEnv() string
- func CallWithIdleTimeout[T any](ctx context.Context, d time.Duration, fn func() (T, error)) (T, error)
- func Compare(actual []byte, goldenFile string) error
- func Diff(actualRaw, goldenRaw string) error
- func DoInEnv() string
- func Ensure(cond bool, msg string)
- func GcpInEnv() string
- func GetCurrentUser() string
- func GetFirstEnv(keys ...string) (string, string)
- func Getenv(key, fallback string) string
- func GetenvBool(key string) bool
- func IsDirEmpty(dir string) (bool, error)
- func IsPaidTier(tier defangv1.SubscriptionTier) bool
- func IsValidRandomID(s string) bool
- func IsValidSecretName(name string) bool
- func IsValidServiceName(name string) bool
- func IsValidTailName(name string) bool
- func IsValidTime(t time.Time) bool
- func Min(a, b int) int
- func RandomID() string
- func RandomIndex(n int) int
- func RecvWithIdleTimeout[T any](ctx context.Context, ch <-chan T, d time.Duration) (T, error)
- func ShellQuote(args ...string) string
- func SleepWithContext(ctx context.Context, d time.Duration) error
- func SplitByComma(s string) []string
- func SubscriptionTierToString(tier defangv1.SubscriptionTier) string
Constants ¶
This section is empty.
Variables ¶
var ( // Standard GCP environment variables in order of precedence; https://registry.terraform.io/providers/hashicorp/google/5.10.0/docs/guides/provider_reference#project-1 GCPProjectEnvVars = []string{"GCP_PROJECT_ID", "GOOGLE_PROJECT", "GOOGLE_CLOUD_PROJECT", "GCLOUD_PROJECT", "CLOUDSDK_CORE_PROJECT"} // Keeping GCP_LOCATION first for backward compatibility GCPRegionEnvVars = []string{"GCP_LOCATION", "GOOGLE_REGION", "GCLOUD_REGION", "CLOUDSDK_COMPUTE_REGION"} )
var ErrIdleTimeout = errors.New("idle timeout: no data received")
ErrIdleTimeout is returned when a stream read has not produced any data (and no error) within the configured idle window. Long-lived server streams (e.g. CloudWatch Live Tail, GCP TailLogEntries) can stall on a half-dead connection without ever closing or erroring, so callers need an idle deadline distinct from the overall context deadline to detect and recover from that instead of blocking indefinitely.
Functions ¶
func AzureInEnv ¶
func AzureInEnv() string
func CallWithIdleTimeout ¶
func CallWithIdleTimeout[T any](ctx context.Context, d time.Duration, fn func() (T, error)) (T, error)
CallWithIdleTimeout runs fn and returns its result, or ErrIdleTimeout if fn does not return within d, or ctx.Err() if ctx is done first. Use this for synchronous, blocking calls (e.g. a gRPC stream's Recv()) that don't expose a channel to select on.
If the timeout (or ctx) fires first, fn keeps running in the background and its result is discarded; the caller is expected to close/cancel whatever fn is blocked on so that goroutine doesn't run forever.
func GetCurrentUser ¶
func GetCurrentUser() string
func GetFirstEnv ¶
func GetenvBool ¶
GetenvBool returns the boolean value of an environment variable; defaults to false.
func IsDirEmpty ¶
func IsPaidTier ¶
func IsPaidTier(tier defangv1.SubscriptionTier) bool
IsPaidTier reports whether the subscription tier is a paid plan (Personal, Pro, or Team).
func IsValidRandomID ¶
func IsValidSecretName ¶
func IsValidServiceName ¶
func IsValidTailName ¶
func IsValidTime ¶
func RandomIndex ¶
func RecvWithIdleTimeout ¶
RecvWithIdleTimeout receives a single value from ch, returning ErrIdleTimeout if nothing arrives within d, or ctx.Err() if ctx is done first. If ch is closed (and drained), it returns io.EOF, matching the two-value receive form's "ok" signal rather than silently handing back T's zero value forever. Use this for channel-based reads (e.g. an AWS SDK EventStream's Events() channel) where wrapping the read in a goroutine would be wasteful.
func ShellQuote ¶
ShellQuote returns a shell-quoted string of the given arguments. When needed, arguments are quoted with double quotes, so that spaces and env vars are preserved.
func SplitByComma ¶
func SubscriptionTierToString ¶
func SubscriptionTierToString(tier defangv1.SubscriptionTier) string
Types ¶
This section is empty.
Directories
¶
| Path | Synopsis |
|---|---|
|
tools
Package tools: consolidated interfaces for mocking CLI/tool dependencies
|
Package tools: consolidated interfaces for mocking CLI/tool dependencies |
|
clouds
|
|
|
azure/dns
Package dns manages public Azure DNS zones used for Defang domain delegation.
|
Package dns manages public Azure DNS zones used for Defang domain delegation. |
|
Package stackpath holds the stack-qualified naming contract that the Defang CLI shares with the Pulumi provider (DefangLabs/pulumi-defang) and with the TypeScript stack that preceded it.
|
Package stackpath holds the stack-qualified naming contract that the Defang CLI shares with the Pulumi provider (DefangLabs/pulumi-defang) and with the TypeScript stack that preceded it. |
|
Package term provides support functions for dealing with terminals, as commonly found on UNIX systems.
|
Package term provides support functions for dealing with terminals, as commonly found on UNIX systems. |