Documentation
¶
Index ¶
- Constants
- func ReleaseAssetURL(tag, goos, goarch string) (archiveURL, binaryInArchive string, err error)
- type ApiToken
- type Client
- func (c *Client) AcceptInvite(ctx context.Context, clusterName string) error
- func (c *Client) AddClusterUsers(ctx context.Context, clusterName string, emails []string, role string) error
- func (c *Client) AddInstanceDomain(ctx context.Context, name, domain string) error
- func (c *Client) Cluster() string
- func (c *Client) CreateDeployment(ctx context.Context, req CreateDeploymentRequest) (CreateDeploymentResult, error)
- func (c *Client) CreateToken(ctx context.Context, name string, scopes []string, expiresIn *int) (CreatedApiToken, error)
- func (c *Client) DeclineInvite(ctx context.Context, clusterName string) error
- func (c *Client) DeleteDeployment(ctx context.Context, id string) error
- func (c *Client) DeleteInstance(ctx context.Context, id string) error
- func (c *Client) DeleteService(ctx context.Context, id string) error
- func (c *Client) ExchangeOIDCToken(ctx context.Context, token string) (string, error)
- func (c *Client) Get2FAStatus(ctx context.Context) (TwoFAStatus, error)
- func (c *Client) GetCluster(ctx context.Context, name string) (Cluster, error)
- func (c *Client) GetDeployment(ctx context.Context, id string) (Deployment, error)
- func (c *Client) GetInstance(ctx context.Context, id string) (Instance, error)
- func (c *Client) GetLatestVersion(ctx context.Context) (string, error)
- func (c *Client) GetLogs(ctx context.Context, q LogQuery) ([]LogChunk, error)
- func (c *Client) GetService(ctx context.Context, id string) (Service, error)
- func (c *Client) ListClusterUsers(ctx context.Context, clusterName string) ([]ClusterUser, error)
- func (c *Client) ListClusters(ctx context.Context) ([]Cluster, error)
- func (c *Client) ListDeployments(ctx context.Context, limit int) ([]Deployment, error)
- func (c *Client) ListInstances(ctx context.Context, limit int) ([]Instance, error)
- func (c *Client) ListInvites(ctx context.Context) ([]PendingInvite, error)
- func (c *Client) ListServices(ctx context.Context, limit int) ([]Service, error)
- func (c *Client) ListTokens(ctx context.Context) ([]ApiToken, error)
- func (c *Client) Logout(ctx context.Context) error
- func (c *Client) Me(ctx context.Context) (Me, error)
- func (c *Client) PingInstance(ctx context.Context, name string) error
- func (c *Client) RawResponse(ctx context.Context, method, path string, query url.Values, body any) (*http.Response, error)
- func (c *Client) RemoveClusterUsers(ctx context.Context, clusterName string, userIDs []string) error
- func (c *Client) RequestEmailOTP(ctx context.Context, email string) (requireTotp bool, err error)
- func (c *Client) RevokeToken(ctx context.Context, id string) error
- func (c *Client) RotateInstanceToken(ctx context.Context, instanceID string) error
- func (c *Client) StartService(ctx context.Context, id string) error
- func (c *Client) StopService(ctx context.Context, id string) error
- func (c *Client) StreamLogs(ctx context.Context, serviceID, source string, onChunk func(LogChunk)) error
- func (c *Client) SystemReboot(ctx context.Context, instanceID string, force bool) error
- func (c *Client) SystemRestart(ctx context.Context, instanceID string, force bool) error
- func (c *Client) UpdateCluster(ctx context.Context, name, newName string) (Cluster, error)
- func (c *Client) Verify2FA(ctx context.Context, code string) error
- func (c *Client) VerifyEmailOTP(ctx context.Context, email, code string) (string, error)
- func (c *Client) WithCluster(name string) *Client
- type Cluster
- type ClusterUser
- type CreateDeploymentRequest
- type CreateDeploymentResult
- type CreatedApiToken
- type Deployment
- type ErrTwoFARequired
- type Instance
- type LogChunk
- type LogQuery
- type LogSubscribeRequest
- type LoginEmailRequest
- type Me
- type PendingInvite
- type Service
- type TwoFAStatus
- type UnixTime
- type VerifyEmailRequest
- type VersionsResponse
Constants ¶
const EnvToken = "DPLOYR_TOKEN"
EnvToken is the environment variable checked before config for CI usage.
Variables ¶
This section is empty.
Functions ¶
func ReleaseAssetURL ¶ added in v0.6.53
ReleaseAssetURL constructs the GitHub release asset URL for the given version, OS, and architecture, matching the GoReleaser archive naming convention: dployr-{OS}-{arch}.tar.gz (or .zip on Windows)
Types ¶
type ApiToken ¶
type ApiToken struct {
ID string `json:"id"`
Name string `json:"name"`
Scopes []string `json:"scopes"`
CreatedAt UnixTime `json:"createdAt"`
ExpiresAt *UnixTime `json:"expiresAt,omitempty"`
LastUsedAt *UnixTime `json:"lastUsedAt,omitempty"`
}
ApiToken is a scoped personal access token (dpat_).
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a typed HTTP client for the dployr-base API.
func (*Client) AcceptInvite ¶
AcceptInvite accepts a cluster invite identified by cluster name.
func (*Client) AddClusterUsers ¶
func (c *Client) AddClusterUsers(ctx context.Context, clusterName string, emails []string, role string) error
AddClusterUsers invites users to a cluster with a given role.
func (*Client) AddInstanceDomain ¶
AddInstanceDomain configures a custom domain on an instance.
func (*Client) CreateDeployment ¶
func (c *Client) CreateDeployment(ctx context.Context, req CreateDeploymentRequest) (CreateDeploymentResult, error)
CreateDeployment submits a new deployment and returns the task ID.
func (*Client) CreateToken ¶
func (c *Client) CreateToken(ctx context.Context, name string, scopes []string, expiresIn *int) (CreatedApiToken, error)
CreateToken creates a new scoped personal access token. The returned CreatedApiToken includes the plaintext — it is shown only once.
func (*Client) DeclineInvite ¶
DeclineInvite declines a cluster invite identified by cluster name.
func (*Client) DeleteDeployment ¶
DeleteDeployment removes a deployment by ID.
func (*Client) DeleteInstance ¶
DeleteInstance removes an instance.
func (*Client) DeleteService ¶
DeleteService deletes a service and its associated resources.
func (*Client) ExchangeOIDCToken ¶
ExchangeOIDCToken exchanges a CI-issued OIDC token for a dployr session ID. Corresponds to POST /v1/auth/oidc/exchange.
func (*Client) Get2FAStatus ¶ added in v0.6.54
func (c *Client) Get2FAStatus(ctx context.Context) (TwoFAStatus, error)
Get2FAStatus returns the current user's 2FA configuration.
func (*Client) GetCluster ¶
GetCluster returns a cluster by name by scanning the user's cluster list. There is no dedicated GET /:id endpoint — name lookup is done client-side.
func (*Client) GetDeployment ¶
GetDeployment returns a single deployment by ID.
func (*Client) GetInstance ¶
GetInstance returns a single instance by ID. The server returns { "success": true, "data": <instance> } with the instance directly as the data value (no intermediate field name).
func (*Client) GetLatestVersion ¶ added in v0.6.53
GetLatestVersion fetches the latest CLI version from /v1/runtime/versions.
func (*Client) GetLogs ¶
GetLogs fetches historical log entries for a service.
TODO: Wire to GET /v1/services/:id/logs once the centralized log API is finalized. Expected query params: source, since (RFC3339), limit.
func (*Client) GetService ¶
GetService returns a service by ID.
func (*Client) ListClusterUsers ¶
ListClusterUsers returns all users in a cluster identified by name.
func (*Client) ListClusters ¶
ListClusters returns all clusters the authenticated user belongs to.
func (*Client) ListDeployments ¶
ListDeployments returns deployments in the active cluster.
func (*Client) ListInstances ¶
ListInstances returns instances visible to the authenticated user.
func (*Client) ListInvites ¶
func (c *Client) ListInvites(ctx context.Context) ([]PendingInvite, error)
ListInvites returns pending cluster invites for the authenticated user.
func (*Client) ListServices ¶
ListServices returns services in the active cluster.
func (*Client) ListTokens ¶
ListTokens returns all personal access tokens for the authenticated user.
func (*Client) Me ¶
Me returns the current authenticated user's profile. Corresponds to GET /v1/users/me.
func (*Client) PingInstance ¶
PingInstance sends a health ping to the instance daemon.
func (*Client) RawResponse ¶
func (c *Client) RawResponse(ctx context.Context, method, path string, query url.Values, body any) (*http.Response, error)
RawResponse returns the raw *http.Response for callers that need to handle streaming or custom decoding (e.g. WebSocket upgrade).
func (*Client) RemoveClusterUsers ¶
func (c *Client) RemoveClusterUsers(ctx context.Context, clusterName string, userIDs []string) error
RemoveClusterUsers removes users from a cluster.
func (*Client) RequestEmailOTP ¶
RequestEmailOTP sends an OTP to the given email address and returns whether the account requires TOTP instead of an email code. Corresponds to POST /v1/auth/login/email.
func (*Client) RevokeToken ¶
RevokeToken deletes a token by ID.
func (*Client) RotateInstanceToken ¶
RotateInstanceToken rotates the access token for an instance.
func (*Client) StartService ¶
StartService wakes a sleeping service.
func (*Client) StopService ¶
StopService stops (sleeps) a service.
func (*Client) StreamLogs ¶
func (c *Client) StreamLogs(ctx context.Context, serviceID, source string, onChunk func(LogChunk)) error
StreamLogs opens a server-sent events (or newline-delimited JSON) stream for real-time log output from both build and instance nodes.
TODO: The streaming endpoint and wire format will be confirmed once the centralized logging implementation in dployr-base is finalized. Candidate endpoints:
- GET /v1/services/:id/logs?follow=true (SSE / ndjson)
- WS /v1/ws/logs/:serviceId (WebSocket, LogSubscribeRequest protocol)
onChunk is called for each received LogChunk. The stream ends when ctx is cancelled or the server closes the connection.
func (*Client) SystemReboot ¶
SystemReboot reboots the underlying machine.
func (*Client) SystemRestart ¶
SystemRestart restarts the dployrd daemon on the instance.
func (*Client) UpdateCluster ¶
UpdateCluster renames a cluster. Resolves the cluster name to its ID first since the rename endpoint requires the cluster UUID.
func (*Client) Verify2FA ¶ added in v0.6.54
Verify2FA submits a TOTP code (or backup code) and marks the session as 2FA-verified. Corresponds to POST /v1/auth/2fa/verify.
func (*Client) VerifyEmailOTP ¶
VerifyEmailOTP submits the OTP code and returns the session cookie on success. Corresponds to POST /v1/auth/login/email/verify.
func (*Client) WithCluster ¶
WithCluster returns a copy of the client scoped to a specific cluster name.
type ClusterUser ¶
type CreateDeploymentRequest ¶
type CreateDeploymentRequest struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Source string `json:"source"` // remote | image
Type string `json:"type,omitempty"`
RuntimeType string `json:"runtimeType"`
RuntimeVersion string `json:"runtimeVersion,omitempty"`
RunCmd string `json:"runCmd,omitempty"`
BuildCmd string `json:"buildCmd,omitempty"`
Port int `json:"port,omitempty"`
WorkingDir string `json:"workingDir,omitempty"`
StaticDir string `json:"staticDir,omitempty"`
HealthCheck string `json:"healthCheck,omitempty"`
Image string `json:"image,omitempty"`
Domain string `json:"domain,omitempty"`
RemoteURL string `json:"remoteUrl,omitempty"`
RemoteBranch string `json:"remoteBranch,omitempty"`
RemoteCommitHash string `json:"remoteCommitHash,omitempty"`
EnvVars map[string]string `json:"envVars,omitempty"`
Secrets map[string]string `json:"secrets,omitempty"`
ForceRebuild bool `json:"forceRebuild,omitempty"`
}
type CreateDeploymentResult ¶
type CreatedApiToken ¶
CreatedApiToken is returned once on token creation — includes the plaintext.
type Deployment ¶
type Deployment struct {
ID string `json:"id"`
ClusterID string `json:"clusterId"`
ServiceID string `json:"serviceId"`
UserID string `json:"userId"`
Name string `json:"name"`
Type string `json:"type"`
Source string `json:"source"` // remote | image
Status string `json:"status"` // pending | running | success | failed
Description string `json:"description"`
RunCmd string `json:"runCmd"`
BuildCmd string `json:"buildCmd"`
Port int `json:"port"`
WorkingDir string `json:"workingDir"`
StaticDir string `json:"staticDir"`
Image string `json:"image"`
Domain string `json:"domain"`
RuntimeType string `json:"runtimeType"`
RuntimeVersion string `json:"runtimeVersion"`
RemoteURL string `json:"remoteUrl"`
RemoteBranch string `json:"remoteBranch"`
RemoteCommitHash string `json:"remoteCommitHash"`
CreatedAt UnixTime `json:"createdAt"`
UpdatedAt UnixTime `json:"updatedAt"`
FinishedAt *UnixTime `json:"finishedAt,omitempty"`
}
type ErrTwoFARequired ¶ added in v0.6.54
type ErrTwoFARequired struct{}
ErrTwoFARequired is returned when the server responds with auth.two_fa_required (HTTP 403). Callers can detect this with errors.Is to prompt the user for a TOTP code and retry.
func (ErrTwoFARequired) Error ¶ added in v0.6.54
func (ErrTwoFARequired) Error() string
type Instance ¶
type Instance struct {
ID string `json:"id"`
Kind string `json:"kind"` // dedicated | pool
ClusterID *string `json:"clusterId,omitempty"`
Address string `json:"address"`
Tag string `json:"tag"`
Status string `json:"status"` // healthy | degraded | offline | unreachable | maintenance | provisioning
Role string `json:"role"` // instance | build
Managed bool `json:"managed"`
Region string `json:"region,omitempty"`
CreatedAt UnixTime `json:"createdAt"`
UpdatedAt UnixTime `json:"updatedAt"`
}
type LogChunk ¶
type LogChunk struct {
Timestamp UnixTime `json:"timestamp"`
Source string `json:"source"` // build | runtime
Level string `json:"level"` // info | warn | error
Message string `json:"message"`
}
LogChunk is a single log entry returned from the log API.
type LogQuery ¶
type LogQuery struct {
ServiceID string
Source string // build | runtime | all (default: all)
Since time.Time // zero means no filter
Limit int // 0 means server default
}
LogQuery parameters for historical log retrieval. The API endpoint and exact field names will be confirmed once the centralized logging implementation in dployr-base is finalized.
type LogSubscribeRequest ¶
type LogSubscribeRequest struct {
Kind string `json:"kind"` // "log_subscribe"
ServiceID string `json:"serviceId"`
Source string `json:"source"` // build | runtime | all
}
LogSubscribeRequest is sent over WebSocket to subscribe to a service log stream.
type LoginEmailRequest ¶
type LoginEmailRequest struct {
Email string `json:"email"`
}
LoginEmailRequest is the body for POST /v1/auth/login/email.
type PendingInvite ¶
type PendingInvite struct {
ClusterID string `json:"clusterId"`
ClusterName string `json:"clusterName"`
OwnerName string `json:"ownerName"`
}
PendingInvite is returned by GET /v1/clusters/users/invites.
type Service ¶
type Service struct {
ID string `json:"id"`
ClusterID string `json:"clusterId"`
Name string `json:"name"`
Label string `json:"label"`
Type string `json:"type"` // static | web | worker | job
DeploymentID *string `json:"deploymentId,omitempty"`
DeploymentName *string `json:"deploymentName,omitempty"`
IcedAt *UnixTime `json:"icedAt,omitempty"`
CreatedAt UnixTime `json:"createdAt"`
UpdatedAt UnixTime `json:"updatedAt"`
}
type TwoFAStatus ¶ added in v0.6.54
type TwoFAStatus struct {
Method string `json:"method"`
TotpEnabled bool `json:"totpEnabled"`
BackupCodesRemaining int `json:"backupCodesRemaining"`
}
TwoFAStatus mirrors GET /v1/auth/2fa/status.
type UnixTime ¶
UnixTime is a time.Time that unmarshals from either a Unix timestamp (ms or s) or an RFC3339 string, matching the server's D1/SQLite storage format.
func (UnixTime) MarshalJSON ¶
func (*UnixTime) UnmarshalJSON ¶
type VerifyEmailRequest ¶
VerifyEmailRequest is the body for POST /v1/auth/login/email/verify.
type VersionsResponse ¶ added in v0.6.53
type VersionsResponse struct {
Latest string `json:"latest"`
OldestSupportedVersion string `json:"oldestSupportedVersion"`
Versions []string `json:"versions"`
IncludePreReleases bool `json:"includePreReleases"`
}
VersionsResponse mirrors the /runtime/versions response data.