client

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OpenBrowser = browser.OpenURL

Functions

func FormatDeployment

func FormatDeployment(d *cobaltapi.Deployment) string

func FormatDeploymentID

func FormatDeploymentID(d cobaltapi.Deployment) string

Types

type APIError

type APIError struct {
	Message    string
	StatusCode int
}

func (*APIError) Error

func (e *APIError) Error() string

type Client

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

func New

func New(s cliconfig.Server) *Client

func (*Client) AddDomain

func (c *Client) AddDomain(ctx context.Context, project string, req cobaltapi.DomainAddRequest) (*cobaltapi.Domain, error)

func (*Client) CancelDeployment

func (c *Client) CancelDeployment(ctx context.Context, id int64) error

func (*Client) CreateDeployment

func (*Client) CreateProject

func (c *Client) CreateProject(ctx context.Context, req cobaltapi.ProjectCreateRequest) (*cobaltapi.Project, error)

func (*Client) CreateRollback added in v0.6.0

func (c *Client) CreateRollback(ctx context.Context, project string, req cobaltapi.RollbackRequest) (*cobaltapi.Deployment, error)

CreateRollback enqueues a rollback to the previous successful deployment (req.To = 0) or to a specific deployment number (req.To > 0). Returns the new queued deployment row.

func (*Client) CreateUpgrade added in v0.9.0

CreateUpgrade triggers a self-upgrade on the daemon. Returns the upgrade row's metadata (id + initial status); follow the actual progress via FollowUpgradeOutput.

func (*Client) DeleteAPIKey

func (c *Client) DeleteAPIKey(ctx context.Context, id int64) error

func (*Client) DeleteEnvVar

func (c *Client) DeleteEnvVar(ctx context.Context, project, key string, redeploy bool) error

func (*Client) DeleteProject

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

func (*Client) DeployOutput

func (c *Client) DeployOutput(ctx context.Context, deploymentID int64, offset int64) (*http.Response, error)

func (*Client) DeployOutputURL

func (c *Client) DeployOutputURL(deploymentID int64, offset int64) string

func (*Client) ExportVolume

func (c *Client) ExportVolume(ctx context.Context, project, volume string) (*http.Response, error)

func (*Client) FindAppByOwner

func (c *Client) FindAppByOwner(ctx context.Context, owner string) (*cobaltapi.GithubApp, error)

func (*Client) GetDeployment

func (c *Client) GetDeployment(ctx context.Context, id int64) (*cobaltapi.Deployment, error)

func (*Client) GetEnvVar

func (c *Client) GetEnvVar(ctx context.Context, project, key string) (*cobaltapi.EnvVar, error)

func (*Client) GetMetaInfo

func (c *Client) GetMetaInfo(ctx context.Context) (*cobaltapi.MetaInfo, error)

func (*Client) GetProject

func (c *Client) GetProject(ctx context.Context, name string) (*cobaltapi.Project, error)

func (*Client) GetScale

func (c *Client) GetScale(ctx context.Context, project string) (*cobaltapi.ScaleInfo, error)

func (*Client) GetUpgrade added in v0.9.0

func (c *Client) GetUpgrade(ctx context.Context, id string) (*cobaltapi.ServerUpgrade, error)

GetUpgrade fetches the current state of an upgrade row. Used post-stream to read the terminal status (which the SSE close doesn't carry — only the bytes of the log do).

func (*Client) ImportVolume

func (c *Client) ImportVolume(ctx context.Context, project, volume string, data []byte) (*http.Response, error)

func (*Client) ListAPIKeys

func (c *Client) ListAPIKeys(ctx context.Context) ([]cobaltapi.APIKey, error)

func (*Client) ListApps

func (c *Client) ListApps(ctx context.Context) ([]cobaltapi.GithubApp, error)

func (*Client) ListCommandRuns added in v0.4.0

func (c *Client) ListCommandRuns(ctx context.Context, project string, limit int) ([]cobaltapi.CommandRun, error)

ListCommandRuns returns the project's `cobalt run` audit log, newest first. limit caps the result; pass 0 for the server's default (50).

func (*Client) ListDeployments

func (c *Client) ListDeployments(ctx context.Context, project string, limit int) ([]cobaltapi.Deployment, error)

func (*Client) ListDomains

func (c *Client) ListDomains(ctx context.Context, project string) ([]cobaltapi.Domain, error)

func (*Client) ListEnvVars

func (c *Client) ListEnvVars(ctx context.Context, project string) ([]cobaltapi.EnvVar, error)

func (*Client) ListProjectCrons added in v0.6.0

func (c *Client) ListProjectCrons(ctx context.Context, project string) ([]cobaltapi.ProjectCron, error)

ListProjectCrons returns the cron services currently registered for a project, with each one's next-fire time.

func (*Client) ListProjects

func (c *Client) ListProjects(ctx context.Context) ([]cobaltapi.Project, error)

func (*Client) ListRepos

func (c *Client) ListRepos(ctx context.Context) ([]cobaltapi.GithubAppRepo, error)

func (*Client) ListVolumes

func (c *Client) ListVolumes(ctx context.Context, project string) ([]cobaltapi.Volume, error)

func (*Client) LogsSSE

func (c *Client) LogsSSE(ctx context.Context, project string, service string) (*http.Response, error)

func (*Client) MostRecentDeployment

func (c *Client) MostRecentDeployment(ctx context.Context, project string) (*cobaltapi.Deployment, error)

func (*Client) MostRecentInFlightDeployment

func (c *Client) MostRecentInFlightDeployment(ctx context.Context, project string) (*cobaltapi.Deployment, error)

func (*Client) PostBytes

func (c *Client) PostBytes(ctx context.Context, path string, data []byte) (*http.Response, error)

func (*Client) PostRaw

func (c *Client) PostRaw(ctx context.Context, path string, contentType string, body io.Reader) (*http.Response, error)

func (*Client) PruneApps

func (c *Client) PruneApps(ctx context.Context) (*cobaltapi.PruneResponse, error)

func (*Client) RemoveDomain

func (c *Client) RemoveDomain(ctx context.Context, project, domain string) error

func (*Client) RenameProject

func (c *Client) RenameProject(ctx context.Context, name string, req cobaltapi.ProjectRenameRequest) (*cobaltapi.Project, error)

func (*Client) RunWS

func (c *Client) RunWS(ctx context.Context, project, command, service string, tty bool) (*websocket.Conn, string, error)

RunWS opens the cobalt-run WebSocket. Subprotocol negotiation: the daemon advertises both v2 and v1; we offer v2 first, falling back to v1 only if a (very) old server doesn't speak v2. The returned subprotocol tells the caller which framer to use.

tty controls whether ?tty=1 is added to the URL — the daemon then allocates a real PTY for the container and bridges its master end. Only meaningful in v2; v1 servers ignore the flag.

func (*Client) ServerStats added in v1.1.0

func (c *Client) ServerStats(ctx context.Context) (cobaltapi.ServerStats, error)

ServerStats fetches one host + per-container usage snapshot. Blocks ~2s: the daemon gives docker a CPU sampling window.

func (*Client) ServerStatsSSE added in v1.1.0

func (c *Client) ServerStatsSSE(ctx context.Context) (*http.Response, error)

ServerStatsSSE opens the live snapshot stream (one ServerStats JSON event every ~2s). The caller owns resp.Body.

func (*Client) SetEnvVars

func (c *Client) SetEnvVars(ctx context.Context, project string, req cobaltapi.EnvSetRequest) ([]cobaltapi.EnvVar, error)

func (*Client) SetMetaHost

func (c *Client) SetMetaHost(ctx context.Context, host string) (*cobaltapi.MetaInfo, error)

func (*Client) SetScale

func (c *Client) SetScale(ctx context.Context, project string, req cobaltapi.ScaleSetRequest) (*cobaltapi.ScaleInfo, error)

func (*Client) StreamGet

func (c *Client) StreamGet(ctx context.Context, path string) (*http.Response, error)

func (*Client) UpdateProjectSource added in v0.16.0

func (c *Client) UpdateProjectSource(ctx context.Context, name string, req cobaltapi.ProjectUpdateSourceRequest) (*cobaltapi.Project, error)

func (*Client) UpgradeDaemon

func (c *Client) UpgradeDaemon(ctx context.Context, req UpgradeDaemonRequest) error

func (*Client) UpgradeOutput added in v0.9.0

func (c *Client) UpgradeOutput(ctx context.Context, id string) (*http.Response, error)

UpgradeOutput opens the SSE stream for an upgrade's helper log.

type UpgradeDaemonRequest

type UpgradeDaemonRequest struct {
	Image string `json:"image,omitempty"`
}

Jump to

Keyboard shortcuts

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