Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyExists = stderrors.New("task already exists")
ErrAlreadyExists is returned by CreateTask when a task of that identifier is already present. It replaces git-rest's 409 on PostIfAbsent: the same benign conflict, expressed by the typed API.
var ErrAmbiguous = stderrors.New("name is ambiguous")
ErrAmbiguous is returned when a name addresses more than one task. The typed API refuses rather than guessing, and so does this client.
var ErrNotFound = stderrors.New("task not found")
ErrNotFound is returned when the addressed task does not exist. It is the ordinary answer to "has this task been created yet", not a failure.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
// ReadTask returns the task with the given identifier, or ErrNotFound.
ReadTask(ctx context.Context, id string) (*Task, error)
// CreateTask creates a task and returns it with the identifier the API
// minted. ErrAlreadyExists when one is already present.
CreateTask(ctx context.Context, task Task) (*Task, error)
// PatchTask replaces the named frontmatter fields and returns the task as it
// now stands. It is the atomic mutation: the API serialises per task.
PatchTask(ctx context.Context, id string, fields map[string]any) (*Task, error)
// PutBody replaces the task's body. It does not touch frontmatter.
PutBody(ctx context.Context, id string, body string) error
// ListTasks returns the tasks matching filter. It refuses rather than returns
// when the API reports a total the response does not carry, so a caller never
// mistakes a partial set for the whole population.
ListTasks(ctx context.Context, filter Filter) ([]Task, error)
}
Client is the controller's persistence model, addressed by identifier.
It replaces gitrestclient.GitClient, and the methods that are absent are the point: there is no EnsureCloned, Pull, CommitAndPush or Path, because vault-api commits server-side and holds the working copy. A caller that wants to know where a file is has the wrong model; a caller that wants to know what a task says asks for the task.
type Filter ¶
type Filter struct {
Assignee string
Status string
Phase string
Goal string
Cluster string
TaskTypes []string
}
Filter is a typed listing question. Zero fields are not sent, so an empty Filter asks for everything — the caller's own gate decides whether that is a sane question to ask.
TaskTypes is a union of the values; every other field intersects. The API distinguishes an absent parameter from an empty one, and so must a caller that means "any type" rather than "no type": leave the slice nil.
type Task ¶
type Task struct {
ID string `json:"id"`
Title string `json:"title"`
Frontmatter map[string]any `json:"frontmatter,omitempty"`
Body string `json:"body,omitempty"`
}
Task is the typed view of one task. There is no path: the identifier is the address, and the title is what a human sees. Body and Frontmatter are the two halves a write touches, and they are separate routes because they are separate mutations — PATCH replaces named frontmatter fields, PUT replaces the body.