pkg

package
v0.0.0-...-6d07a85 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2026 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
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"}
)
View Source
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 AwsInEnv

func AwsInEnv() string

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 Compare

func Compare(actual []byte, goldenFile string) error

func Diff

func Diff(actualRaw, goldenRaw string) error

func DoInEnv

func DoInEnv() string

func Ensure

func Ensure(cond bool, msg string)

func GcpInEnv

func GcpInEnv() string

func GetCurrentUser

func GetCurrentUser() string

func GetFirstEnv

func GetFirstEnv(keys ...string) (string, string)

func Getenv

func Getenv(key, fallback string) string

Getenv returns the value of an environment variable; defaults to the fallback string.

func GetenvBool

func GetenvBool(key string) bool

GetenvBool returns the boolean value of an environment variable; defaults to false.

func IsDirEmpty

func IsDirEmpty(dir string) (bool, error)

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 IsValidRandomID(s string) bool

func IsValidSecretName

func IsValidSecretName(name string) bool

func IsValidServiceName

func IsValidServiceName(name string) bool

func IsValidTailName

func IsValidTailName(name string) bool

func IsValidTime

func IsValidTime(t time.Time) bool

func Min

func Min(a, b int) int

func RandomID

func RandomID() string

func RandomIndex

func RandomIndex(n int) int

func RecvWithIdleTimeout

func RecvWithIdleTimeout[T any](ctx context.Context, ch <-chan T, d time.Duration) (T, error)

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

func ShellQuote(args ...string) string

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 SleepWithContext

func SleepWithContext(ctx context.Context, d time.Duration) error

func SplitByComma

func SplitByComma(s string) []string

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
cli
clouds
aws
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.
do
gcp
mcp
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.

Jump to

Keyboard shortcuts

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