common

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneForStream

func CloneForStream(c *http.Client) *http.Client

cloneForStream returns a shallow copy of the provided HTTP client with Timeout disabled (0). Used for SSE calls which should not have a global client timeout.

func ControlPlaneHTTPError

func ControlPlaneHTTPError(resp *http.Response) error

controlPlaneHTTPError summarises a non-2xx control-plane response.

func ExpandPath

func ExpandPath(path string) string

func FollowRunRenderOptions

func FollowRunRenderOptions(baseURL *url.URL, output io.Writer) runs.TextRenderOptions

FollowRunRenderOptions returns shared render options for follow-mode output.

func MakeAuthenticatedRequest

func MakeAuthenticatedRequest(ctx context.Context, method, endpoint string, body io.Reader) (*http.Request, error)

makeAuthenticatedRequest creates an HTTP request with bearer token authorization. This helper should be used for all API calls that require authentication.

func ParseFlagSet

func ParseFlagSet(fs *flag.FlagSet, args []string, printUsage func()) error

ParseFlagSet handles shared FlagSet parse behavior for CLI handlers. It prints usage via printUsage on parse errors and treats --help/-h as success.

func PrintCommandUsage

func PrintCommandUsage(w io.Writer, parts ...string)

PrintCommandUsage prints a simple usage header for the given command path. It intentionally mirrors the strings used by help goldens under testdata/.

func ReadFileRooted

func ReadFileRooted(path string) ([]byte, error)

func ResolveControlPlaneHTTP

func ResolveControlPlaneHTTP(_ context.Context) (*url.URL, *http.Client, error)

ResolveControlPlaneHTTP selects the base URL and HTTP client using PLOY_SERVER_URL and PLOY_AUTH_TOKEN. Returns a client configured for bearer token authentication.

func ResolveControlPlaneToken

func ResolveControlPlaneToken() (string, error)

ResolveControlPlaneToken returns the configured bearer token. It is used for rendering browser-friendly artifact links with auth_token query parameters.

func ResolveIdentityPath

func ResolveIdentityPath(v StringValue) (string, error)

ResolveIdentityPath chooses a default SSH identity when not explicitly set.

func ResolvePloydBinaryPath

func ResolvePloydBinaryPath(v StringValue) (string, error)

ResolvePloydBinaryPath locates the ployd binary adjacent to the CLI.

func SplitRemoteRepoSelector

func SplitRemoteRepoSelector(selector string) (string, string)

func SupportsOSC8

func SupportsOSC8(w io.Writer) bool

func ValidateFileReadable

func ValidateFileReadable(path string) error

ValidateFileReadable checks if a file exists and is readable.

func ValidateSSHPort

func ValidateSSHPort(port int) error

ValidateSSHPort checks if a port number is in a valid range.

func WantsHelp

func WantsHelp(args []string) bool

wantsHelp checks whether the given argument list represents a help request. It returns true if the sole argument is "--help" or "-h", which is the pattern used by command routers that manually parse arguments (DisableFlagParsing: true) to detect and respond to help flags before dispatching to subcommands.

Types

type BoolValue

type BoolValue struct {
	IsSet bool
	Value bool
}

BoolValue implements flag.Value for booleans.

func (*BoolValue) IsBoolFlag

func (v *BoolValue) IsBoolFlag() bool

func (*BoolValue) Set

func (v *BoolValue) Set(s string) error

func (*BoolValue) String

func (v *BoolValue) String() string

type IntValue

type IntValue struct {
	IsSet bool
	Value int
}

IntValue implements flag.Value for integers.

func (*IntValue) Set

func (v *IntValue) Set(s string) error

func (*IntValue) String

func (v *IntValue) String() string

type ResolvedRemoteRepo

type ResolvedRemoteRepo struct {
	RepoURL   string
	Ref       string
	CommitSHA string
}

ResolvedRemoteRepo is the control-plane resolution of a repo selector such as namespace/repo:branch.

func ResolveRemoteRepoSelector

func ResolveRemoteRepoSelector(ctx context.Context, base *url.URL, httpClient *http.Client, selector string) (ResolvedRemoteRepo, error)

type StringSlice

type StringSlice []string

StringSlice is a simple flag.Value for collecting repeated values.

func (*StringSlice) Set

func (s *StringSlice) Set(v string) error

func (*StringSlice) String

func (s *StringSlice) String() string

type StringValue

type StringValue struct {
	IsSet bool
	Value string
}

StringValue implements flag.Value with a marker for whether it was set.

func (*StringValue) Set

func (v *StringValue) Set(s string) error

func (*StringValue) String

func (v *StringValue) String() string

type StringsValue

type StringsValue struct {
	Values []string
}

StringsValue implements flag.Value for accumulating multiple string flag values.

func (*StringsValue) Set

func (v *StringsValue) Set(s string) error

func (*StringsValue) String

func (v *StringsValue) String() string

Jump to

Keyboard shortcuts

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