Help us shape the future of Go! Take the 2026 Go Developer Survey

vaultapi

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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.

View Source
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.

View Source
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.

func NewClient

func NewClient(baseURL, gatewaySecret, gatewayInitiator string) Client

NewClient builds a Client against baseURL. An empty gatewaySecret sends no auth headers, which is how a local vault-api is addressed; every deployed instance requires it and answers 401 without it.

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.

Jump to

Keyboard shortcuts

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