Documentation
¶
Overview ¶
Package api provides the HTTP API surface of the takt server.
The routes, request decoding and response marshalling are generated from api/openapi.yaml. This package implements the generated interface. The middleware the server wraps around it lives in the middleware package.
Index ¶
- type ACLAPI
- func (a *ACLAPI) ApplyACLPolicy(ctx context.Context, request api.ApplyACLPolicyRequestObject) (api.ApplyACLPolicyResponseObject, error)
- func (a *ACLAPI) GetACLPolicy(ctx context.Context, _ api.GetACLPolicyRequestObject) (api.GetACLPolicyResponseObject, error)
- func (a *ACLAPI) InitACL(ctx context.Context, _ api.InitACLRequestObject) (api.InitACLResponseObject, error)
- type ACLAPIConfig
- type ACLInitializer
- type API
- type Admin
- type AdminAPI
- type AdminAPIConfig
- type AuthAPI
- func (a *AuthAPI) GetAuth(ctx context.Context, _ api.GetAuthRequestObject) (api.GetAuthResponseObject, error)
- func (a *AuthAPI) GetOIDC(_ context.Context, _ api.GetOIDCRequestObject) (api.GetOIDCResponseObject, error)
- func (a *AuthAPI) Login(ctx context.Context, request api.LoginRequestObject) (api.LoginResponseObject, error)
- func (a *AuthAPI) Logout(ctx context.Context, _ api.LogoutRequestObject) (api.LogoutResponseObject, error)
- func (a *AuthAPI) OidcCallback(ctx context.Context, request api.OidcCallbackRequestObject) (api.OidcCallbackResponseObject, error)
- func (a *AuthAPI) OidcLogin(_ context.Context, _ api.OidcLoginRequestObject) (api.OidcLoginResponseObject, error)
- type AuthAPIConfig
- type AuthService
- type Config
- type ErrorResponse
- type NodeAPI
- type NodeAPIConfig
- type NodeService
- type OIDCRelyingParty
- type Observer
- type Pinger
- type PolicyService
- type ScrapeTargeter
- type SecretAPI
- func (a *SecretAPI) DeleteSecret(ctx context.Context, request api.DeleteSecretRequestObject) (api.DeleteSecretResponseObject, error)
- func (a *SecretAPI) GetSecret(ctx context.Context, request api.GetSecretRequestObject) (api.GetSecretResponseObject, error)
- func (a *SecretAPI) ListSecrets(ctx context.Context, request api.ListSecretsRequestObject) (api.ListSecretsResponseObject, error)
- func (a *SecretAPI) SetSecret(ctx context.Context, request api.SetSecretRequestObject) (api.SetSecretResponseObject, error)
- type SecretAPIConfig
- type SecretService
- type ServiceAPI
- func (a *ServiceAPI) ApplyService(ctx context.Context, request api.ApplyServiceRequestObject) (api.ApplyServiceResponseObject, error)
- func (a *ServiceAPI) DeleteService(ctx context.Context, request api.DeleteServiceRequestObject) (api.DeleteServiceResponseObject, error)
- func (a *ServiceAPI) GetService(ctx context.Context, request api.GetServiceRequestObject) (api.GetServiceResponseObject, error)
- func (a *ServiceAPI) ListServices(ctx context.Context, request api.ListServicesRequestObject) (api.ListServicesResponseObject, error)
- type ServiceAPIConfig
- type ServiceService
- type SystemAPI
- func (a *SystemAPI) GetHealth(_ context.Context, _ api.GetHealthRequestObject) (api.GetHealthResponseObject, error)
- func (a *SystemAPI) GetMetrics(_ context.Context, _ api.GetMetricsRequestObject) (api.GetMetricsResponseObject, error)
- func (a *SystemAPI) GetPrometheusTargets(ctx context.Context, _ api.GetPrometheusTargetsRequestObject) (api.GetPrometheusTargetsResponseObject, error)
- func (a *SystemAPI) GetReadiness(ctx context.Context, _ api.GetReadinessRequestObject) (api.GetReadinessResponseObject, error)
- type SystemAPIConfig
- type TokenAPI
- func (a *TokenAPI) CreateToken(ctx context.Context, request api.CreateTokenRequestObject) (api.CreateTokenResponseObject, error)
- func (a *TokenAPI) DeleteToken(ctx context.Context, request api.DeleteTokenRequestObject) (api.DeleteTokenResponseObject, error)
- func (a *TokenAPI) ListTokens(ctx context.Context, _ api.ListTokensRequestObject) (api.ListTokensResponseObject, error)
- type TokenAPIConfig
- type TokenService
- type VariableAPI
- func (a *VariableAPI) DeleteVariable(ctx context.Context, request api.DeleteVariableRequestObject) (api.DeleteVariableResponseObject, error)
- func (a *VariableAPI) GetVariable(ctx context.Context, request api.GetVariableRequestObject) (api.GetVariableResponseObject, error)
- func (a *VariableAPI) ListVariables(ctx context.Context, request api.ListVariablesRequestObject) (api.ListVariablesResponseObject, error)
- func (a *VariableAPI) SetVariable(ctx context.Context, request api.SetVariableRequestObject) (api.SetVariableResponseObject, error)
- type VariableAPIConfig
- type VariableService
- type VolumeAPI
- func (a *VolumeAPI) ApplyVolume(ctx context.Context, request api.ApplyVolumeRequestObject) (api.ApplyVolumeResponseObject, error)
- func (a *VolumeAPI) DeleteVolume(ctx context.Context, request api.DeleteVolumeRequestObject) (api.DeleteVolumeResponseObject, error)
- func (a *VolumeAPI) GetVolume(ctx context.Context, request api.GetVolumeRequestObject) (api.GetVolumeResponseObject, error)
- func (a *VolumeAPI) ListVolumes(ctx context.Context, request api.ListVolumesRequestObject) (api.ListVolumesResponseObject, error)
- type VolumeAPIConfig
- type VolumeService
- type WorkloadAPI
- func (a *WorkloadAPI) ApplyWorkload(ctx context.Context, request api.ApplyWorkloadRequestObject) (api.ApplyWorkloadResponseObject, error)
- func (a *WorkloadAPI) DeleteWorkload(ctx context.Context, request api.DeleteWorkloadRequestObject) (api.DeleteWorkloadResponseObject, error)
- func (a *WorkloadAPI) DryRunWorkload(ctx context.Context, request api.DryRunWorkloadRequestObject) (api.DryRunWorkloadResponseObject, error)
- func (a *WorkloadAPI) GetWorkload(ctx context.Context, request api.GetWorkloadRequestObject) (api.GetWorkloadResponseObject, error)
- func (a *WorkloadAPI) GetWorkloadEvents(ctx context.Context, request api.GetWorkloadEventsRequestObject) (api.GetWorkloadEventsResponseObject, error)
- func (a *WorkloadAPI) GetWorkloadLogs(ctx context.Context, request api.GetWorkloadLogsRequestObject) (api.GetWorkloadLogsResponseObject, error)
- func (a *WorkloadAPI) ListWorkloads(ctx context.Context, request api.ListWorkloadsRequestObject) (api.ListWorkloadsResponseObject, error)
- func (a *WorkloadAPI) RestartWorkload(ctx context.Context, request api.RestartWorkloadRequestObject) (api.RestartWorkloadResponseObject, error)
- func (a *WorkloadAPI) StartWorkload(ctx context.Context, request api.StartWorkloadRequestObject) (api.StartWorkloadResponseObject, error)
- func (a *WorkloadAPI) StopWorkload(ctx context.Context, request api.StopWorkloadRequestObject) (api.StopWorkloadResponseObject, error)
- type WorkloadAPIConfig
- type WorkloadService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACLAPI ¶ added in v0.5.0
type ACLAPI struct {
// contains filtered or unexported fields
}
The ACLAPI type exposes HTTP endpoints for the policy document and its one-shot init.
func NewACLAPI ¶ added in v0.5.0
func NewACLAPI(config ACLAPIConfig) *ACLAPI
NewACLAPI returns a new instance of the ACLAPI type.
func (*ACLAPI) ApplyACLPolicy ¶ added in v0.5.0
func (a *ACLAPI) ApplyACLPolicy(ctx context.Context, request api.ApplyACLPolicyRequestObject) (api.ApplyACLPolicyResponseObject, error)
ApplyACLPolicy replaces the policy document, on the condition the caller read the one it is replacing.
func (*ACLAPI) GetACLPolicy ¶ added in v0.5.0
func (a *ACLAPI) GetACLPolicy(ctx context.Context, _ api.GetACLPolicyRequestObject) (api.GetACLPolicyResponseObject, error)
GetACLPolicy returns the current policy document and its tag.
func (*ACLAPI) InitACL ¶ added in v0.5.0
func (a *ACLAPI) InitACL(ctx context.Context, _ api.InitACLRequestObject) (api.InitACLResponseObject, error)
InitACL mints the recovery token, exactly once.
type ACLAPIConfig ¶ added in v0.5.0
type ACLAPIConfig struct {
// The logger used to record failures the response deliberately
// doesn't describe.
Logger *slog.Logger
// The service owning the policy document.
Policies PolicyService
// The service minting the recovery token.
Init ACLInitializer
}
The ACLAPIConfig type contains fields used to construct an ACLAPI.
type ACLInitializer ¶ added in v0.5.0
type ACLInitializer interface {
// Init should mint the recovery token, exactly once.
Init(ctx context.Context) (string, error)
}
The ACLInitializer interface describes how the API mints the recovery token.
type API ¶
type API struct {
*WorkloadAPI
*VolumeAPI
*ServiceAPI
*SecretAPI
*VariableAPI
*NodeAPI
*SystemAPI
*AdminAPI
*AuthAPI
*ACLAPI
*TokenAPI
// contains filtered or unexported fields
}
The API type is the whole HTTP surface, assembled from the types serving each resource.
The wire format describes one API, so the generated code describes one interface covering every operation in it. Each resource still gets a type of its own, holding only the service it needs, and embedding them here is what makes the set of them satisfy that interface. None of them has to know the others exist.
func (*API) Register ¶
Register the HTTP endpoints onto the given http.ServeMux.
The routes themselves come from the generated handler, which is mounted onto the caller's mux rather than one of its own so that the server keeps ownership of routing and can wrap the whole surface in its own middleware.
The generated code answers a request it cannot decode, and a response it cannot write, with a plain-text body of its own. Both are routed through the API's own error shape instead, so a client decodes every failure the same way.
type Admin ¶
type Admin interface {
// PrepareBackup should take a snapshot of the state a backup covers. The
// returned backup should be closed by the caller.
PrepareBackup(ctx context.Context, options service.BackupOptions) (*service.Backup, error)
// Rekey should re-encrypt every secret under a newly generated key.
Rekey(ctx context.Context) (service.Rekey, error)
}
The Admin interface describes the operations the admin endpoints run against the node itself.
type AdminAPI ¶
type AdminAPI struct {
// contains filtered or unexported fields
}
The AdminAPI type exposes the HTTP endpoints acting on the node itself rather than on the workloads running on it.
func NewAdminAPI ¶
func NewAdminAPI(config AdminAPIConfig) *AdminAPI
NewAdminAPI returns a new instance of the AdminAPI type.
func (*AdminAPI) GetBackup ¶
func (a *AdminAPI) GetBackup(ctx context.Context, request api.GetBackupRequestObject) (api.GetBackupResponseObject, error)
GetBackup returns a zip archive holding a consistent snapshot of the database, and the keyring when the request asks for it.
func (*AdminAPI) Rekey ¶
func (a *AdminAPI) Rekey(ctx context.Context, _ api.RekeyRequestObject) (api.RekeyResponseObject, error)
Rekey re-encrypts every secret under a newly generated key and reports what moved.
type AdminAPIConfig ¶
type AdminAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the operations the endpoints expose.
Admin Admin
}
The AdminAPIConfig type contains fields used to construct an AdminAPI.
type AuthAPI ¶ added in v0.5.0
type AuthAPI struct {
// contains filtered or unexported fields
}
The AuthAPI type exposes HTTP endpoints for the caller's own authentication.
func NewAuthAPI ¶ added in v0.5.0
func NewAuthAPI(config AuthAPIConfig) *AuthAPI
NewAuthAPI returns a new instance of the AuthAPI type.
func (*AuthAPI) GetAuth ¶ added in v0.5.0
func (a *AuthAPI) GetAuth(ctx context.Context, _ api.GetAuthRequestObject) (api.GetAuthResponseObject, error)
GetAuth reports who the caller is.
func (*AuthAPI) GetOIDC ¶ added in v0.5.0
func (a *AuthAPI) GetOIDC(_ context.Context, _ api.GetOIDCRequestObject) (api.GetOIDCResponseObject, error)
GetOIDC reports how to log in with OIDC.
func (*AuthAPI) Login ¶ added in v0.5.0
func (a *AuthAPI) Login(ctx context.Context, request api.LoginRequestObject) (api.LoginResponseObject, error)
Login exchanges an identity for a short-lived client token.
func (*AuthAPI) Logout ¶ added in v0.5.0
func (a *AuthAPI) Logout(ctx context.Context, _ api.LogoutRequestObject) (api.LogoutResponseObject, error)
Logout revokes the credential that authenticated this request.
func (*AuthAPI) OidcCallback ¶ added in v0.5.0
func (a *AuthAPI) OidcCallback(ctx context.Context, request api.OidcCallbackRequestObject) (api.OidcCallbackResponseObject, error)
OidcCallback completes the browser OIDC flow.
func (*AuthAPI) OidcLogin ¶ added in v0.5.0
func (a *AuthAPI) OidcLogin(_ context.Context, _ api.OidcLoginRequestObject) (api.OidcLoginResponseObject, error)
OidcLogin starts the browser OIDC flow.
type AuthAPIConfig ¶ added in v0.5.0
type AuthAPIConfig struct {
// The logger used to record failures the response deliberately
// doesn't describe.
Logger *slog.Logger
// The service performing the authentication operations.
Auth AuthService
// The OIDC configuration the browser flow and discovery answer
// from. May be nil, in which case the OIDC routes answer 404 and a
// pasted token is the only way in.
OIDC *OIDCRelyingParty
// Whether cookies are marked Secure, which follows whether the
// server terminates TLS itself.
Secure bool
}
The AuthAPIConfig type contains fields used to construct an AuthAPI.
type AuthService ¶ added in v0.5.0
type AuthService interface {
// LoginOIDC should exchange a verified OIDC identity for a
// short-lived client token. The browser flow's callback calls it
// with the identity token the server's own code exchange earned.
LoginOIDC(ctx context.Context, rawIDToken string) (service.Token, string, error)
// LoginToken should exchange an existing client token for a
// short-lived session token bound to the same principal.
LoginToken(ctx context.Context, credential string) (service.Token, string, error)
// LoginCode should trade an authorization code from the CLI's
// loopback flow for a short-lived client token, exchanging it with
// the issuer server-side.
LoginCode(ctx context.Context, code, verifier, redirectURI string) (service.Token, string, error)
// Logout should revoke the credential behind the given identity.
Logout(ctx context.Context, identity auth.Identity) error
}
The AuthService interface describes the authentication operations the API exposes.
type Config ¶
type Config struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The endpoints serving workloads.
Workloads *WorkloadAPI
// The endpoints serving volumes.
Volumes *VolumeAPI
// The endpoints serving services.
Services *ServiceAPI
// The endpoints serving secrets.
Secrets *SecretAPI
// The endpoints serving variables.
Variables *VariableAPI
// The endpoints describing the node the server runs on.
Node *NodeAPI
// The endpoints describing the server itself.
System *SystemAPI
// The endpoints acting on the node itself.
Admin *AdminAPI
// The endpoints serving the caller's own authentication.
Auth *AuthAPI
// The endpoints serving the policy document.
ACL *ACLAPI
// The endpoints managing tokens.
Tokens *TokenAPI
}
The Config type contains fields used to construct an API.
type ErrorResponse ¶
type ErrorResponse struct {
// The HTTP status code. It is set when writing the response and not sent on
// the wire.
Status int `json:"-"`
// The human-readable error message.
Message string `json:"error"`
}
The ErrorResponse type is the JSON shape returned for error responses, and implements the error interface so that clients can return it directly.
type NodeAPI ¶ added in v0.8.0
type NodeAPI struct {
// contains filtered or unexported fields
}
The NodeAPI type exposes HTTP endpoints describing the node.
func NewNodeAPI ¶ added in v0.8.0
func NewNodeAPI(config NodeAPIConfig) *NodeAPI
NewNodeAPI returns a new instance of the NodeAPI type.
func (*NodeAPI) GetNode ¶ added in v0.8.0
func (a *NodeAPI) GetNode(ctx context.Context, _ api.GetNodeRequestObject) (api.GetNodeResponseObject, error)
GetNode returns the machine the server runs on.
type NodeAPIConfig ¶ added in v0.8.0
type NodeAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service reading the node.
Node NodeService
}
The NodeAPIConfig type contains fields used to construct a NodeAPI.
type NodeService ¶ added in v0.8.0
type NodeService interface {
// Get should report the node as it stands now.
Get(ctx context.Context) (service.Node, error)
}
The NodeService interface describes how the API reads the machine the server runs on.
type OIDCRelyingParty ¶ added in v0.5.0
type OIDCRelyingParty struct {
// The issuer the authorization code flow runs against.
Issuer string
// The client identifier registered with the issuer.
ClientID string
// The authorization code flow the login redirect starts and the
// callback completes. Nil disables the browser flow while the CLI's
// own loopback flow keeps working.
Flow *oauth2.Config
}
The OIDCRelyingParty type carries what the browser OIDC flow runs against. The discovery endpoint needs only the issuer and client identifier. The redirect flow additionally needs Flow, which is absent when the configuration names no redirect URL.
type Observer ¶
type Observer interface {
// Observations should report how the most recent attempt to observe
// each driver ended, keyed by runtime name.
Observations() map[string]reconciler.Observation
}
The Observer interface describes how the readiness endpoint reads the reconciler's cached view of each driver.
type Pinger ¶
type Pinger interface {
// PingContext should report an error when the database cannot be
// reached.
PingContext(ctx context.Context) error
}
The Pinger interface describes how the readiness endpoint asks whether the database is reachable.
type PolicyService ¶ added in v0.5.0
type PolicyService interface {
// Get should return the current policy, at version zero before any
// apply.
Get(ctx context.Context) (service.Policy, error)
// Apply should validate the document and replace the current one with
// it, on the condition that ifMatch is the version of the document
// being replaced, recording the actor as who changed it.
Apply(ctx context.Context, actor auth.Identity, policy manifest.Policy, ifMatch int) (service.Policy, error)
}
The PolicyService interface describes the policy operations the API exposes.
type ScrapeTargeter ¶ added in v0.4.0
type ScrapeTargeter interface {
// ScrapeTargets should report the workloads that opted into scraping
// as http_sd target groups, ordered by workload name.
ScrapeTargets(ctx context.Context) ([]service.ScrapeTarget, error)
}
The ScrapeTargeter interface describes how the discovery endpoint learns which workloads prometheus should scrape.
type SecretAPI ¶
type SecretAPI struct {
// contains filtered or unexported fields
}
The SecretAPI type exposes HTTP endpoints for managing secrets.
func NewSecretAPI ¶
func NewSecretAPI(config SecretAPIConfig) *SecretAPI
NewSecretAPI returns a new instance of the SecretAPI type.
func (*SecretAPI) DeleteSecret ¶
func (a *SecretAPI) DeleteSecret(ctx context.Context, request api.DeleteSecretRequestObject) (api.DeleteSecretResponseObject, error)
DeleteSecret removes the secret with the given name.
The response is 200 rather than 202, unlike deleting a workload: there is nothing running to wind down, so the secret is gone when the request returns.
func (*SecretAPI) GetSecret ¶
func (a *SecretAPI) GetSecret(ctx context.Context, request api.GetSecretRequestObject) (api.GetSecretResponseObject, error)
GetSecret returns the secret with the given name, without its value.
func (*SecretAPI) ListSecrets ¶
func (a *SecretAPI) ListSecrets(ctx context.Context, request api.ListSecretsRequestObject) (api.ListSecretsResponseObject, error)
ListSecrets returns the secrets matching the request's queries, or every secret when it carries none, without their values.
func (*SecretAPI) SetSecret ¶
func (a *SecretAPI) SetSecret(ctx context.Context, request api.SetSecretRequestObject) (api.SetSecretResponseObject, error)
SetSecret stores the given value as the named secret.
type SecretAPIConfig ¶
type SecretAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the secret operations.
Secrets SecretService
}
The SecretAPIConfig type contains fields used to construct a SecretAPI.
type SecretService ¶
type SecretService interface {
// Set should store the given secret, reporting whether it was newly
// created. A non-zero ifMatch should condition the set on the secret still
// being at that version.
Set(ctx context.Context, secret manifest.Secret, ifMatch int) (service.Secret, bool, error)
// Get should return the secret with the given name, without its value.
Get(ctx context.Context, name string) (service.Secret, error)
// List should return the secrets matching every one of the given
// "path=value" queries, or every secret the server holds when given none,
// without their values.
List(ctx context.Context, queries ...string) ([]service.Secret, error)
// Delete should remove the secret with the given name, refusing one a workload
// reads unless force is set.
Delete(ctx context.Context, name string, force bool) error
}
The SecretService interface describes the secret operations the API exposes.
There is nothing here that reads a value. The service can decrypt one, but only to hand it to a workload that is starting, so the API is given an interface that cannot ask.
type ServiceAPI ¶
type ServiceAPI struct {
// contains filtered or unexported fields
}
The ServiceAPI type exposes HTTP endpoints for managing services.
func NewServiceAPI ¶
func NewServiceAPI(config ServiceAPIConfig) *ServiceAPI
NewServiceAPI returns a new instance of the ServiceAPI type.
func (*ServiceAPI) ApplyService ¶
func (a *ServiceAPI) ApplyService(ctx context.Context, request api.ApplyServiceRequestObject) (api.ApplyServiceResponseObject, error)
ApplyService records the submitted specification as the desired state for the named service.
func (*ServiceAPI) DeleteService ¶
func (a *ServiceAPI) DeleteService(ctx context.Context, request api.DeleteServiceRequestObject) (api.DeleteServiceResponseObject, error)
DeleteService removes the service with the given name.
The response is 200 rather than 202, unlike deleting a workload: the workloads the service selected are their own resources and keep running, so there is nothing to wind down.
func (*ServiceAPI) GetService ¶
func (a *ServiceAPI) GetService(ctx context.Context, request api.GetServiceRequestObject) (api.GetServiceResponseObject, error)
GetService returns the service with the given name.
func (*ServiceAPI) ListServices ¶
func (a *ServiceAPI) ListServices(ctx context.Context, request api.ListServicesRequestObject) (api.ListServicesResponseObject, error)
ListServices returns the services matching the request's queries, or every service when it carries none. A followed list keeps the response open and writes the set again each time it changes.
type ServiceAPIConfig ¶
type ServiceAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the service operations.
Services ServiceService
}
The ServiceAPIConfig type contains fields used to construct a ServiceAPI.
type ServiceService ¶
type ServiceService interface {
// Apply should record the service a manifest describes, replacing what a
// service already holding the name says, and report whether it created
// the service.
// A non-zero ifMatch should condition the apply on the service still
// being at that version.
Apply(ctx context.Context, spec manifest.Service, ifMatch int) (service.Service, bool, error)
// Get should return the service with the given name with its backends
// resolved.
Get(ctx context.Context, name string) (service.Service, error)
// List should return the services matching every one of the given
// "path=value" queries, or every service the server holds when given
// none.
List(ctx context.Context, queries ...string) ([]service.Service, error)
// Stream should call fn with the services matching every one of the
// given queries at once, and again each time the set changes, until ctx
// ends or fn returns an error.
Stream(ctx context.Context, fn func([]service.Service) error, queries ...string) error
// Delete should remove the service with the given name.
Delete(ctx context.Context, name string) error
}
The ServiceService interface describes the service operations the API exposes.
type SystemAPI ¶
type SystemAPI struct {
// contains filtered or unexported fields
}
The SystemAPI type exposes HTTP endpoints describing the server itself: liveness, readiness, metrics, and the scrape targets it discovers for prometheus.
func NewSystemAPI ¶
func NewSystemAPI(config SystemAPIConfig) *SystemAPI
NewSystemAPI returns a new instance of the SystemAPI type.
func (*SystemAPI) GetHealth ¶
func (a *SystemAPI) GetHealth(_ context.Context, _ api.GetHealthRequestObject) (api.GetHealthResponseObject, error)
GetHealth reports that the server is alive. Handling the request is the answer, so there is nothing to check.
func (*SystemAPI) GetMetrics ¶
func (a *SystemAPI) GetMetrics(_ context.Context, _ api.GetMetricsRequestObject) (api.GetMetricsResponseObject, error)
GetMetrics returns everything the server's meters record, in the Prometheus text format.
Gathering happens before the first byte is written, so a failure is a 500 rather than a truncated 200 nothing can retract.
func (*SystemAPI) GetPrometheusTargets ¶ added in v0.4.0
func (a *SystemAPI) GetPrometheusTargets(ctx context.Context, _ api.GetPrometheusTargetsRequestObject) (api.GetPrometheusTargetsResponseObject, error)
GetPrometheusTargets reports the workloads that opted into scraping as target groups in the shape prometheus's http_sd_configs reads.
func (*SystemAPI) GetReadiness ¶
func (a *SystemAPI) GetReadiness(ctx context.Context, _ api.GetReadinessRequestObject) (api.GetReadinessResponseObject, error)
GetReadiness reports whether the server can do its job: the database answers, and every configured driver answered the most recent attempt to observe it.
The reasons name what is not answering and no more. The route is anonymous, and the errors behind it carry the paths of the database and of the daemon's socket. The database error is logged here, where it has a reader. A driver's is already in the log from the pass that recorded it.
type SystemAPIConfig ¶
type SystemAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The database the readiness endpoint pings.
DB Pinger
// Reports the reconciler's cached view of each driver.
Observer Observer
// The gatherer the metrics endpoint reads from.
Metrics prometheus.Gatherer
// Reports the workloads prometheus should scrape.
Targets ScrapeTargeter
}
The SystemAPIConfig type contains fields used to construct a SystemAPI.
type TokenAPI ¶ added in v0.5.0
type TokenAPI struct {
// contains filtered or unexported fields
}
The TokenAPI type exposes HTTP endpoints for managing tokens.
func NewTokenAPI ¶ added in v0.5.0
func NewTokenAPI(config TokenAPIConfig) *TokenAPI
NewTokenAPI returns a new instance of the TokenAPI type.
func (*TokenAPI) CreateToken ¶ added in v0.5.0
func (a *TokenAPI) CreateToken(ctx context.Context, request api.CreateTokenRequestObject) (api.CreateTokenResponseObject, error)
CreateToken mints a client token bound to a principal.
func (*TokenAPI) DeleteToken ¶ added in v0.5.0
func (a *TokenAPI) DeleteToken(ctx context.Context, request api.DeleteTokenRequestObject) (api.DeleteTokenResponseObject, error)
DeleteToken revokes the token with the given identifier.
func (*TokenAPI) ListTokens ¶ added in v0.5.0
func (a *TokenAPI) ListTokens(ctx context.Context, _ api.ListTokensRequestObject) (api.ListTokensResponseObject, error)
ListTokens names every credential the server holds.
type TokenAPIConfig ¶ added in v0.5.0
type TokenAPIConfig struct {
// The logger used to record failures the response deliberately
// doesn't describe.
Logger *slog.Logger
// The service performing the token operations.
Tokens TokenService
}
The TokenAPIConfig type contains fields used to construct a TokenAPI.
type TokenService ¶ added in v0.5.0
type TokenService interface {
// Create should mint a client token bound to the given principal,
// returning the stored token and the credential itself, recording the
// actor as who minted it.
Create(ctx context.Context, actor auth.Identity, principal string) (service.Token, string, error)
// List should return every token, newest first.
List(ctx context.Context) ([]service.Token, error)
// Delete should revoke the token with the given identifier, recording
// the actor as who revoked it.
Delete(ctx context.Context, actor auth.Identity, id string) error
}
The TokenService interface describes the token operations the API exposes.
type VariableAPI ¶
type VariableAPI struct {
// contains filtered or unexported fields
}
The VariableAPI type exposes HTTP endpoints for managing variables.
func NewVariableAPI ¶
func NewVariableAPI(config VariableAPIConfig) *VariableAPI
NewVariableAPI returns a new instance of the VariableAPI type.
func (*VariableAPI) DeleteVariable ¶
func (a *VariableAPI) DeleteVariable(ctx context.Context, request api.DeleteVariableRequestObject) (api.DeleteVariableResponseObject, error)
DeleteVariable removes the variable with the given name.
The response is 200 rather than 202, unlike deleting a workload: there is nothing running to wind down, so the variable is gone when the request returns.
func (*VariableAPI) GetVariable ¶
func (a *VariableAPI) GetVariable(ctx context.Context, request api.GetVariableRequestObject) (api.GetVariableResponseObject, error)
GetVariable returns the variable with the given name.
func (*VariableAPI) ListVariables ¶
func (a *VariableAPI) ListVariables(ctx context.Context, request api.ListVariablesRequestObject) (api.ListVariablesResponseObject, error)
ListVariables returns the variables matching the request's queries, or every variable when it carries none.
func (*VariableAPI) SetVariable ¶
func (a *VariableAPI) SetVariable(ctx context.Context, request api.SetVariableRequestObject) (api.SetVariableResponseObject, error)
SetVariable stores the given value as the named variable.
type VariableAPIConfig ¶
type VariableAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the variable operations.
Variables VariableService
}
The VariableAPIConfig type contains fields used to construct a VariableAPI.
type VariableService ¶
type VariableService interface {
// Set should store the given variable, reporting whether it was newly
// created. A non-zero ifMatch should condition the set on the variable
// still being at that version.
Set(ctx context.Context, variable manifest.Variable, ifMatch int) (service.Variable, bool, error)
// Get should return the variable with the given name.
Get(ctx context.Context, name string) (service.Variable, error)
// List should return the variables matching every one of the given
// "path=value" queries, or every variable the server holds when given
// none.
List(ctx context.Context, queries ...string) ([]service.Variable, error)
// Delete should remove the variable with the given name, refusing one a
// workload reads unless force is set.
Delete(ctx context.Context, name string, force bool) error
}
The VariableService interface describes the variable operations the API exposes.
type VolumeAPI ¶
type VolumeAPI struct {
// contains filtered or unexported fields
}
The VolumeAPI type exposes HTTP endpoints for managing volumes.
func NewVolumeAPI ¶
func NewVolumeAPI(config VolumeAPIConfig) *VolumeAPI
NewVolumeAPI returns a new instance of the VolumeAPI type.
func (*VolumeAPI) ApplyVolume ¶ added in v0.3.0
func (a *VolumeAPI) ApplyVolume(ctx context.Context, request api.ApplyVolumeRequestObject) (api.ApplyVolumeResponseObject, error)
ApplyVolume stores the volume the request describes, creating it when the name is new and updating it when it is not, answering 201 or 200 to report which happened.
func (*VolumeAPI) DeleteVolume ¶
func (a *VolumeAPI) DeleteVolume(ctx context.Context, request api.DeleteVolumeRequestObject) (api.DeleteVolumeResponseObject, error)
DeleteVolume removes the volume with the given name and everything stored in it.
The response is 200 rather than 202, unlike deleting a workload: there is nothing running to wind down, only a directory to remove, so the volume is gone when the request returns.
func (*VolumeAPI) GetVolume ¶
func (a *VolumeAPI) GetVolume(ctx context.Context, request api.GetVolumeRequestObject) (api.GetVolumeResponseObject, error)
GetVolume returns the volume with the given name.
func (*VolumeAPI) ListVolumes ¶
func (a *VolumeAPI) ListVolumes(ctx context.Context, request api.ListVolumesRequestObject) (api.ListVolumesResponseObject, error)
ListVolumes returns the volumes matching the request's queries, or every volume when it carries none.
type VolumeAPIConfig ¶
type VolumeAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the volume operations.
Volumes VolumeService
}
The VolumeAPIConfig type contains fields used to construct a VolumeAPI.
type VolumeService ¶
type VolumeService interface {
// Apply should store the given volume, creating it and the directory
// backing it when the name is new, and replacing its labels, owner and
// mode when it is not, reporting which happened. The owner and mode
// should be reapplied to the directory either way.
// A non-zero ifMatch should condition the apply on the volume still
// being at that version.
Apply(ctx context.Context, volume manifest.Volume, ifMatch int) (service.Volume, bool, error)
// Get should return the volume with the given name.
Get(ctx context.Context, name string) (service.Volume, error)
// List should return the volumes matching every one of the given
// "path=value" queries, or every volume the server holds when given none.
List(ctx context.Context, queries ...string) ([]service.Volume, error)
// Delete should remove the volume with the given name and everything stored
// in it, refusing a volume a workload mounts unless force is set.
Delete(ctx context.Context, name string, force bool) error
}
The VolumeService interface describes the volume operations the API exposes.
type WorkloadAPI ¶
type WorkloadAPI struct {
// contains filtered or unexported fields
}
The WorkloadAPI type exposes HTTP endpoints for managing workloads.
func NewWorkloadAPI ¶
func NewWorkloadAPI(config WorkloadAPIConfig) *WorkloadAPI
NewWorkloadAPI returns a new instance of the WorkloadAPI type.
func (*WorkloadAPI) ApplyWorkload ¶
func (a *WorkloadAPI) ApplyWorkload(ctx context.Context, request api.ApplyWorkloadRequestObject) (api.ApplyWorkloadResponseObject, error)
ApplyWorkload stores the given specification as the desired state for the named workload.
func (*WorkloadAPI) DeleteWorkload ¶
func (a *WorkloadAPI) DeleteWorkload(ctx context.Context, request api.DeleteWorkloadRequestObject) (api.DeleteWorkloadResponseObject, error)
DeleteWorkload marks the workload with the given name for deletion.
The response is 202 rather than 204 because the workload is not gone when the request returns: it is reported as terminating until the driver's work for it has actually stopped, at which point it disappears.
func (*WorkloadAPI) DryRunWorkload ¶
func (a *WorkloadAPI) DryRunWorkload(ctx context.Context, request api.DryRunWorkloadRequestObject) (api.DryRunWorkloadResponseObject, error)
DryRunWorkload reports what applying the given specification would do, and applies nothing.
func (*WorkloadAPI) GetWorkload ¶
func (a *WorkloadAPI) GetWorkload(ctx context.Context, request api.GetWorkloadRequestObject) (api.GetWorkloadResponseObject, error)
GetWorkload returns the workload with the given name.
func (*WorkloadAPI) GetWorkloadEvents ¶ added in v0.7.0
func (a *WorkloadAPI) GetWorkloadEvents(ctx context.Context, request api.GetWorkloadEventsRequestObject) (api.GetWorkloadEventsResponseObject, error)
GetWorkloadEvents returns what the server recorded about the named workload.
func (*WorkloadAPI) GetWorkloadLogs ¶
func (a *WorkloadAPI) GetWorkloadLogs(ctx context.Context, request api.GetWorkloadLogsRequestObject) (api.GetWorkloadLogsResponseObject, error)
GetWorkloadLogs returns the recent output of the named workload.
func (*WorkloadAPI) ListWorkloads ¶
func (a *WorkloadAPI) ListWorkloads(ctx context.Context, request api.ListWorkloadsRequestObject) (api.ListWorkloadsResponseObject, error)
ListWorkloads returns the workloads matching the request's queries, or every workload when it carries none.
func (*WorkloadAPI) RestartWorkload ¶
func (a *WorkloadAPI) RestartWorkload(ctx context.Context, request api.RestartWorkloadRequestObject) (api.RestartWorkloadResponseObject, error)
RestartWorkload asks for the named workload's instances to be replaced.
The response is 202 like StopWorkload's: the request is only recorded when it returns, and the next reconcile pass performs the replacement.
func (*WorkloadAPI) StartWorkload ¶
func (a *WorkloadAPI) StartWorkload(ctx context.Context, request api.StartWorkloadRequestObject) (api.StartWorkloadResponseObject, error)
StartWorkload clears the suspension of the workload with the given name.
The response is 202 like StopWorkload's: the mark is cleared when the request returns, and the next reconcile pass starts the workload's instances.
func (*WorkloadAPI) StopWorkload ¶
func (a *WorkloadAPI) StopWorkload(ctx context.Context, request api.StopWorkloadRequestObject) (api.StopWorkloadResponseObject, error)
StopWorkload marks the workload with the given name as suspended.
The response is 202 for the same reason DeleteWorkload's is: the workload is only marked when the request returns, and the reconciler stops its work afterwards. A caller can watch the instances drain by polling the workload.
type WorkloadAPIConfig ¶
type WorkloadAPIConfig struct {
// The logger used to record failures the response deliberately doesn't
// describe.
Logger *slog.Logger
// The service performing the workload operations.
Workloads WorkloadService
}
The WorkloadAPIConfig type contains fields used to construct a WorkloadAPI.
type WorkloadService ¶
type WorkloadService interface {
// Apply should store the given specification as desired state, reporting
// whether the workload was newly created.
// A non-zero ifMatch should condition the apply on the workload still
// being at that version.
Apply(ctx context.Context, spec manifest.Spec, ifMatch int) (service.Workload, bool, error)
// DryRun should report what applying the given specification would do,
// without applying it.
DryRun(ctx context.Context, spec manifest.Spec) (service.DryRun, error)
// Get should return the workload with the given name.
Get(ctx context.Context, name string) (service.Workload, error)
// Events should return what the server recorded about the named workload,
// most recently seen first, up to limit of them. A non-zero since should
// drop the events last seen at or before it.
Events(ctx context.Context, name string, since time.Time, limit int) ([]service.Event, error)
// List should return the workloads matching every one of the given queries,
// or all of them when none are given.
List(ctx context.Context, queries ...string) ([]service.Workload, error)
// Delete should mark the workload with the given name for deletion,
// returning it as it now stands.
Delete(ctx context.Context, name string, force bool) (service.Workload, error)
// Stop should mark the workload with the given name as suspended,
// returning it as it now stands.
Stop(ctx context.Context, name string) (service.Workload, error)
// Start should clear the suspension of the workload with the given name,
// returning it as it now stands.
Start(ctx context.Context, name string) (service.Workload, error)
// Restart should ask for the workload's instances to be replaced,
// returning the workload as it now stands.
Restart(ctx context.Context, name string) (service.Workload, error)
// Logs should write the recent output of the named workload to out, as the
// options describe.
Logs(ctx context.Context, out io.Writer, name string, options driver.LogOptions) error
}
The WorkloadService interface describes the workload operations the API exposes.