Documentation
¶
Index ¶
- Constants
- Variables
- func FetchAllGlobalSpans(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string) ([]*core.Span, error)
- func FetchAllPreAppStartSpans(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string) ([]*core.Span, error)
- func FetchAllTraceTests(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ...) ([]*backend.TraceTest, error)
- func FetchAllTraceTestsWithCache(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ...) ([]*backend.TraceTest, error)
- func FetchDriftRunTraceTests(ctx context.Context, client *TuskClient, auth AuthOptions, driftRunID string, ...) ([]*backend.TraceTest, error)
- func FetchGlobalSpansWithCache(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ...) ([]*core.Span, error)
- func FetchPreAppStartSpansWithCache(ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ...) ([]*core.Span, error)
- func GetBaseURL() string
- func IsNoSeatError(err error) bool
- func IsPausedByLabelError(err error) bool
- func SetupCloud(ctx context.Context, requireServiceID bool) (*TuskClient, AuthOptions, *config.Config, error)
- type AuthOptions
- type Deviation
- type FetchAllTraceTestsOptions
- type MockInteraction
- type NoSeatError
- type PausedByLabelError
- type RecordedRequest
- type RecordedResponse
- type RetryConfig
- type TestRecording
- type TestResult
- type TuskClient
- func (c *TuskClient) CreateApiKey(ctx context.Context, in *backend.CreateApiKeyRequest, auth AuthOptions) (*backend.CreateApiKeyResponse, error)
- func (c *TuskClient) CreateDriftRun(ctx context.Context, in *backend.CreateDriftRunRequest, auth AuthOptions) (string, error)
- func (c *TuskClient) CreateObservableService(ctx context.Context, in *backend.CreateObservableServiceRequest, ...) (*backend.CreateObservableServiceResponse, error)
- func (c *TuskClient) ExportSpans(ctx context.Context, in *backend.ExportSpansRequest, auth AuthOptions) (*backend.ExportSpansResponse, error)
- func (c *TuskClient) GetAllGlobalSpanIds(ctx context.Context, in *backend.GetAllGlobalSpanIdsRequest, auth AuthOptions) (*backend.GetAllGlobalSpanIdsResponseSuccess, error)
- func (c *TuskClient) GetAllPreAppStartSpanIds(ctx context.Context, in *backend.GetAllPreAppStartSpanIdsRequest, ...) (*backend.GetAllPreAppStartSpanIdsResponseSuccess, error)
- func (c *TuskClient) GetAllTraceTestIds(ctx context.Context, in *backend.GetAllTraceTestIdsRequest, auth AuthOptions) (*backend.GetAllTraceTestIdsResponseSuccess, error)
- func (c *TuskClient) GetAllTraceTests(ctx context.Context, in *backend.GetAllTraceTestsRequest, auth AuthOptions) (*backend.GetAllTraceTestsResponseSuccess, error)
- func (c *TuskClient) GetAuthInfo(ctx context.Context, in *backend.GetAuthInfoRequest, auth AuthOptions) (*backend.GetAuthInfoResponse, error)
- func (c *TuskClient) GetDriftRunTraceTests(ctx context.Context, in *backend.GetDriftRunTraceTestsRequest, ...) (*backend.GetDriftRunTraceTestsResponseSuccess, error)
- func (c *TuskClient) GetGlobalSpans(ctx context.Context, in *backend.GetGlobalSpansRequest, auth AuthOptions) (*backend.GetGlobalSpansResponseSuccess, error)
- func (c *TuskClient) GetGlobalSpansByIds(ctx context.Context, in *backend.GetGlobalSpansByIdsRequest, auth AuthOptions) (*backend.GetGlobalSpansByIdsResponseSuccess, error)
- func (c *TuskClient) GetObservableServiceInfo(ctx context.Context, in *backend.GetObservableServiceInfoRequest, ...) (*backend.GetObservableServiceInfoResponseSuccess, error)
- func (c *TuskClient) GetPreAppStartSpans(ctx context.Context, in *backend.GetPreAppStartSpansRequest, auth AuthOptions) (*backend.GetPreAppStartSpansResponseSuccess, error)
- func (c *TuskClient) GetPreAppStartSpansByIds(ctx context.Context, in *backend.GetPreAppStartSpansByIdsRequest, ...) (*backend.GetPreAppStartSpansByIdsResponseSuccess, error)
- func (c *TuskClient) GetTraceTest(ctx context.Context, in *backend.GetTraceTestRequest, auth AuthOptions) (*backend.GetTraceTestResponseSuccess, error)
- func (c *TuskClient) GetTraceTestsByIds(ctx context.Context, in *backend.GetTraceTestsByIdsRequest, auth AuthOptions) (*backend.GetTraceTestsByIdsResponseSuccess, error)
- func (c *TuskClient) GetValidationTraceTests(ctx context.Context, in *backend.GetValidationTraceTestsRequest, ...) (*backend.GetValidationTraceTestsResponseSuccess, error)
- func (c *TuskClient) UpdateDriftRunCIStatus(ctx context.Context, in *backend.UpdateDriftRunCIStatusRequest, ...) error
- func (c *TuskClient) UploadTraceTestResults(ctx context.Context, in *backend.UploadTraceTestResultsRequest, ...) error
- func (c *TuskClient) VerifyRepoAccess(ctx context.Context, in *backend.VerifyRepoAccessRequest, auth AuthOptions) (*backend.VerifyRepoAccessResponse, error)
Constants ¶
const ( // DefaultBaseURL is the default Tusk Cloud API URL DefaultBaseURL = "https://api.usetusk.ai" TestRunServiceAPIPath = "/api/drift/test_run_service" ClientServiceAPIPath = "/api/drift/client_service" SpanExportServiceAPIPath = "/api/drift/tusk.drift.backend.v1.SpanExportService" )
Variables ¶
var ( ErrFetchTraceTests = errors.New("unable to fetch tests from Tusk Cloud") ErrFetchTraceTestIDs = errors.New("unable to fetch test IDs from Tusk Cloud and no cache available") ErrFetchNewTraceTests = errors.New("unable to fetch new tests from Tusk Cloud") ErrFetchPreAppStartSpanIDs = errors.New("unable to fetch pre-app-start span IDs from Tusk Cloud and no cache available") ErrFetchNewPreAppStartSpans = errors.New("unable to fetch new pre-app-start spans from Tusk Cloud") ErrFetchPreAppStartSpans = errors.New("unable to fetch pre-app-start spans from Tusk Cloud") ErrFetchGlobalSpanIDs = errors.New("unable to fetch global span IDs from Tusk Cloud and no cache available") ErrFetchNewGlobalSpans = errors.New("unable to fetch new global spans from Tusk Cloud") ErrFetchGlobalSpans = errors.New("unable to fetch global spans from Tusk Cloud") )
Functions ¶
func FetchAllGlobalSpans ¶ added in v0.1.49
func FetchAllGlobalSpans( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ) ([]*core.Span, error)
FetchAllGlobalSpans fetches all global spans without caching (fallback).
func FetchAllPreAppStartSpans ¶ added in v0.1.49
func FetchAllPreAppStartSpans( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, ) ([]*core.Span, error)
FetchAllPreAppStartSpans fetches all pre-app-start spans without caching (fallback).
func FetchAllTraceTests ¶ added in v0.1.43
func FetchAllTraceTests( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, opts *FetchAllTraceTestsOptions, ) ([]*backend.TraceTest, error)
FetchAllTraceTests fetches all trace tests from the cloud with a progress bar. This is the shared implementation used by both `tusk list -c` and `tusk run -c`.
func FetchAllTraceTestsWithCache ¶ added in v0.1.49
func FetchAllTraceTestsWithCache( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, interactive bool, quiet bool, ) ([]*backend.TraceTest, error)
FetchAllTraceTestsWithCache fetches trace tests using ID-based cache diffing. It only fetches new traces and removes deleted ones from cache. On network error, it falls back to cached data if available.
func FetchDriftRunTraceTests ¶ added in v0.1.43
func FetchDriftRunTraceTests( ctx context.Context, client *TuskClient, auth AuthOptions, driftRunID string, opts *FetchAllTraceTestsOptions, ) ([]*backend.TraceTest, error)
FetchDriftRunTraceTests fetches trace tests for a specific drift run with a progress bar.
func FetchGlobalSpansWithCache ¶ added in v0.1.49
func FetchGlobalSpansWithCache( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, interactive bool, quiet bool, ) ([]*core.Span, error)
FetchGlobalSpansWithCache fetches global spans using ID-based cache diffing. It only fetches new spans and removes deleted ones from cache. On network error, it falls back to cached data if available.
func FetchPreAppStartSpansWithCache ¶ added in v0.1.49
func FetchPreAppStartSpansWithCache( ctx context.Context, client *TuskClient, auth AuthOptions, serviceID string, interactive bool, quiet bool, ) ([]*core.Span, error)
FetchPreAppStartSpansWithCache fetches pre-app-start spans using ID-based cache diffing. It only fetches new spans and removes deleted ones from cache. On network error, it falls back to cached data if available.
func GetBaseURL ¶ added in v0.1.23
func GetBaseURL() string
GetBaseURL returns the API base URL with the following priority: 1. TUSK_API_URL environment variable 2. tusk_api.url from .tusk/config.yaml 3. Default URL (https://api.usetusk.ai)
func IsNoSeatError ¶ added in v0.1.47
IsNoSeatError checks if an error is a NoSeatError
func IsPausedByLabelError ¶ added in v0.1.49
IsPausedByLabelError checks if an error is a PausedByLabelError
func SetupCloud ¶
func SetupCloud(ctx context.Context, requireServiceID bool) (*TuskClient, AuthOptions, *config.Config, error)
Types ¶
type AuthOptions ¶
type FetchAllTraceTestsOptions ¶ added in v0.1.43
type FetchAllTraceTestsOptions struct {
// Message to show in the progress bar
Message string
// PageSize for pagination (default 25)
PageSize int32
}
FetchAllTraceTestsOptions configures the fetch behavior
type MockInteraction ¶
type MockInteraction struct {
Service string `json:"service"`
Request RecordedRequest `json:"request"`
Response RecordedResponse `json:"response"`
Order int `json:"order"`
Timestamp time.Time `json:"timestamp"`
}
type NoSeatError ¶ added in v0.1.47
type NoSeatError struct {
Message string
}
NoSeatError is returned when the PR creator doesn't have a Tusk Cloud seat
func (*NoSeatError) Error ¶ added in v0.1.47
func (e *NoSeatError) Error() string
type PausedByLabelError ¶ added in v0.1.49
type PausedByLabelError struct {
Message string
}
PausedByLabelError is returned when the PR has the "Tusk - Pause For Current PR" label
func (*PausedByLabelError) Error ¶ added in v0.1.49
func (e *PausedByLabelError) Error() string
type RecordedRequest ¶
type RecordedResponse ¶
type RetryConfig ¶ added in v0.1.14
type RetryConfig struct {
MaxRetries int
BaseBackoff time.Duration
MaxBackoff time.Duration
JitterMin float64
JitterMax float64
}
func DefaultRetryConfig ¶ added in v0.1.14
func DefaultRetryConfig(maxRetries int) RetryConfig
DefaultRetryConfig returns normal retry configuration
func FastRetryConfig ¶ added in v0.1.14
func FastRetryConfig(maxRetries int) RetryConfig
FastRetryConfig returns retry configuration for testing
type TestRecording ¶
type TestRecording struct {
ID string `json:"id"`
ServiceID string `json:"service_id"`
TraceID string `json:"trace_id"`
Method string `json:"method"`
Path string `json:"path"`
Request RecordedRequest `json:"request"`
Response RecordedResponse `json:"response"`
Mocks []MockInteraction `json:"mocks"`
Timestamp time.Time `json:"timestamp"`
Metadata map[string]any `json:"metadata"`
}
type TestResult ¶
type TestResult struct {
TestID string `json:"test_id"`
ServiceID string `json:"service_id"`
Passed bool `json:"passed"`
Duration int `json:"duration_ms"`
Deviations []Deviation `json:"deviations,omitempty"`
Error string `json:"error,omitempty"`
ExecutedAt time.Time `json:"executed_at"`
Environment string `json:"environment"`
}
type TuskClient ¶
type TuskClient struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(baseURL, apiKey string) *TuskClient
func (*TuskClient) CreateApiKey ¶ added in v0.1.19
func (c *TuskClient) CreateApiKey(ctx context.Context, in *backend.CreateApiKeyRequest, auth AuthOptions) (*backend.CreateApiKeyResponse, error)
func (*TuskClient) CreateDriftRun ¶
func (c *TuskClient) CreateDriftRun(ctx context.Context, in *backend.CreateDriftRunRequest, auth AuthOptions) (string, error)
func (*TuskClient) CreateObservableService ¶ added in v0.1.19
func (c *TuskClient) CreateObservableService(ctx context.Context, in *backend.CreateObservableServiceRequest, auth AuthOptions) (*backend.CreateObservableServiceResponse, error)
func (*TuskClient) ExportSpans ¶ added in v0.1.46
func (c *TuskClient) ExportSpans(ctx context.Context, in *backend.ExportSpansRequest, auth AuthOptions) (*backend.ExportSpansResponse, error)
ExportSpans uploads spans to Tusk Cloud
func (*TuskClient) GetAllGlobalSpanIds ¶ added in v0.1.49
func (c *TuskClient) GetAllGlobalSpanIds(ctx context.Context, in *backend.GetAllGlobalSpanIdsRequest, auth AuthOptions) (*backend.GetAllGlobalSpanIdsResponseSuccess, error)
GetAllGlobalSpanIds fetches all global span IDs for a service (lightweight, no pagination).
func (*TuskClient) GetAllPreAppStartSpanIds ¶ added in v0.1.49
func (c *TuskClient) GetAllPreAppStartSpanIds(ctx context.Context, in *backend.GetAllPreAppStartSpanIdsRequest, auth AuthOptions) (*backend.GetAllPreAppStartSpanIdsResponseSuccess, error)
GetAllPreAppStartSpanIds fetches all pre-app-start span IDs for a service (lightweight, no pagination).
func (*TuskClient) GetAllTraceTestIds ¶ added in v0.1.49
func (c *TuskClient) GetAllTraceTestIds(ctx context.Context, in *backend.GetAllTraceTestIdsRequest, auth AuthOptions) (*backend.GetAllTraceTestIdsResponseSuccess, error)
GetAllTraceTestIds fetches all trace test IDs for a service (lightweight, no pagination).
func (*TuskClient) GetAllTraceTests ¶
func (c *TuskClient) GetAllTraceTests(ctx context.Context, in *backend.GetAllTraceTestsRequest, auth AuthOptions) (*backend.GetAllTraceTestsResponseSuccess, error)
func (*TuskClient) GetAuthInfo ¶ added in v0.1.17
func (c *TuskClient) GetAuthInfo(ctx context.Context, in *backend.GetAuthInfoRequest, auth AuthOptions) (*backend.GetAuthInfoResponse, error)
func (*TuskClient) GetDriftRunTraceTests ¶
func (c *TuskClient) GetDriftRunTraceTests(ctx context.Context, in *backend.GetDriftRunTraceTestsRequest, auth AuthOptions) (*backend.GetDriftRunTraceTestsResponseSuccess, error)
func (*TuskClient) GetGlobalSpans ¶
func (c *TuskClient) GetGlobalSpans(ctx context.Context, in *backend.GetGlobalSpansRequest, auth AuthOptions) (*backend.GetGlobalSpansResponseSuccess, error)
func (*TuskClient) GetGlobalSpansByIds ¶ added in v0.1.49
func (c *TuskClient) GetGlobalSpansByIds(ctx context.Context, in *backend.GetGlobalSpansByIdsRequest, auth AuthOptions) (*backend.GetGlobalSpansByIdsResponseSuccess, error)
GetGlobalSpansByIds fetches global spans by their IDs (batch fetch).
func (*TuskClient) GetObservableServiceInfo ¶ added in v0.1.31
func (c *TuskClient) GetObservableServiceInfo(ctx context.Context, in *backend.GetObservableServiceInfoRequest, auth AuthOptions) (*backend.GetObservableServiceInfoResponseSuccess, error)
GetObservableServiceInfo fetches observable service info including default branch
func (*TuskClient) GetPreAppStartSpans ¶
func (c *TuskClient) GetPreAppStartSpans(ctx context.Context, in *backend.GetPreAppStartSpansRequest, auth AuthOptions) (*backend.GetPreAppStartSpansResponseSuccess, error)
func (*TuskClient) GetPreAppStartSpansByIds ¶ added in v0.1.49
func (c *TuskClient) GetPreAppStartSpansByIds(ctx context.Context, in *backend.GetPreAppStartSpansByIdsRequest, auth AuthOptions) (*backend.GetPreAppStartSpansByIdsResponseSuccess, error)
GetPreAppStartSpansByIds fetches pre-app-start spans by their IDs (batch fetch).
func (*TuskClient) GetTraceTest ¶
func (c *TuskClient) GetTraceTest(ctx context.Context, in *backend.GetTraceTestRequest, auth AuthOptions) (*backend.GetTraceTestResponseSuccess, error)
func (*TuskClient) GetTraceTestsByIds ¶ added in v0.1.49
func (c *TuskClient) GetTraceTestsByIds(ctx context.Context, in *backend.GetTraceTestsByIdsRequest, auth AuthOptions) (*backend.GetTraceTestsByIdsResponseSuccess, error)
GetTraceTestsByIds fetches trace tests by their IDs (batch fetch).
func (*TuskClient) GetValidationTraceTests ¶ added in v0.1.31
func (c *TuskClient) GetValidationTraceTests(ctx context.Context, in *backend.GetValidationTraceTestsRequest, auth AuthOptions) (*backend.GetValidationTraceTestsResponseSuccess, error)
GetValidationTraceTests fetches traces for validation (both DRAFT and IN_SUITE)
func (*TuskClient) UpdateDriftRunCIStatus ¶
func (c *TuskClient) UpdateDriftRunCIStatus(ctx context.Context, in *backend.UpdateDriftRunCIStatusRequest, auth AuthOptions) error
func (*TuskClient) UploadTraceTestResults ¶
func (c *TuskClient) UploadTraceTestResults(ctx context.Context, in *backend.UploadTraceTestResultsRequest, auth AuthOptions) error
func (*TuskClient) VerifyRepoAccess ¶ added in v0.1.19
func (c *TuskClient) VerifyRepoAccess(ctx context.Context, in *backend.VerifyRepoAccessRequest, auth AuthOptions) (*backend.VerifyRepoAccessResponse, error)