client

package
v0.8.22 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package client is the Go client for the Jokku API, used by the CLI and the git hook. It reaches the API over the local unix socket or over SSH.

Index

Constants

View Source
const DefaultSocket = "/run/jokku/jokku.sock"

DefaultSocket is where the control node's daemon listens.

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(err error) bool

func ParseGitRemote

func ParseGitRemote(remote string) (dest, app string, ok bool)

ParseGitRemote extracts the SSH destination and app from a git remote URL such as "jokku@host:app", "jokku@host:app.git" or "ssh://jokku@host:2222/app".

Types

type Client

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

func New

func New(target Target, actor string) *Client

New returns a client for target. actor is sent with every request so the API can record who did what (an SSH key name, for example); it may be empty.

func (*Client) AddDatabaseUser

func (c *Client) AddDatabaseUser(ctx context.Context, engine, name string, req types.AddDatabaseUserRequest) (*types.DatabaseUser, error)

AddDatabaseUser adds a login to a database, returning it with its password and URLs.

func (*Client) AddSSHKey

func (c *Client) AddSSHKey(ctx context.Context, name, publicKey string) (*types.SSHKey, error)

func (*Client) App

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

func (*Client) Apps

func (c *Client) Apps(ctx context.Context) ([]types.App, error)

func (*Client) Auth

func (c *Client) Auth(ctx context.Context, app string) (*types.AuthSettings, error)

func (*Client) AuthShares

func (c *Client) AuthShares(ctx context.Context, app string) ([]types.AuthShare, error)

func (*Client) AuthUsers

func (c *Client) AuthUsers(ctx context.Context) ([]types.AuthUser, error)

func (*Client) BackupDestinations

func (c *Client) BackupDestinations(ctx context.Context) ([]types.BackupDestination, error)

func (*Client) BackupKey

func (c *Client) BackupKey(ctx context.Context) (*types.BackupKey, error)

BackupKey returns the cluster's backup key; IsNotFound until one is made.

func (*Client) BackupReport

func (c *Client) BackupReport(ctx context.Context, app string) ([]types.VolumeBackups, error)

BackupReport says where volumes are backed up and how their backups went: one app's, or every app's for app "".

func (*Client) BackupsOverview

func (c *Client) BackupsOverview(ctx context.Context) (*types.BackupsOverview, error)

BackupsOverview is everything about backups at once, for jokku top.

func (*Client) CloneApp

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

func (*Client) ClusterBackups

func (c *Client) ClusterBackups(ctx context.Context) (*types.VolumeBackups, error)

ClusterBackups lists the cluster's own backups, newest first.

func (*Client) ClusterStatus

func (c *Client) ClusterStatus(ctx context.Context) (*types.ClusterStatus, error)

func (*Client) Config

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

func (*Client) CreateApp

func (c *Client) CreateApp(ctx context.Context, app string) (*types.App, error)

func (*Client) CreateAuthShare

func (c *Client) CreateAuthShare(ctx context.Context, app string, req types.CreateShareRequest) (*types.AuthShare, error)

func (*Client) CreateAuthUser

func (c *Client) CreateAuthUser(ctx context.Context, req types.AuthUserRequest) (*types.AuthUserResult, error)

func (*Client) CreateBackupDestination

func (c *Client) CreateBackupDestination(ctx context.Context, req types.CreateBackupDestinationRequest) (*types.BackupDestination, error)

func (*Client) CreateBackupKey

func (c *Client) CreateBackupKey(ctx context.Context) (*types.BackupKey, error)

CreateBackupKey makes the cluster's backup key, or returns the one it has.

func (*Client) CreateDatabase

func (c *Client) CreateDatabase(ctx context.Context, engine string, req types.CreateDatabaseRequest, onEvent func(types.Event)) error

CreateDatabase creates and deploys a database, streaming the deploy.

func (*Client) CreateEdge

func (c *Client) CreateEdge(ctx context.Context, req types.CreateEdgeRequest) (*types.Edge, error)

CreateEdge adds an edge; the result holds the command that installs it.

func (*Client) CreateExternal

func (c *Client) CreateExternal(ctx context.Context, req types.ExternalRequest) (*types.External, error)

func (*Client) CreateJoinToken

func (c *Client) CreateJoinToken(ctx context.Context, req types.CreateJoinTokenRequest) (*types.JoinToken, error)

func (*Client) CreateVolume

func (c *Client) CreateVolume(ctx context.Context, app string, req types.CreateVolumeRequest) (*types.Volume, error)

func (*Client) Database

func (c *Client) Database(ctx context.Context, engine, name string) (*types.Database, error)

Database describes one database, with its config vars.

func (*Client) DatabaseStats

func (c *Client) DatabaseStats(ctx context.Context) ([]types.DatabaseStats, error)

DatabaseStats is what the control node has seen inside every database.

func (*Client) DatabaseUserPassword

func (c *Client) DatabaseUserPassword(ctx context.Context, engine, name, user string) (*types.DatabaseUser, error)

DatabaseUserPassword gives a database's login a new password.

func (*Client) DatabaseUsers

func (c *Client) DatabaseUsers(ctx context.Context, engine, name string) ([]types.DatabaseUser, error)

DatabaseUsers lists a database's logins.

func (*Client) Databases

func (c *Client) Databases(ctx context.Context, engine string) ([]types.Database, error)

Databases lists the databases of one engine, or all for engine "".

func (*Client) DeleteAuthShare

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

func (*Client) DeleteAuthUser

func (c *Client) DeleteAuthUser(ctx context.Context, name string) error

func (*Client) DeleteBackupDestination

func (c *Client) DeleteBackupDestination(ctx context.Context, name string) error

func (*Client) DeleteRegistryLogin

func (c *Client) DeleteRegistryLogin(ctx context.Context, server string) error

func (*Client) Deploy

func (c *Client) Deploy(ctx context.Context, app, source, ref string, tarball io.Reader, onEvent func(types.Event)) error

Deploy uploads a source tarball and streams the build and rollout. It returns the deploy's failure, if any.

func (*Client) DeployImage

func (c *Client) DeployImage(ctx context.Context, app, image string, onEvent func(types.Event)) error

DeployImage deploys a registry image (builder:image), which makes the app an image app, and streams the pull and rollout.

func (*Client) Deploys

func (c *Client) Deploys(ctx context.Context, app string) ([]types.Deploy, error)

func (*Client) DestroyApp

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

func (*Client) DestroyDatabase

func (c *Client) DestroyDatabase(ctx context.Context, engine, name string) error

func (*Client) DestroyExternal

func (c *Client) DestroyExternal(ctx context.Context, name string) error

func (*Client) DestroyVolume

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

func (*Client) DiscardOldCopy

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

DiscardOldCopy deletes the copy of a volume's disk a node kept after the volume was restored elsewhere.

func (*Client) Domains

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

func (*Client) Edges

func (c *Client) Edges(ctx context.Context) ([]types.Edge, error)

func (*Client) EnsureGitRepo

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

EnsureGitRepo creates the app's bare repo (with its deploy hook) if needed and returns its path on the server.

func (*Client) Enter

func (c *Client) Enter(ctx context.Context, app, process string) (io.ReadWriteCloser, error)

Enter opens a session in one of an app's running instances (process "", web or web.2). The caller sends a session.Request first.

func (*Client) Events

func (c *Client) Events(ctx context.Context, app string, limit int) ([]types.ClusterEvent, error)

func (*Client) ExportVolume

func (c *Client) ExportVolume(ctx context.Context, app, name string, live bool, w io.Writer) error

ExportVolume writes a volume's files to w as a .tar.gz. live skips pausing the app.

func (*Client) ExposeDatabase

func (c *Client) ExposeDatabase(ctx context.Context, engine, name string, req types.ExposeDatabaseRequest) (*types.Database, error)

ExposeDatabase lets clients outside reach a database, or changes how.

func (*Client) External

func (c *Client) External(ctx context.Context, name string) (*types.External, error)

func (*Client) Externals

func (c *Client) Externals(ctx context.Context) ([]types.External, error)

func (*Client) Firewall

func (c *Client) Firewall(ctx context.Context) (*types.Firewall, error)

Firewall is what the firewall is doing.

func (*Client) Formation

func (c *Client) Formation(ctx context.Context, app string) ([]types.Process, error)

func (*Client) ImportVolume

func (c *Client) ImportVolume(ctx context.Context, app, name string, clear, keepOwners bool, archive io.Reader) error

ImportVolume restores a volume's files from a tar (gzipped or not) and restarts the app's process that mounts it. clear empties the volume first; keepOwners keeps the archive's owners instead of the volume's.

func (*Client) Instances

func (c *Client) Instances(ctx context.Context, app string) ([]types.Instance, error)

func (*Client) Latency

func (c *Client) Latency(ctx context.Context) (*types.Latency, error)

Latency is how long requests took over the last hour and day.

func (*Client) LinkDatabase

func (c *Client) LinkDatabase(ctx context.Context, engine, name string, req types.LinkDatabaseRequest, onEvent func(types.Event)) error

LinkDatabase links a database to an app, streaming the app's restart.

func (*Client) Logs

func (c *Client) Logs(ctx context.Context, app string, o types.LogOptions, onEvent func(types.Event)) error

Logs streams log lines; with Follow it runs until ctx is done.

func (*Client) MountVolume

func (c *Client) MountVolume(ctx context.Context, app, name string, m types.VolumeMount) (*types.Volume, error)

func (*Client) MoveVolume

func (c *Client) MoveVolume(ctx context.Context, app, name, node string) (*types.Volume, error)

func (*Client) NetTests added in v0.8.19

func (c *Client) NetTests(ctx context.Context) (*types.NetTests, error)

NetTests is the network test that is running, if any, and the latest finished ones, newest first.

func (*Client) Node

func (c *Client) Node(ctx context.Context, name string) (*types.Node, error)

func (*Client) Nodes

func (c *Client) Nodes(ctx context.Context) ([]types.Node, error)

func (*Client) PS

func (c *Client) PS(ctx context.Context, app, action string, onEvent func(types.Event)) error

PS runs restart, start, stop or rebuild and streams its progress.

func (*Client) PatchAuth

func (c *Client) PatchAuth(ctx context.Context, app string, p types.AuthPatch) (*types.AuthSettings, error)

func (*Client) PatchAuthUser

func (c *Client) PatchAuthUser(ctx context.Context, name string, req types.AuthUserRequest) (*types.AuthUserResult, error)

func (*Client) PatchConfig

func (c *Client) PatchConfig(ctx context.Context, app string, p types.ConfigPatch) (*types.ConfigVars, error)

func (*Client) PatchDomains

func (c *Client) PatchDomains(ctx context.Context, app string, p types.DomainsPatch) (*types.Domains, error)

func (*Client) PatchExternal

func (c *Client) PatchExternal(ctx context.Context, name string, req types.ExternalRequest) (*types.External, error)

func (*Client) Properties

func (c *Client) Properties(ctx context.Context, app, plugin string) (*types.Properties, error)

func (*Client) Rebalance added in v0.8.21

func (c *Client) Rebalance(ctx context.Context, req types.RebalanceRequest) (*types.Rebalance, error)

Rebalance spreads instances over the nodes, or with DryRun says what would move.

func (*Client) RegistryLogins

func (c *Client) RegistryLogins(ctx context.Context) ([]types.RegistryLogin, error)

func (*Client) Releases

func (c *Client) Releases(ctx context.Context, app string) ([]types.Release, error)

func (*Client) RemoveDatabaseUser

func (c *Client) RemoveDatabaseUser(ctx context.Context, engine, name, user string) error

RemoveDatabaseUser drops a database's login and ends its sessions.

func (*Client) RemoveEdge

func (c *Client) RemoveEdge(ctx context.Context, name string) error

func (*Client) RemoveNode

func (c *Client) RemoveNode(ctx context.Context, name string, force bool) error

func (*Client) RemoveSSHKey

func (c *Client) RemoveSSHKey(ctx context.Context, nameOrFingerprint string, byFingerprint bool) error

func (*Client) RenameApp

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

func (*Client) Requests

func (c *Client) Requests(ctx context.Context, app string, tail int, follow bool, fn func(types.Request)) error

Requests streams the HTTP requests the cluster's proxies handle (all apps when app is ""): the last tail, then new ones while following.

func (*Client) ResizeVolume

func (c *Client) ResizeVolume(ctx context.Context, app, name string, sizeMB int) (*types.Volume, error)

func (*Client) Resources

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

func (*Client) RestoreVolume

func (c *Client) RestoreVolume(ctx context.Context, app, name string, req types.RestoreVolumeRequest, onEvent func(types.Event)) error

RestoreVolume restores a volume from a backup, streaming its progress.

func (*Client) RunBackup

func (c *Client) RunBackup(ctx context.Context, app, name string, onEvent func(types.Event)) error

RunBackup backs a volume up now, streaming its progress.

func (*Client) RunClusterBackup

func (c *Client) RunClusterBackup(ctx context.Context, onEvent func(types.Event)) error

RunClusterBackup backs the cluster up now, streaming its progress.

func (*Client) SSHKeys

func (c *Client) SSHKeys(ctx context.Context) ([]types.SSHKey, error)

func (*Client) SaveBackupKey

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

SaveBackupKey records that the user saved the backup key.

func (*Client) Scale

func (c *Client) Scale(ctx context.Context, app string, req types.ScaleRequest) ([]types.Process, error)

func (*Client) SetAppLocked

func (c *Client) SetAppLocked(ctx context.Context, app string, locked bool) error

func (*Client) SetBuilder

func (c *Client) SetBuilder(ctx context.Context, app, typ, file string) error

SetBuilder switches an app to Dockerfile or compose builds (typ), with file the Dockerfile or compose file ("" for the default).

func (*Client) SetClusterBackup

func (c *Client) SetClusterBackup(ctx context.Context, req types.SetVolumeBackupRequest) (*types.VolumeBackups, error)

func (*Client) SetFirewall

func (c *Client) SetFirewall(ctx context.Context, app string, p types.FirewallPatch) (*types.FirewallSettings, error)

SetFirewall changes the firewall's rules, or with an app whether it's on for it.

func (*Client) SetNodeFlag

func (c *Client) SetNodeFlag(ctx context.Context, name, flag string, value bool) (*types.Node, error)

SetNodeFlag sets schedulable, ingress or draining on a node.

func (*Client) SetProperty

func (c *Client) SetProperty(ctx context.Context, app, plugin, key, value string) error

func (*Client) SetRegistryLogin

func (c *Client) SetRegistryLogin(ctx context.Context, server, username, password string) error

func (*Client) SetResources

func (c *Client) SetResources(ctx context.Context, app string, l types.ResourceLimits) (*types.Resources, error)

func (*Client) SetVolumeBackup

func (c *Client) SetVolumeBackup(ctx context.Context, app, name string, req types.SetVolumeBackupRequest) (*types.VolumeBackups, error)

func (*Client) StartNetTest added in v0.8.19

func (c *Client) StartNetTest(ctx context.Context, req types.NetTestRequest) (*types.NetTestProgress, error)

StartNetTest starts testing the network between the nodes.

func (*Client) Unban

func (c *Client) Unban(ctx context.Context, addr string) (bool, error)

Unban lifts an address's bans, saying whether it had one.

func (*Client) UnexposeDatabase

func (c *Client) UnexposeDatabase(ctx context.Context, engine, name string) error

UnexposeDatabase stops clients outside from reaching a database.

func (*Client) UnlinkDatabase

func (c *Client) UnlinkDatabase(ctx context.Context, engine, name, app string, noRestart bool, onEvent func(types.Event)) error

UnlinkDatabase unlinks a database from an app, streaming its restart.

func (*Client) UnmountVolume

func (c *Client) UnmountVolume(ctx context.Context, app, name string, m types.VolumeMount) (*types.Volume, error)

UnmountVolume removes a mount; an empty path removes the volume's only one.

func (*Client) UnsetClusterBackup

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

func (*Client) UnsetVolumeBackup

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

func (*Client) UpdateNodes

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

UpdateNodes asks the control node to bring the other nodes to its version.

func (*Client) Version

func (c *Client) Version(ctx context.Context) (*types.Version, error)

func (*Client) Volume

func (c *Client) Volume(ctx context.Context, app, name string) (*types.Volume, error)

func (*Client) VolumeBackups

func (c *Client) VolumeBackups(ctx context.Context, app, name string) (*types.VolumeBackups, error)

VolumeBackups lists a volume's backups, newest first.

func (*Client) Volumes

func (c *Client) Volumes(ctx context.Context, app string) ([]types.Volume, error)

type Error

type Error struct {
	Status  int
	Message string
}

Error is a non-2xx API response.

func (*Error) Error

func (e *Error) Error() string

type Target

type Target struct {
	Socket string // path of the API unix socket
	SSH    string // [user@]host[:port], reached with "ssh ... jokku api:dial-stdio"
}

Target says how to reach the API. Exactly one field is set.

func (Target) String

func (t Target) String() string

Jump to

Keyboard shortcuts

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