Documentation
¶
Overview ¶
Package client talks to the hub API for the CLI and the TUI.
Index ¶
- Constants
- Variables
- func AppName(flagValue, dir string) string
- func CheckURL(raw string) error
- func IsClientOutdated(err error) bool
- func IsNotFound(err error) bool
- func IsReadOnlyQuery(err error) bool
- func Logout(ctx context.Context, config Config) error
- func OriginRepo(dir string) string
- func Percent(value *float64) string
- func PickApp(flagValue, dir string) (name, from string)
- func PushedCommit(dir string) (repo, commit string, err error)
- func RemoveConfig() error
- func SaveConfig(config Config) error
- func Share(used, total float64) string
- func Sparkline(values []float64, width int) string
- func ViaLabel(via, token string) string
- type Account
- type ActivityPage
- type ActivityQuery
- type AlertDestination
- type App
- type AppBackups
- type AppDetail
- type AppMetrics
- type AppMetricsNow
- type BackupSchedule
- type Bucket
- type BucketInput
- type CIToken
- type CatalogDeploy
- type CatalogEntry
- type CatalogInstall
- type CatalogVersion
- type Change
- type Client
- func (c *Client) Account(ctx context.Context) (Account, error)
- func (c *Client) Activity(ctx context.Context, query ActivityQuery) (ActivityPage, error)
- func (c *Client) AddAlertDestination(ctx context.Context, destination NewAlertDestination) (AlertDestination, error)
- func (c *Client) AddApp(ctx context.Context, name, server string) (CreatedApp, error)
- func (c *Client) AddBucket(ctx context.Context, input BucketInput) (Bucket, error)
- func (c *Client) AddServer(ctx context.Context, name string) (NewServer, error)
- func (c *Client) AlertDestinations(ctx context.Context) ([]AlertDestination, error)
- func (c *Client) App(ctx context.Context, app string) (AppDetail, error)
- func (c *Client) AppMetrics(ctx context.Context, app, rangeName string) (AppMetrics, error)
- func (c *Client) Apps(ctx context.Context) ([]App, error)
- func (c *Client) Backups(ctx context.Context, app string) (AppBackups, error)
- func (c *Client) Bucket(ctx context.Context, name string) (Bucket, error)
- func (c *Client) Buckets(ctx context.Context) ([]Bucket, error)
- func (c *Client) CITokens(ctx context.Context) ([]CIToken, error)
- func (c *Client) Catalog(ctx context.Context) ([]CatalogEntry, error)
- func (c *Client) CatalogApp(ctx context.Context, slug string) (CatalogEntry, error)
- func (c *Client) CheckDomains(ctx context.Context, app string) ([]DomainCheck, error)
- func (c *Client) ComposeFile(ctx context.Context, app string) (ComposeFile, error)
- func (c *Client) Connections(ctx context.Context) ([]Connection, error)
- func (c *Client) DaemonUpdates(ctx context.Context) (bool, error)
- func (c *Client) DeployImage(ctx context.Context, app, image, ref string) (Deploy, error)
- func (c *Client) DeployRef(ctx context.Context, app, ref string) (Deploy, error)
- func (c *Client) Download(ctx context.Context, app, database, moment string) (Download, error)
- func (c *Client) EditBucket(ctx context.Context, name string, input BucketInput) (Bucket, error)
- func (c *Client) Env(ctx context.Context, app string) ([]EnvVar, error)
- func (c *Client) Exec(ctx context.Context, app, service string, argv []string, line string, ...) (ExecResult, error)
- func (c *Client) FetchCopy(ctx context.Context, link string, out io.Writer) error
- func (c *Client) FollowDeploy(ctx context.Context, app string, number int, line func(string)) (Deploy, error)
- func (c *Client) GetDeploy(ctx context.Context, app string, number int) (Deploy, error)
- func (c *Client) GitHub(ctx context.Context) (GitHub, error)
- func (c *Client) GitHubBranches(ctx context.Context, repo string) ([]string, error)
- func (c *Client) GitHubRepos(ctx context.Context) ([]GitHubRepo, error)
- func (c *Client) InstallCatalogApp(ctx context.Context, slug string, install CatalogInstall) (CatalogDeploy, error)
- func (c *Client) Instant(ctx context.Context, app string) (Instant, error)
- func (c *Client) Integrations(ctx context.Context) (Integrations, error)
- func (c *Client) Invite(ctx context.Context, email, role string) error
- func (c *Client) LinkRepo(ctx context.Context, app, repo, branch string, autoDeploy bool) (App, error)
- func (c *Client) Logs(ctx context.Context, app string, tail int) ([]string, error)
- func (c *Client) Meta(ctx context.Context) (Meta, error)
- func (c *Client) NewInstallCommand(ctx context.Context, idOrName string) (NewServer, error)
- func (c *Client) Query(ctx context.Context, app, database, sql string, write bool, limit int) (protocol.DBResult, error)
- func (c *Client) Redeploy(ctx context.Context, app string) (Deploy, error)
- func (c *Client) Registries(ctx context.Context) ([]Registry, error)
- func (c *Client) RemoveAlertDestination(ctx context.Context, name string) error
- func (c *Client) RemoveApp(ctx context.Context, app, confirm string) error
- func (c *Client) RemoveBucket(ctx context.Context, name, confirm string) error
- func (c *Client) RemoveCIToken(ctx context.Context, id string) error
- func (c *Client) RemoveConnection(ctx context.Context, id string) error
- func (c *Client) RemoveDeployHook(ctx context.Context, app string) error
- func (c *Client) RemovePassword(ctx context.Context, app string) (Change, error)
- func (c *Client) RemoveRegistry(ctx context.Context, host string) error
- func (c *Client) RemoveServer(ctx context.Context, idOrName, confirm string) (RemovedServer, error)
- func (c *Client) RenameApp(ctx context.Context, app, name string) (App, error)
- func (c *Client) RenameServer(ctx context.Context, idOrName, name string) (Server, error)
- func (c *Client) RenameWorkspace(ctx context.Context, slug, name string) error
- func (c *Client) ReplaceEnv(ctx context.Context, app string, env map[string]string) (dotenv.Change, error)
- func (c *Client) ResendInvitation(ctx context.Context, slug, id string) error
- func (c *Client) Restart(ctx context.Context, app string) (Deploy, error)
- func (c *Client) Restore(ctx context.Context, app, database, moment string, at *time.Time, ...) error
- func (c *Client) RevokeInvitation(ctx context.Context, slug, id string) error
- func (c *Client) Rollback(ctx context.Context, app string, number int) (Deploy, error)
- func (c *Client) RotateDeployHook(ctx context.Context, app string) (string, error)
- func (c *Client) Rows(ctx context.Context, app, database, table string, offset, limit int) (TableRows, error)
- func (c *Client) ServerMetrics(ctx context.Context, server, rangeName string) (ServerMetrics, error)
- func (c *Client) Servers(ctx context.Context) ([]Server, error)
- func (c *Client) SetAppBucket(ctx context.Context, app, bucket string) (App, error)
- func (c *Client) SetBackupSchedule(ctx context.Context, app string, schedule BackupSchedule) (BackupSchedule, error)
- func (c *Client) SetBucketKey(ctx context.Context, name, server, secretKey string) (Bucket, error)
- func (c *Client) SetDaemonUpdates(ctx context.Context, on bool) error
- func (c *Client) SetDomains(ctx context.Context, app string, domains []string, canonical string) (Change, error)
- func (c *Client) SetEmailAlerts(ctx context.Context, on bool) error
- func (c *Client) SetEnv(ctx context.Context, app string, set map[string]string, unset []string) ([]EnvVar, error)
- func (c *Client) SetInstant(ctx context.Context, app, provider string) (Change, error)
- func (c *Client) SetIntegrations(ctx context.Context, cloudflareToken, tailscaleKey *string, server string) (Integrations, error)
- func (c *Client) SetPassword(ctx context.Context, app, username, password string) (NewPassword, error)
- func (c *Client) SetPinned(ctx context.Context, app string, pinned bool) (App, error)
- func (c *Client) SetRegistry(ctx context.Context, host, username, password, server string) error
- func (c *Client) SetSecurity(ctx context.Context, server string, security Security) (Server, error)
- func (c *Client) SetServiceDomains(ctx context.Context, app, service string, domains []string) (Change, error)
- func (c *Client) SetUptime(ctx context.Context, app, domain string, path *string, paused *bool) (UptimeDomain, error)
- func (c *Client) Start(ctx context.Context, app string) (Deploy, error)
- func (c *Client) Status(ctx context.Context) (Status, error)
- func (c *Client) Stop(ctx context.Context, app string) error
- func (c *Client) Tables(ctx context.Context, app, database string) (protocol.DBTables, error)
- func (c *Client) Team(ctx context.Context) (Team, error)
- func (c *Client) TestAlertDestination(ctx context.Context, name string) (AlertDestination, error)
- func (c *Client) URL() string
- func (c *Client) UnlinkRepo(ctx context.Context, app string) error
- func (c *Client) UpdateApp(ctx context.Context, app, version string) (CatalogDeploy, error)
- func (c *Client) UpdateDaemon(ctx context.Context, idOrName string) (Server, error)
- func (c *Client) Uptime(ctx context.Context, app string) (Uptime, error)
- func (c *Client) UseSurface(surface string)
- func (c *Client) Version(ctx context.Context) (Version, error)
- func (c *Client) WatchApps(ctx context.Context, fn func([]App)) error
- func (c *Client) WatchServers(ctx context.Context, fn func([]Server)) error
- type ComposeFile
- type Config
- type Connection
- type CreatedApp
- type DatabaseBackup
- type DatabaseBackups
- type Deploy
- type DeployMark
- type DeviceLogin
- type DomainCheck
- type Download
- type EnvVar
- type Error
- type Event
- type ExecResult
- type GitHub
- type GitHubRepo
- type HubBackup
- type Instant
- type Integrations
- type Invitation
- type Meta
- type MetricsPoint
- type Moment
- type NewAlertDestination
- type NewPassword
- type NewServer
- type Outage
- type Registry
- type RemovedServer
- type Restore
- type SecretOn
- type SecretServers
- type Security
- type SecurityLine
- type Server
- type ServerAppMetrics
- type ServerMetrics
- type ServerMetricsNow
- type Status
- type StatusCounts
- type StatusIssue
- type StatusUpdate
- type TableRows
- type Team
- type Uptime
- type UptimeDomain
- type Version
Constants ¶
const DefaultURL = "https://moin.run"
DefaultURL is the hosted hub.
const FromDirectory = "the directory name"
FromDirectory says an app name came from the name of the directory.
const MovedHeader = "X-Hub-URL"
MovedHeader names the hub's address in an answer to a request that came on an old one.
Variables ¶
var ErrLoginEnded = errors.New("your login ended: run `" + build.Name + " login` again")
ErrLoginEnded is a connection the hub ended: removed in Settings, unused for 90 days, or its refresh token used twice.
var ErrNotLoggedIn = errors.New("not logged in: run `" + build.Name + " login`")
ErrNotLoggedIn means there is no token in the environment or config file.
var TokenVariable = strings.ToUpper(build.Name) + "_TOKEN"
TokenVariable overrides the saved token, for CI.
Functions ¶
func CheckURL ¶
CheckURL refuses a hub URL the token would cross the internet in plain text to. http is fine on this machine and on a tailnet, which Tailscale already encrypts; everywhere else it must be https.
func IsClientOutdated ¶
IsClientOutdated reports whether the hub refused this moin as too old. The message says how to update.
func IsNotFound ¶
IsNotFound reports whether err is a not_found answer.
func IsReadOnlyQuery ¶
IsReadOnlyQuery reports whether a read query was refused because it changes data.
func Logout ¶
Logout ends the connection of config at the hub, so its tokens stop working, before the config is forgotten. A CI token stays: it belongs to Settings.
func OriginRepo ¶
OriginRepo is owner/name of the GitHub repo of dir's remote origin, "" when it has none.
func PickApp ¶
PickApp is AppName that also says where the name came from: "--app" or FromDirectory.
func PushedCommit ¶
PushedCommit is what `moin deploy` deploys from dir: the GitHub repo of its remote origin, as owner/name, and the commit HEAD is at. The server builds that commit from GitHub, so it fails, saying what to do, unless dir is the top folder of a GitHub repo with every change committed and pushed.
func SaveConfig ¶
SaveConfig writes the config file, readable only by the user.
Types ¶
type Account ¶
type Account struct {
Email string `json:"email"`
Name string `json:"name"`
// EmailAlerts mails the user when a site or a server goes down or
// comes back, or a deploy fails.
EmailAlerts bool `json:"email_alerts"`
}
Account is the signed-in user.
type ActivityPage ¶
ActivityPage is a page of the activity, newest first. Next continues with older events and is empty on the last page.
type ActivityQuery ¶
ActivityQuery picks a page of the activity: up to Limit events, after the cursor of the page before, of one app, server or member (an email).
type AlertDestination ¶
type AlertDestination struct {
ID string `json:"id"`
Name string `json:"name"`
Kind string `json:"kind"`
Hint string `json:"hint"`
ChatID string `json:"chat_id"`
Events []string `json:"events"`
Failing bool `json:"failing"`
FailingSince *time.Time `json:"failing_since"`
LastError string `json:"last_error"`
LastSentAt *time.Time `json:"last_sent_at"`
CreatedAt time.Time `json:"created_at"`
// SigningSecret comes only with a new webhook.
SigningSecret string `json:"signing_secret,omitempty"`
}
AlertDestination is where the alerts of the workspace go besides email: Slack, Discord, Telegram or a webhook. Hint shows its host and last characters, never the URL or token.
type App ¶
type App struct {
ID string `json:"id"`
Name string `json:"name"`
ServerID string `json:"server_id"`
ServerName string `json:"server_name"`
LatestNumber int `json:"latest_number"`
LatestStatus string `json:"latest_status"`
LiveNumber int `json:"live_number"`
Domains []string `json:"domains"`
Canonical string `json:"canonical"`
// Password says the app's password is on: its domains and its
// instant address ask for it.
Password bool `json:"password"`
// ServiceDomains are the domains of the app's other services.
ServiceDomains map[string][]string `json:"service_domains"`
// Instant is the instant address, "" when the app has none. The
// app's password guards it like the app's domains.
Instant string `json:"instant"`
InstantProvider string `json:"instant_provider"`
Stopped bool `json:"stopped"`
// ChangesWaiting counts the changes saved since the live deploy
// started; a restart applies them. Only App fills it.
ChangesWaiting int `json:"changes_waiting"`
// Repo and Branch are the GitHub repo the app follows, if any.
Repo string `json:"repo"`
Branch string `json:"branch"`
AutoDeploy bool `json:"auto_deploy"`
Pinned bool `json:"pinned"`
// Hook says the app has a deploy hook URL.
Hook bool `json:"hook"`
// DeployFrom is ci or github, where new versions come from; empty
// while neither is set up.
DeployFrom string `json:"deploy_from"`
// HookImage is the image the hook deploys new tags of, the one running
// now; empty while the app runs from its repo.
HookImage string `json:"hook_image"`
// Bucket is the bucket the app backs up to; empty follows
// the workspace's default.
Bucket string `json:"bucket"`
// Catalog is the catalog entry the app was installed from; empty for
// an app of your own.
Catalog string `json:"catalog"`
CreatedAt time.Time `json:"created_at"`
}
App is a compose project on a server, as the API answers it.
type AppBackups ¶
type AppBackups struct {
Bucket string `json:"bucket"`
BackupSchedule
Databases []DatabaseBackups `json:"databases"`
}
AppBackups are the backups of an app's databases: the bucket the copies go to, the user's own, the schedule and each database.
type AppMetrics ¶
type AppMetrics struct {
App string `json:"app"`
Server string `json:"server"`
ServerOnline bool `json:"server_online"`
Range string `json:"range"`
StepSeconds int `json:"step_seconds"`
Now *AppMetricsNow `json:"now"`
Points []MetricsPoint `json:"points"`
Deploys []DeployMark `json:"deploys"`
}
AppMetrics are the metrics of an app: now, over a range, and the deploys that went live in it.
type AppMetricsNow ¶
type AppMetricsNow struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
MemoryUsed uint64 `json:"memory_used"`
MemoryLimit uint64 `json:"memory_limit"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Containers int `json:"containers"`
}
AppMetricsNow is the newest sample of an app; a MemoryLimit of 0 is none.
type BackupSchedule ¶
type BackupSchedule struct {
EveryMinutes int `json:"every_minutes"`
KeepDays int `json:"keep_days"`
}
BackupSchedule is how an app is backed up: a copy every EveryMinutes, each kept KeepDays.
type Bucket ¶
type Bucket struct {
Name string `json:"name"`
Default bool `json:"default"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
Path string `json:"path"`
Folder string `json:"folder,omitempty"`
AccessKey string `json:"access_key"`
Apps []string `json:"apps,omitempty"`
OlderBackups []string `json:"older_backups,omitempty"`
CreatedAt time.Time `json:"created_at"`
Servers []SecretOn `json:"servers,omitempty"`
MissingOn []string `json:"missing_on,omitempty"`
}
Bucket is one bucket of the workspace, without its secret key, which only the servers keep: Servers say which, MissingOn which do not. Apps use it now; OlderBackups moved away and keep older backups there.
func (Bucket) Input ¶
func (b Bucket) Input() BucketInput
Input is the bucket as it is, to change some of it.
type BucketInput ¶
type BucketInput struct {
Server string `json:"server,omitempty"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
Region string `json:"region"`
Bucket string `json:"bucket"`
Path string `json:"path"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Default bool `json:"default"`
}
BucketInput adds or changes a bucket. Server tests it and keeps the secret key, empty for the workspace's only server. On a change an empty Name keeps the name and an empty SecretKey the key the server keeps.
type CIToken ¶
type CIToken struct {
ID string `json:"id"`
Name string `json:"name"`
Prefix string `json:"prefix"`
Rights []string `json:"rights"`
App *string `json:"app"`
CreatedBy string `json:"created_by"`
LastUsedAt *time.Time `json:"last_used_at"`
ExpiresAt *time.Time `json:"expires_at"`
Expired bool `json:"expired"`
}
CIToken is a token made by hand for CI, as the API answers it.
type CatalogDeploy ¶
type CatalogDeploy struct {
App App `json:"app"`
Deploy Deploy `json:"deploy"`
// Login, only from an install, holds the secrets the first sign-in
// needs, such as ADMIN_PASSWORD: the one time they are shown.
Login map[string]string `json:"login"`
// Password, only from an install, is the app's password, user moin,
// which its domains and its instant address ask for: the one time
// moin shows it.
Password string `json:"password"`
}
CatalogDeploy is an installed or updated app and its started deploy.
type CatalogEntry ¶
type CatalogEntry struct {
Slug string `json:"slug"`
Name string `json:"name"`
Pitch string `json:"pitch"`
Category string `json:"category"`
Website string `json:"website"`
Source string `json:"source"`
License string `json:"license"`
Image string `json:"image"`
Database string `json:"database"`
// DatabaseNote says when moin does not back up the app's database.
DatabaseNote string `json:"database_note"`
Login string `json:"login"`
// NeedsDomain says the install needs --domain.
NeedsDomain bool `json:"needs_domain"`
Secrets []string `json:"secrets"`
Latest *CatalogVersion `json:"latest"`
Versions []CatalogVersion `json:"versions"`
}
CatalogEntry is an open source app moin installs in one click. Versions is only set by CatalogApp.
type CatalogInstall ¶
type CatalogInstall struct {
Server string `json:"server"`
Version string `json:"version,omitempty"`
Name string `json:"name,omitempty"`
Domain string `json:"domain,omitempty"`
}
CatalogInstall installs a catalog app; the empty fields take the newest release, the slug and no domain.
type CatalogVersion ¶
CatalogVersion is a release of a catalog app; Date is nil when the registry does not say.
type Change ¶
type Change struct {
App App `json:"app"`
// Unchanged is set when the app had it so already; nothing restarts.
Unchanged bool `json:"unchanged"`
}
Change is the app after a change of its settings. Saving never restarts it: the next restart, start or deploy applies the change.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls the hub as a connection or with a CI token.
func (*Client) Activity ¶
func (c *Client) Activity(ctx context.Context, query ActivityQuery) (ActivityPage, error)
Activity returns a page of the token's workspace activity, newest first.
func (*Client) AddAlertDestination ¶
func (c *Client) AddAlertDestination(ctx context.Context, destination NewAlertDestination) (AlertDestination, error)
AddAlertDestination adds an alert destination; a webhook comes back with its signing secret.
func (*Client) AlertDestinations ¶
func (c *Client) AlertDestinations(ctx context.Context) ([]AlertDestination, error)
AlertDestinations lists the alert destinations of the workspace.
func (*Client) AppMetrics ¶
AppMetrics returns the metrics of an app over a range: 1h, 24h, 7d or 30d, "" for 1h.
func (*Client) Catalog ¶
func (c *Client) Catalog(ctx context.Context) ([]CatalogEntry, error)
Catalog lists the catalog with each app's newest release.
func (*Client) CatalogApp ¶
CatalogApp returns a catalog app with every release, newest first.
func (*Client) CheckDomains ¶
CheckDomains looks up every domain of an app.
func (*Client) ComposeFile ¶
ComposeFile answers the compose file of the app's live deploy.
func (*Client) Connections ¶
func (c *Client) Connections(ctx context.Context) ([]Connection, error)
Connections lists the connections of the workspace this login is in, this one marked Current.
func (*Client) DaemonUpdates ¶
DaemonUpdates reports whether the daemons of the workspace update to the hub's version by themselves.
func (*Client) DeployImage ¶
DeployImage deploys an image built elsewhere as the app's main service. An app that follows a GitHub repo takes the compose file of ref there; an empty ref is the linked branch.
func (*Client) DeployRef ¶
DeployRef deploys a branch, tag or commit of the app's GitHub repo; an empty ref deploys the linked branch.
func (*Client) Download ¶
Download signs a link to a copy of a database: the newest, or the one moment names.
func (*Client) EditBucket ¶
EditBucket changes a bucket.
func (*Client) Exec ¶
func (c *Client) Exec(ctx context.Context, app, service string, argv []string, line string, timeout int, output func(string)) (ExecResult, error)
Exec runs a command in a container of an app and hands what it writes to output as it comes. argv is the command as words; line, used when argv is empty, is one line the hub splits like a shell quotes it.
func (*Client) FetchCopy ¶
FetchCopy writes the copy a download link points to, in the user's own bucket, to out. It goes straight to the bucket, not to the hub.
func (*Client) FollowDeploy ¶
func (c *Client) FollowDeploy(ctx context.Context, app string, number int, line func(string)) (Deploy, error)
FollowDeploy calls line for every log line of a deploy and returns the deploy once it ended.
func (*Client) GitHubBranches ¶
GitHubBranches lists the branches of a repo, owner/name, the default branch first.
func (*Client) GitHubRepos ¶
func (c *Client) GitHubRepos(ctx context.Context) ([]GitHubRepo, error)
GitHubRepos lists the repos moin may read.
func (*Client) InstallCatalogApp ¶
func (c *Client) InstallCatalogApp(ctx context.Context, slug string, install CatalogInstall) (CatalogDeploy, error)
InstallCatalogApp creates the app from the catalog and deploys it.
func (*Client) Integrations ¶
func (c *Client) Integrations(ctx context.Context) (Integrations, error)
Integrations says which keys are stored.
func (*Client) Invite ¶
Invite emails an invitation to the token's workspace. role is member or admin.
func (*Client) LinkRepo ¶
func (c *Client) LinkRepo(ctx context.Context, app, repo, branch string, autoDeploy bool) (App, error)
LinkRepo makes an app follow a repo and branch.
func (*Client) NewInstallCommand ¶
NewInstallCommand makes a new one-time install command for a server; the old one stops working.
func (*Client) Query ¶
func (c *Client) Query(ctx context.Context, app, database, sql string, write bool, limit int) (protocol.DBResult, error)
Query runs SQL on an app's database. Without write it cannot change anything.
func (*Client) Registries ¶
Registries lists the workspace's registry logins.
func (*Client) RemoveAlertDestination ¶
RemoveAlertDestination removes an alert destination by name or ID.
func (*Client) RemoveApp ¶
RemoveApp stops an app and removes it. Its data stays on the server. confirm is the app's name, typed out; the hub checks it.
func (*Client) RemoveBucket ¶
RemoveBucket forgets a bucket nothing uses; what is in it stays. confirm is the bucket's name, typed out; the hub checks it.
func (*Client) RemoveCIToken ¶
RemoveCIToken deletes a CI token.
func (*Client) RemoveConnection ¶
RemoveConnection ends a connection and its tokens.
func (*Client) RemoveDeployHook ¶
RemoveDeployHook turns the deploy hook off; its URL stops working.
func (*Client) RemovePassword ¶
RemovePassword turns the app's password off.
func (*Client) RemoveRegistry ¶
RemoveRegistry deletes the login for a registry host.
func (*Client) RemoveServer ¶
RemoveServer deletes a server by ID or name. Its daemon is disconnected and stays installed. An offline server goes with its apps. confirm is the server's name, typed out; the hub checks it.
func (*Client) RenameServer ¶
RenameServer gives a server a new name and returns it.
func (*Client) RenameWorkspace ¶
RenameWorkspace gives the workspace a new name.
func (*Client) ReplaceEnv ¶
func (c *Client) ReplaceEnv(ctx context.Context, app string, env map[string]string) (dotenv.Change, error)
ReplaceEnv makes env every env var of the app, like one .env file: keys not in env are removed. It answers what changed, by key. The next deploy gets them.
func (*Client) ResendInvitation ¶
ResendInvitation emails an open invitation again.
func (*Client) Restart ¶
Restart starts the live deploy again with the env and domains as they are now.
func (*Client) Restore ¶
func (c *Client) Restore(ctx context.Context, app, database, moment string, at *time.Time, confirm string) error
Restore puts a database back to a moment from Backups, by its ID or label, or to a time: the newest copy at or before it. It waits until the daemon is done: a restore runs on its own on the hub, as a big database takes a while. confirm is the app's name as the user typed it; the hub refuses a restore without it.
func (*Client) RevokeInvitation ¶
RevokeInvitation takes an open invitation back.
func (*Client) Rollback ¶
Rollback starts an earlier successful release again. Number 0 is the one before the live deploy.
func (*Client) RotateDeployHook ¶
RotateDeployHook gives the app a new deploy hook URL; the old one stops working.
func (*Client) Rows ¶
func (c *Client) Rows(ctx context.Context, app, database, table string, offset, limit int) (TableRows, error)
Rows returns one page of a table, newest first.
func (*Client) ServerMetrics ¶
func (c *Client) ServerMetrics(ctx context.Context, server, rangeName string) (ServerMetrics, error)
ServerMetrics returns the metrics of a server over a range.
func (*Client) SetAppBucket ¶
SetAppBucket moves an app's new backups to a bucket; empty follows the workspace's default.
func (*Client) SetBackupSchedule ¶
func (c *Client) SetBackupSchedule(ctx context.Context, app string, schedule BackupSchedule) (BackupSchedule, error)
SetBackupSchedule sets how often an app is copied and how long each copy stays.
func (*Client) SetBucketKey ¶
SetBucketKey hands one more server the secret key of a bucket; it tests the bucket with it first.
func (*Client) SetDaemonUpdates ¶
SetDaemonUpdates turns automatic daemon updates on or off.
func (*Client) SetDomains ¶
func (c *Client) SetDomains(ctx context.Context, app string, domains []string, canonical string) (Change, error)
SetDomains replaces the domains and the canonical one ("" for none).
func (*Client) SetEmailAlerts ¶
SetEmailAlerts turns the email alerts of the signed-in user on or off.
func (*Client) SetEnv ¶
func (c *Client) SetEnv(ctx context.Context, app string, set map[string]string, unset []string) ([]EnvVar, error)
SetEnv sets and removes env vars and answers them all, by key. The next deploy gets them.
func (*Client) SetInstant ¶
SetInstant picks the provider of the instant address, or off.
func (*Client) SetIntegrations ¶
func (c *Client) SetIntegrations(ctx context.Context, cloudflareToken, tailscaleKey *string, server string) (Integrations, error)
SetIntegrations stores keys; a nil one stays, an empty one is removed. The Tailscale key goes to server, which keeps it; empty is the workspace's only server.
func (*Client) SetPassword ¶
func (c *Client) SetPassword(ctx context.Context, app, username, password string) (NewPassword, error)
SetPassword turns the app's password on for its domains and its instant address. An empty password lets moin make one.
func (*Client) SetRegistry ¶
SetRegistry hands the login for a registry host to a server, which keeps it; an empty server is the workspace's only one.
func (*Client) SetSecurity ¶
SetSecurity applies the settings and returns the server with what its daemon set up.
func (*Client) SetServiceDomains ¶
func (c *Client) SetServiceDomains(ctx context.Context, app, service string, domains []string) (Change, error)
SetServiceDomains replaces the domains of another service of the app.
func (*Client) SetUptime ¶
func (c *Client) SetUptime(ctx context.Context, app, domain string, path *string, paused *bool) (UptimeDomain, error)
SetUptime changes the path of a domain's visit, nil keeps it and "" goes back to /, and pauses or resumes it, nil keeps it.
func (*Client) TestAlertDestination ¶
TestAlertDestination sends a test alert to a destination.
func (*Client) UnlinkRepo ¶
UnlinkRepo stops an app from following its repo.
func (*Client) UpdateApp ¶
UpdateApp sets a catalog app to version, the newest when empty, and deploys it.
func (*Client) UpdateDaemon ¶
UpdateDaemon has the daemon of a server download the hub's moin binary, swap it in and restart. It returns the server once the new daemon is back.
func (*Client) UseSurface ¶
UseSurface names the program that sends the requests: "cli" or "tui".
type ComposeFile ¶
ComposeFile is the compose file of an app's live deploy, YAML: everything moin runs for it, without a secret value.
type Config ¶
type Config struct {
URL string `json:"url"`
Token string `json:"token"`
// RefreshToken gets the next pair once ExpiresAt comes.
RefreshToken string `json:"refresh_token,omitempty"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
// Connection is the ID of the connection the login made.
Connection string `json:"connection,omitempty"`
// TokenFromEnv is true when the token came from MOIN_TOKEN.
TokenFromEnv bool `json:"-"`
// contains filtered or unexported fields
}
Config is what `moin login` saves. A login in the browser keeps the access token of its connection in Token, the refresh token and when the access token ends; the client refreshes them by itself. A CI token has only Token.
func LoadConfig ¶
LoadConfig reads the config file. MOIN_URL and MOIN_TOKEN override it.
func LoginInBrowser ¶
func LoginInBrowser(ctx context.Context, baseURL, surface string, show func(DeviceLogin)) (Config, error)
LoginInBrowser logs this computer in through the browser, the device flow of RFC 8628: it starts a login on the hub at baseURL, calls show with the code and the page to open, and polls until the user approved or denied it there, or it expired. surface is "cli" or "tui". The config it returns has the tokens of the new connection; the caller saves it with SaveConfig.
type Connection ¶
type Connection struct {
ID string `json:"id"`
ClientName string `json:"client_name"`
RedirectHost string `json:"redirect_host"`
WorkspaceID string `json:"workspace_id"`
Rights []string `json:"rights"`
Current bool `json:"current"`
LastUsedAt *time.Time `json:"last_used_at"`
CreatedAt time.Time `json:"created_at"`
}
Connection is a client let in from the browser, as the API answers it.
type CreatedApp ¶
CreatedApp is the answer of AddApp: the app and its password, user moin, the one time moin shows it.
type DatabaseBackup ¶
type DatabaseBackup struct {
Database string `json:"database"`
Kind string `json:"kind,omitempty"`
CopiedAt *time.Time `json:"copied_at,omitempty"`
CheckedAt *time.Time `json:"checked_at,omitempty"`
CheckError string `json:"check_error,omitempty"`
Copies []protocol.Copy `json:"copies"`
Undos []protocol.Copy `json:"undos"`
Error string `json:"error,omitempty"`
}
DatabaseBackup is how one database is backed up, as the daemon reports it: protocol.DatabaseBackup under the API's own names.
type DatabaseBackups ¶
type DatabaseBackups struct {
DatabaseBackup
Problem string `json:"problem,omitempty"`
Moments []Moment `json:"moments"`
}
DatabaseBackups is the backup of one database: how it stands, Problem in one sentence when it does not work, and the moments a restore can go back to.
type Deploy ¶
type Deploy struct {
Number int `json:"number"`
Status string `json:"status"`
FromNumber int `json:"from_number"`
Image string `json:"image"`
// Ref and Commit name the GitHub commit the deploy came from.
Ref string `json:"ref"`
Commit string `json:"commit"`
CommitMessage string `json:"commit_message"`
Error string `json:"error"`
Detected *protocol.Detected `json:"detected"`
CreatedAt time.Time `json:"created_at"`
FinishedAt *time.Time `json:"finished_at"`
Log []string `json:"log"`
}
Deploy is one version of an app, v12.
type DeployMark ¶
DeployMark is a deploy that went live.
type DeviceLogin ¶
type DeviceLogin struct {
DeviceCode string `json:"device_code"`
UserCode string `json:"user_code"`
VerificationURI string `json:"verification_uri"`
VerificationURIComplete string `json:"verification_uri_complete"`
ExpiresIn int `json:"expires_in"`
Interval int `json:"interval"`
}
DeviceLogin is a login in the browser that waits for the user: the code to check and the page to approve it on.
type DomainCheck ¶
type DomainCheck struct {
Domain string `json:"domain"`
Canonical bool `json:"canonical"`
Address string `json:"address"`
IPv4 string `json:"ipv4"`
IPv6 string `json:"ipv6"`
Advice string `json:"advice"`
Found []string `json:"found"`
Points bool `json:"points"`
// Service is the service of compose.yml the domain reaches, empty for
// the main one.
Service string `json:"service"`
}
DomainCheck says whether a domain points at the app's server.
type Download ¶
type Download struct {
App string `json:"app"`
Database string `json:"database"`
Copy string `json:"copy"`
Label string `json:"label"`
At time.Time `json:"at"`
Size int64 `json:"size"`
Link string `json:"link"`
}
Download is a copy of a database in the app's bucket; Link is a link to it there, signed by the app's server, valid 15 minutes.
type EnvVar ¶
EnvVar is an env var of an app: its key and when it changed. Values are write-only: the hub never answers one.
type Event ¶
type Event struct {
ID string `json:"id"`
Action string `json:"action"`
Actor string `json:"actor"`
Summary string `json:"summary"`
Via string `json:"via"`
Token string `json:"token"`
App string `json:"app"`
Server string `json:"server"`
IP string `json:"ip"`
UserAgent string `json:"user_agent"`
Metadata string `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
}
Event is one thing that happened in the workspace. Actor and Summary read as a sentence: "Ada Lovelace deployed blog v12". Via is web, cli, tui, api, mcp, hook, github or system, Token the connection or CI token by name. IP and UserAgent are there for admins only.
type ExecResult ¶
type ExecResult struct {
Service string `json:"service"`
ExitCode int `json:"exit_code"`
Truncated bool `json:"truncated"`
TimedOut bool `json:"timed_out"`
}
ExecResult is how a command ended.
type GitHub ¶
type GitHub struct {
Enabled bool `json:"enabled"`
ConnectURL string `json:"connect_url"`
InstallURL string `json:"install_url"`
Installations []struct {
ID int64 `json:"id"`
Account string `json:"account"`
SettingsURL string `json:"settings_url"`
} `json:"installations"`
}
GitHub is where the moin GitHub App is installed.
type GitHubRepo ¶
type GitHubRepo struct {
FullName string `json:"full_name"`
DefaultBranch string `json:"default_branch"`
Private bool `json:"private"`
Account string `json:"account"`
}
GitHubRepo is a repo moin may read.
type HubBackup ¶
type HubBackup struct {
State string `json:"state"`
Bucket string `json:"bucket"`
LastCopy *time.Time `json:"last_copy"`
}
HubBackup is how the backup of the hub's own database stands: State is on, off or late.
type Instant ¶
type Instant struct {
URL string `json:"url"`
Provider string `json:"provider"`
Reason string `json:"reason"`
}
Instant is the app's instant address, or why it has none.
type Integrations ¶
type Integrations struct {
Cloudflare bool `json:"cloudflare"`
CloudflareAccount string `json:"cloudflare_account"`
Tailscale SecretServers `json:"tailscale"`
}
Integrations says which keys there are: the Cloudflare API token the hub keeps, and the servers that keep a Tailscale key.
type Invitation ¶
type Invitation struct {
ID string `json:"id"`
Email string `json:"email"`
Role string `json:"role"`
ExpiresAt time.Time `json:"expires_at"`
}
Invitation is an open invitation to the workspace.
type Meta ¶
type Meta struct {
Name string `json:"name"`
// Version is the version of the hub and of the moin binary
// it serves; "dev" for a build without one.
Version string `json:"version"`
}
Meta is what the hub says about itself.
type MetricsPoint ¶
type MetricsPoint struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
Memory uint64 `json:"memory"`
Disk uint64 `json:"disk"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Load float64 `json:"load"`
}
MetricsPoint is a server or an app at one point; apps have no disk and no load.
type Moment ¶
type Moment struct {
ID string `json:"id"`
Label string `json:"label"`
At time.Time `json:"at"`
Kind string `json:"kind"`
}
Moment is one moment to go back to; Restore takes its ID or label.
type NewAlertDestination ¶
type NewAlertDestination struct {
Kind string `json:"kind"`
Name string `json:"name"`
URL string `json:"url,omitempty"`
BotToken string `json:"bot_token,omitempty"`
ChatID string `json:"chat_id,omitempty"`
Events []string `json:"events,omitempty"`
}
NewAlertDestination is a destination to add. URL is for Slack, Discord and webhooks; BotToken and ChatID for Telegram. No events means all.
type NewPassword ¶
NewPassword is the answer of SetPassword: the change, and the password moin made when none was given, the one time it shows it.
type NewServer ¶
type NewServer struct {
Server Server `json:"server"`
InstallToken string `json:"install_token"`
InstallCommand string `json:"install_command"`
ExpiresAt time.Time `json:"expires_at"`
}
NewServer is a server that waits for its daemon.
type Outage ¶
type Outage struct {
StartedAt time.Time `json:"started_at"`
EndedAt *time.Time `json:"ended_at"`
Reason string `json:"reason"`
}
Outage is a time a domain was down; EndedAt is nil while it lasts.
type Registry ¶
type Registry struct {
Host string `json:"host"`
Username string `json:"username"`
CreatedAt time.Time `json:"created_at"`
Servers []SecretOn `json:"servers"`
MissingOn []string `json:"missing_on"`
}
Registry is a registry login without its password, which only the servers keep: Servers say which, MissingOn which do not.
type RemovedServer ¶
RemovedServer is a server just removed: the command that removes its daemon on the machine, empty when no daemon ever connected there, and the apps that went with it because it was offline.
type Restore ¶
type Restore struct {
ID string `json:"id"`
Database string `json:"database"`
To string `json:"to"`
State string `json:"state"`
Error string `json:"error"`
}
Restore is a restore the daemon runs: running, then done or failed.
type SecretServers ¶
type SecretServers struct {
Servers []SecretOn `json:"servers"`
MissingOn []string `json:"missing_on"`
}
SecretServers says which servers keep a secret and which do not.
type Security ¶
type Security struct {
Tunnel bool `json:"tunnel"`
SSH string `json:"ssh"`
Firewall bool `json:"firewall"`
}
Security is how a server should be reached and locked down. SSH is tailscale, everyone or off.
type SecurityLine ¶
type SecurityLine struct {
Name, Is, Set string
}
SecurityLine is one line of how a server is reached: what is on the server (Is) and what is set (Set), the lines of its Security page.
type Server ¶
type Server struct {
ID string `json:"id"`
Name string `json:"name"`
Online bool `json:"online"`
Hostname string `json:"hostname"`
OS string `json:"os"`
Arch string `json:"arch"`
DaemonVersion string `json:"daemon_version"`
LastSeenAt *time.Time `json:"last_seen_at"`
// Tunnel, SSH and Firewall say how the server should be reached and
// locked down; SSH is tailscale, everyone or off. Security is what its
// daemon last saw on it.
Tunnel bool `json:"tunnel"`
SSH string `json:"ssh"`
Firewall bool `json:"firewall"`
Security *protocol.ServerConfigResult `json:"security"`
// Rules are what the owner allows moin to do on the server, from
// /etc/moin/rules there. Nil without rules.
Rules *protocol.Rules `json:"rules"`
CreatedAt time.Time `json:"created_at"`
}
Server is a server with a daemon, as the API answers it.
func (Server) Outdated ¶
Outdated reports whether the server's daemon runs another version than the hub. Development builds never count.
func (Server) SecurityLines ¶
func (s Server) SecurityLines() []SecurityLine
SecurityLines are web, SSH and the firewall, the lines of the Security page in the same words, once the daemon reported; nil before.
type ServerAppMetrics ¶
type ServerAppMetrics struct {
App string `json:"app"`
Now *AppMetricsNow `json:"now"`
}
ServerAppMetrics is an app on a server and its newest sample, nil when it does not run.
type ServerMetrics ¶
type ServerMetrics struct {
Server string `json:"server"`
Online bool `json:"online"`
Range string `json:"range"`
StepSeconds int `json:"step_seconds"`
Now *ServerMetricsNow `json:"now"`
Points []MetricsPoint `json:"points"`
Apps []ServerAppMetrics `json:"apps"`
}
ServerMetrics are the metrics of a server: now, over a range, and its apps now, the one with the most memory first.
type ServerMetricsNow ¶
type ServerMetricsNow struct {
At time.Time `json:"at"`
CPU float64 `json:"cpu"`
Cores int `json:"cores"`
MemoryUsed uint64 `json:"memory_used"`
MemoryTotal uint64 `json:"memory_total"`
DiskUsed uint64 `json:"disk_used"`
DiskTotal uint64 `json:"disk_total"`
NetRx float64 `json:"net_rx"`
NetTx float64 `json:"net_tx"`
Load float64 `json:"load"`
}
ServerMetricsNow is the newest sample of a server.
type Status ¶
type Status struct {
OK bool `json:"ok"`
Issues []StatusIssue `json:"issues"`
Updates []StatusUpdate `json:"updates"`
Counts StatusCounts `json:"counts"`
}
Status says whether everything is OK in the workspace.
type StatusCounts ¶
type StatusCounts struct {
Apps int `json:"apps"`
AppsLive int `json:"apps_live"`
Servers int `json:"servers"`
ServersOnline int `json:"servers_online"`
Databases int `json:"databases"`
BackupsChecked int `json:"backups_checked"`
}
StatusCounts is what runs well.
type StatusIssue ¶
type StatusIssue struct {
Kind string `json:"kind"`
Target string `json:"target"`
Detail string `json:"detail"`
Path string `json:"path"`
Since *time.Time `json:"since"`
}
StatusIssue is one thing that needs you, with the web page to fix it, under the workspace.
type StatusUpdate ¶
type StatusUpdate struct {
App string `json:"app"`
Name string `json:"name"`
Version string `json:"version"`
Latest string `json:"latest"`
}
StatusUpdate is a catalog app with a newer release.
type TableRows ¶
type TableRows struct {
Database string `json:"database"`
Table protocol.DBTable `json:"table"`
Columns []string `json:"columns"`
Rows [][]any `json:"rows"`
Offset int `json:"offset"`
Limit int `json:"limit"`
Truncated bool `json:"truncated"`
}
TableRows is one page of a table. When the table has a rowid, it is the first column.
type Team ¶
type Team struct {
Workspace struct {
ID string `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
} `json:"workspace"`
Role string `json:"role"`
Permissions struct {
ManageWorkspace bool `json:"manage_workspace"`
ManageMembers bool `json:"manage_members"`
} `json:"permissions"`
Members []struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Role string `json:"role"`
} `json:"members"`
Invitations []Invitation `json:"invitations"`
}
Team is the workspace of the token with its members and the invitations still open.
type Uptime ¶
type Uptime struct {
App string `json:"app"`
State string `json:"state"`
Server string `json:"server"`
ServerOnline bool `json:"server_online"`
Domains []UptimeDomain `json:"domains"`
}
Uptime is the uptime of an app: one state for all its domains, its server, and each domain.
type UptimeDomain ¶
type UptimeDomain struct {
Domain string `json:"domain"`
Path string `json:"path"`
CustomPath bool `json:"custom_path"`
Paused bool `json:"paused"`
State string `json:"state"`
Since *time.Time `json:"since"`
VisitedAt *time.Time `json:"visited_at"`
StatusCode int `json:"status_code"`
ResponseMS int `json:"response_ms"`
Error string `json:"error"`
CertExpiresAt *time.Time `json:"cert_expires_at"`
Uptime24h *float64 `json:"uptime_24h"`
Uptime7d *float64 `json:"uptime_7d"`
Uptime30d *float64 `json:"uptime_30d"`
AverageMS int `json:"average_ms"`
Outages []Outage `json:"outages"`
}
UptimeDomain is the uptime of one domain.
type Version ¶
type Version struct {
Version string `json:"version"`
SelfHosted bool `json:"self_hosted"`
Latest string `json:"latest"`
UpdateAvailable bool `json:"update_available"`
PublishedAt *time.Time `json:"published_at"`
NotesURL string `json:"notes_url"`
Summary string `json:"summary"`
ReadFirst string `json:"read_first"`
// HubBackup is how the backup of the hub's own database stands; only
// the admins of the hub get it.
HubBackup *HubBackup `json:"hub_backup"`
}
Version is the hub's version and, on a self-hosted one, the newest release.