Documentation
¶
Overview ¶
Package client is a small client for the Stampede REST API, used by the CLI and the terminal UI. It speaks the same public API as the web UI.
Index ¶
- func ConfigPath() (string, error)
- func Login(ctx context.Context, server, email, password, tokenName string) (string, gen.Me, error)
- func PasswordToken(ctx context.Context, server, email, password string, body map[string]any) (gen.TokenCreated, gen.Me, error)
- func Query(kv ...string) string
- func SaveConfig(c Config) (string, error)
- func Setup(ctx context.Context, ...) (string, gen.Me, error)
- type APIError
- type Client
- func (c *Client) Do(ctx context.Context, method, path string, body, out any) error
- func (c *Client) FindAIJob(ctx context.Context, project, ref string) (gen.AIJobSummary, error)
- func (c *Client) FindAIProvider(ctx context.Context, ref string) (gen.AIProvider, error)
- func (c *Client) FindChannel(ctx context.Context, ref string) (gen.NotificationChannel, error)
- func (c *Client) FindDriftResult(ctx context.Context, project, ref string) (gen.DriftResult, error)
- func (c *Client) FindIntegration(ctx context.Context, ref string) (gen.Integration, error)
- func (c *Client) FindProject(ctx context.Context, ref string) (gen.Project, error)
- func (c *Client) FindScenario(ctx context.Context, project, ref string) (gen.Scenario, error)
- func (c *Client) FindScenarioIn(ctx context.Context, project, ref string) (gen.Scenario, error)
- func (c *Client) FindTarget(ctx context.Context, project, ref string) (gen.Target, error)
- func (c *Client) FindToken(ctx context.Context, ref string) (gen.Token, error)
- func (c *Client) FindUser(ctx context.Context, ref string) (gen.User, error)
- func (c *Client) Follow(ctx context.Context, runID string, fn func(Event)) error
- func (c *Client) Projects(ctx context.Context) ([]gen.Project, error)
- type Config
- type Event
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConfigPath ¶
ConfigPath is ~/.config/stampede/config.yaml (or the OS equivalent).
func PasswordToken ¶
func PasswordToken(ctx context.Context, server, email, password string, body map[string]any) (gen.TokenCreated, gen.Me, error)
PasswordToken signs in with a password and creates an API token from body (a TokenCreate). API tokens cannot create tokens, so this is how the CLI makes them.
func SaveConfig ¶
SaveConfig writes the config with owner-only permissions (it holds a token).
Types ¶
type Client ¶
type Client struct {
Server string
Token string
// Project is the default project for commands given no --project
// (stampede projects use, or STAMPEDE_PROJECT).
Project string
HTTP *http.Client
}
Client calls a Stampede server.
func (*Client) FindAIProvider ¶
FindAIProvider resolves an AI provider by id or name.
func (*Client) FindChannel ¶
FindChannel resolves a notification channel by id or name.
func (*Client) FindDriftResult ¶
FindDriftResult resolves a project's drift check by id or a unique id prefix.
func (*Client) FindIntegration ¶
FindIntegration resolves an integration by id or name.
func (*Client) FindProject ¶
FindProject resolves a project by id, slug or name.
func (*Client) FindScenario ¶
FindScenario resolves a scenario in a project by id or name.
func (*Client) FindScenarioIn ¶
FindScenarioIn resolves a scenario by id, name or a unique id prefix.
func (*Client) FindTarget ¶
FindTarget resolves a target in a project by id, name or base URL.
type Config ¶
type Config struct {
Server string `yaml:"server"`
Token string `yaml:"token"`
Project string `yaml:"project,omitempty"`
}
Config is what `stampede login` stores.
func LoadConfig ¶
LoadConfig reads the stored config; env vars STAMPEDE_SERVER, STAMPEDE_TOKEN and STAMPEDE_PROJECT override it.
func ReadConfigFile ¶
ReadConfigFile reads the stored config without environment overrides.