client

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package client talks to the controller's HTTP API.

Per D3 the API is the only surface: the command-line client, the TUI view and the web UI all read the same endpoints, so anything one of them can show, the others can. That is why this package exists rather than the CLI reaching into the reconciler — a second path to the same state would be a second definition of what an application's state is.

Every read hands back the decoded value and the bytes it was decoded from. Machine-readable output prints those bytes rather than re-encoding the value, so `--output json` is exactly what the controller said and cannot drift from it as the types grow.

Index

Constants

View Source
const DefaultServer = "http://127.0.0.1:8080"

DefaultServer is the controller on this host, which is where a `docker exec` into the controller's own container finds it.

View Source
const EnvServer = "SWARMCLI_CD_SERVER"

EnvServer names the controller to talk to, so that a shell exports it once rather than repeating --server on every command.

Variables

This section is empty.

Functions

This section is empty.

Types

type Applications

type Applications struct {
	Applications []application.View `json:"applications"`
}

Applications is the list response. The controller wraps the array in an object so that the response can grow fields without becoming a different kind of document.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client reads one controller.

func New

func New(server, token string) *Client

New returns a client for the controller at server, presenting token as a bearer credential. An empty token still produces a usable client — the resulting 401 is the API's to explain, not this constructor's.

func (*Client) Diff

func (c *Client) Diff(ctx context.Context, app string) (Diff, []byte, error)

Diff returns the manifest change each of the application's releases would undergo.

func (*Client) Get

func (c *Client) Get(ctx context.Context, app string) (application.View, []byte, error)

Get returns one application with its releases and their services.

func (*Client) Health

func (c *Client) Health(ctx context.Context) error

Health probes the controller's liveness endpoint.

It is the one endpoint that takes no credential, because a container healthcheck runs beside the process and cannot carry one without putting it in the stack file and in `docker inspect` output.

func (*Client) History

func (c *Client) History(ctx context.Context, app string) (application.History, []byte, error)

History returns every declared release's revisions, newest first.

func (*Client) List

func (c *Client) List(ctx context.Context) (Applications, []byte, error)

List returns every application with its sync state and health, without per-release detail.

func (*Client) Status

Status returns the controller's own state: where the app set is sourced from, the revision and time of the last successful load, and whether what is running is a last-good set because a newer one is being refused.

func (*Client) Sync

func (c *Client) Sync(ctx context.Context, app string) error

Sync asks the controller to reconcile the application now.

It returns as soon as the controller has accepted the request: a sync fetches, renders, plans and deploys, and under a wait policy blocks until the rollout converges, which is legitimately minutes. Follow it by polling Get — the application's LastSync is what records the outcome.

type Diff

type Diff struct {
	Releases []application.ReleaseDiff `json:"releases"`
	Planned  bool                      `json:"planned"`
}

Diff is the diff response. Planned distinguishes "nothing would change" from "this application has not been reconciled yet", which look identical in the releases array and mean very different things.

type Error

type Error struct {
	StatusCode int
	Message    string
}

Error is a non-2xx response, carrying the API's own message.

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

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