client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDebug

func IsDebug(cmd *cobra.Command) bool

IsDebug returns true when --debug is set and --dry-run is not. When both flags are set, dry-run takes precedence.

func IsDryRun

func IsDryRun(cmd *cobra.Command) bool

IsDryRun returns true when --dry-run is set on the command.

func NewClient

func NewClient(cmd *cobra.Command) (*sdk.CompassCLI, error)

NewClient creates a new SDK client configured from command flags and environment. It handles global security, server URL/selection override, global parameters, retry configuration, timeout, and test client injection.

Types

type DebugClient

type DebugClient struct {
	Inner  HTTPClient
	Stderr io.Writer
}

DebugClient wraps an HTTP client and logs request/response diagnostics to stderr.

func (*DebugClient) Do

func (c *DebugClient) Do(req *http.Request) (*http.Response, error)

Do executes the request, logging diagnostics before and after.

type DryRunClient

type DryRunClient struct {
	Stderr io.Writer
}

DryRunClient intercepts HTTP requests and returns a synthetic response without making any network calls.

func (*DryRunClient) Do

func (c *DryRunClient) Do(req *http.Request) (*http.Response, error)

Do logs the request preview and returns a synthetic 200 response.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the interface that SDK clients implement.

func WrapClientForDiagnostics

func WrapClientForDiagnostics(cmd *cobra.Command, inner HTTPClient) HTTPClient

WrapClientForDiagnostics wraps an HTTP client based on diagnostics mode. Returns the original client if no diagnostics flags are set.

Jump to

Keyboard shortcuts

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