runner

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 29 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runner executes one catalog operation end to end: input checks, policy, credentials, the Restish engine, pagination, secrets and downloads. The CLI and the TUI both call it, so humans and agents get the same behaviour.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBody

func ValidateBody(op *catalog.Operation, raw []byte) error

ValidateBody checks that raw is one JSON document matching the operation's request schema and reports every problem with its field path.

Types

type Options

type Options struct {
	Op *catalog.Operation
	// Params holds parameter values by flag name; arrays repeat.
	Params map[string][]string
	// BodyFile is a JSON or binary body file; "-" reads Stdin.
	BodyFile string
	Stdin    io.Reader
	// Body is a JSON body given directly by cchp's own workflows.
	Body []byte
	// FormFiles maps multipart file fields to local paths.
	FormFiles map[string]string
	// SecretOut receives one-time secrets.
	SecretOut string
	// Output receives a binary download; "-" means Stdout.
	Output string
	Stdout io.Writer
	// PageLimit is the number of pages to fetch (default 1).
	PageLimit int
	// MaxItems stops paging once this many items arrived.
	MaxItems int
	// MaxEvents stops a stream after this many events.
	MaxEvents int
	// Timeout bounds the whole run.
	Timeout time.Duration
	// Agent turns on the agent policy: read-only unless allowed.
	Agent      bool
	AllowWrite bool
	Confirm    string
	// HumanConfirmed records an interactive confirmation in human mode.
	HumanConfirmed bool
	DryRun         bool
	// OnEvent receives stream events as they arrive.
	OnEvent func(*contract.Event) error
}

Options is one operation call.

type Runner

type Runner struct {
	Store     *auth.Store
	Catalog   *catalog.Catalog
	UserAgent string
	// Debug, when set, receives a redacted trace of each request.
	Debug io.Writer
	// contains filtered or unexported fields
}

Runner holds what every call needs.

func New

func New(store *auth.Store, version string) *Runner

New builds a runner from the embedded catalog.

func (*Runner) Credential

func (r *Runner) Credential() (*auth.Credential, error)

Credential resolves and remembers the credential for this process.

func (*Runner) Identity

func (r *Runner) Identity(ctx context.Context) (*auth.Identity, error)

Identity returns the token's identity, asking the server once if needed.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, o Options) (*contract.Result, error)

Run executes one operation and returns the result object.

func (*Runner) SignIn

func (r *Runner) SignIn(ctx context.Context, rawServer, token string) (*auth.Profile, error)

SignIn checks the server address and token with whoami, then saves them as the current sign-in. Nothing is saved when the server rejects the token.

func (*Runner) UseCredential

func (r *Runner) UseCredential(c *auth.Credential)

UseCredential sets the credential explicitly (login verifies a new token).

func (*Runner) Whoami

func (r *Runner) Whoami(ctx context.Context, cred *auth.Credential) (*auth.Identity, error)

Whoami asks the server who the credential belongs to: getWhoami for the token and its organization, getMe for the person's email and name.

Jump to

Keyboard shortcuts

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