Documentation
¶
Index ¶
- Constants
- func APIBaseURL() string
- func FrontendBaseURL() string
- func NormalizeBaseURL(raw string) (string, error)
- func SetBaseOverride(raw string) error
- func SubmitCLILesson(uuid string, results []CLIStepResult, captureDebug bool) (LessonSubmissionEvent, SubmissionDebugData, error)
- type CLICommandJqOutput
- type CLICommandResult
- type CLICommandTest
- type CLIData
- type CLIStep
- type CLIStepCLICommand
- type CLIStepHTTPRequest
- type CLIStepResult
- type CurrentUserResponse
- type HTTPBasicAuth
- type HTTPRequest
- type HTTPRequestResponseHeaderVariable
- type HTTPRequestResponseVariable
- type HTTPRequestResult
- type HTTPRequestTest
- type HTTPRequestTestHeader
- type HTTPRequestTestJSONValue
- type JqExpectedResult
- type JqOperator
- type JqValueType
- type Lesson
- type LessonDataCLI
- type LessonSubmissionEvent
- type LoginRequest
- type LoginResponse
- type OperatorType
- type Sleepable
- type StdoutJqTest
- type StructuredErrCLI
- type SubmissionDebugData
- type VerificationResultSlug
- type XPBreakdownItem
Constants ¶
const BaseURLOverrideRequired = "override"
const BaseURLPlaceholder = "${baseURL}"
const DefaultBaseURL = "https://sovorem.am"
DefaultBaseURL is the production origin the CLI talks to. It is compiled into the binary on purpose: the endpoint is environment configuration, not user data, so it lives in code (shipped via releases) and is never persisted to a user's config file where a stale value could shadow it after an upgrade.
Variables ¶
This section is empty.
Functions ¶
func APIBaseURL ¶
func APIBaseURL() string
APIBaseURL returns the origin used for /v1/* API requests, without a trailing slash. Precedence: --api-url flag > SOVOREM_API_URL env > built-in default.
func FrontendBaseURL ¶
func FrontendBaseURL() string
FrontendBaseURL returns the origin used for the browser /cli/login page, without a trailing slash. Precedence: --api-url flag > SOVOREM_FRONTEND_URL env > built-in default.
func NormalizeBaseURL ¶
NormalizeBaseURL validates that raw is an absolute http(s) origin and returns it without a trailing slash. http is intentionally allowed so local dev servers (e.g. http://localhost:3000) work.
func SetBaseOverride ¶
SetBaseOverride validates raw and, when non-empty, makes it the base origin for both API requests and the browser login URL. An empty string is a no-op, so callers can pass an unset flag value safely.
func SubmitCLILesson ¶
func SubmitCLILesson(uuid string, results []CLIStepResult, captureDebug bool) (LessonSubmissionEvent, SubmissionDebugData, error)
Types ¶
type CLICommandJqOutput ¶
type CLICommandResult ¶
type CLICommandResult struct {
ExitCode int
FinalCommand string `json:"-"`
Command CLIStepCLICommand `json:"-"`
Stdout string
Variables map[string]string
JqOutputs []CLICommandJqOutput `json:"-"`
}
type CLICommandTest ¶
type CLICommandTest struct {
ExitCode *int `yaml:"exitCode"`
StdoutContainsAll []string `yaml:"stdoutContainsAll"`
StdoutContainsNone []string `yaml:"stdoutContainsNone"`
StdoutLinesGt *int `yaml:"stdoutLinesGt"`
StdoutJq *StdoutJqTest `yaml:"stdoutJq"`
}
type CLIStep ¶
type CLIStep struct {
CLICommand *CLIStepCLICommand `yaml:"cliCommand"`
HTTPRequest *CLIStepHTTPRequest `yaml:"httpRequest"`
NoPenaltyOnFail bool `yaml:"noPenaltyOnFail"`
}
type CLIStepCLICommand ¶
type CLIStepCLICommand struct {
Command string `yaml:"command"`
Tests []CLICommandTest `yaml:"tests"`
SleepAfterMs *int `yaml:"sleepAfterMs"`
StdoutFilterTmdl *string `yaml:"stdoutFilterTmdl"`
}
func (*CLIStepCLICommand) GetSleepAfterMs ¶
func (c *CLIStepCLICommand) GetSleepAfterMs() *int
type CLIStepHTTPRequest ¶
type CLIStepHTTPRequest struct {
ResponseVariables []HTTPRequestResponseVariable `yaml:"responseVariables"`
ResponseHeaderVariables []HTTPRequestResponseHeaderVariable `yaml:"responseHeaderVariables"`
Tests []HTTPRequestTest `yaml:"tests"`
Request HTTPRequest `yaml:"request"`
SleepAfterMs *int `yaml:"sleepAfterMs"`
}
func (*CLIStepHTTPRequest) GetSleepAfterMs ¶
func (h *CLIStepHTTPRequest) GetSleepAfterMs() *int
type CLIStepResult ¶
type CLIStepResult struct {
CLICommandResult *CLICommandResult
HTTPRequestResult *HTTPRequestResult
}
type CurrentUserResponse ¶
type CurrentUserResponse struct {
Handle string `json:"handle"`
}
func FetchCurrentUser ¶
func FetchCurrentUser() (*CurrentUserResponse, error)
type HTTPBasicAuth ¶
type HTTPRequest ¶
type HTTPRequest struct {
Method string `yaml:"method"`
FullURL string `yaml:"fullURL"`
Headers map[string]string `yaml:"headers"`
BodyJSON map[string]any `yaml:"bodyJSON"`
BodyForm map[string]string `yaml:"bodyForm"`
FollowRedirects *bool `yaml:"followRedirects"`
BasicAuth *HTTPBasicAuth `yaml:"basicAuth"`
}
type HTTPRequestResult ¶
type HTTPRequestTest ¶
type HTTPRequestTest struct {
StatusCode *int `yaml:"statusCode"`
BodyContains *string `yaml:"bodyContains"`
BodyContainsNone *string `yaml:"bodyContainsNone"`
HeadersContain *HTTPRequestTestHeader `yaml:"headersContain"`
TrailersContain *HTTPRequestTestHeader `yaml:"trailersContain"`
JSONValue *HTTPRequestTestJSONValue `yaml:"jsonValue"`
}
HTTPRequestTest should have only one field set
type HTTPRequestTestHeader ¶
type HTTPRequestTestJSONValue ¶
type HTTPRequestTestJSONValue struct {
Path string `yaml:"path"`
Operator OperatorType `yaml:"operator"`
IntValue *int `yaml:"intValue"`
StringValue *string `yaml:"stringValue"`
BoolValue *bool `yaml:"boolValue"`
}
type JqExpectedResult ¶
type JqExpectedResult struct {
Type JqValueType `yaml:"type"`
Operator JqOperator `yaml:"operator"`
Value any `yaml:"value"`
}
type JqOperator ¶
type JqOperator string // defined fully on backend
type JqValueType ¶
type JqValueType string
const ( JqTypeString JqValueType = "string" JqTypeInt JqValueType = "int" JqTypeBool JqValueType = "bool" )
type Lesson ¶
type Lesson struct {
Lesson struct {
Type string
LessonDataCLI *LessonDataCLI
}
}
func FetchLesson ¶
type LessonDataCLI ¶
type LessonDataCLI struct {
// Readme string
CLIData CLIData
}
type LessonSubmissionEvent ¶
type LessonSubmissionEvent struct {
ResultSlug VerificationResultSlug
StructuredErrCLI *StructuredErrCLI
XPReward int
XPBreakdown []XPBreakdownItem
}
type LoginRequest ¶
type LoginRequest struct {
Otp string `json:"otp"`
}
type LoginResponse ¶
type LoginResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
func FetchAccessToken ¶
func FetchAccessToken() (*LoginResponse, error)
func LoginWithCode ¶
func LoginWithCode(code string) (*LoginResponse, error)
type OperatorType ¶
type OperatorType string
const ( OpEquals OperatorType = "eq" OpGreaterThan OperatorType = "gt" OpContains OperatorType = "contains" OpNotContains OperatorType = "not_contains" )
type StdoutJqTest ¶
type StdoutJqTest struct {
InputMode string `yaml:"inputMode"` // "json" or "jsonl"
Query string `yaml:"query"`
ExpectedResults []JqExpectedResult `yaml:"expectedResults"`
}
type StructuredErrCLI ¶
type SubmissionDebugData ¶
type VerificationResultSlug ¶
type VerificationResultSlug string
const ( // "noop" is for "noPenaltyOnFail" on the CLI type VerificationResultSlugNoop VerificationResultSlug = "noop" VerificationResultSlugSystemError VerificationResultSlug = "system-error" VerificationResultSlugSuccess VerificationResultSlug = "success" VerificationResultSlugFailure VerificationResultSlug = "failure" )