Documentation ¶
Index ¶
- Variables
- func LogsNotifyChannel(agentID uuid.UUID) string
- func LogsSender(sourceID uuid.UUID, patchLogs func(ctx context.Context, req PatchLogs) error, ...) (sendLog func(ctx context.Context, log ...Log) error, ...)
- func LogsSenderFlushTimeout(timeout time.Duration) func(*logsSenderOptions)
- func LogsWriter(ctx context.Context, sender func(ctx context.Context, log ...Log) error, ...) io.WriteCloser
- type AWSInstanceIdentityToken
- type AgentMetric
- type AgentMetricLabel
- type AgentMetricType
- type AuthenticateResponse
- type AzureInstanceIdentityToken
- type Client
- func (c *Client) AuthAWSInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
- func (c *Client) AuthAzureInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
- func (c *Client) AuthGoogleInstanceIdentity(ctx context.Context, serviceAccount string, gcpClient *metadata.Client) (AuthenticateResponse, error)
- func (c *Client) DERPMapUpdates(ctx context.Context) (<-chan DERPMapUpdate, io.Closer, error)
- func (c *Client) ExternalAuth(ctx context.Context, req ExternalAuthRequest) (ExternalAuthResponse, error)
- func (c *Client) GetServiceBanner(ctx context.Context) (codersdk.ServiceBannerConfig, error)
- func (c *Client) GitSSHKey(ctx context.Context) (GitSSHKey, error)
- func (c *Client) Listen(ctx context.Context) (net.Conn, error)
- func (c *Client) Manifest(ctx context.Context) (Manifest, error)
- func (c *Client) PatchLogs(ctx context.Context, req PatchLogs) error
- func (c *Client) PostAppHealth(ctx context.Context, req PostAppHealthsRequest) error
- func (c *Client) PostLifecycle(ctx context.Context, req PostLifecycleRequest) error
- func (c *Client) PostLogSource(ctx context.Context, req PostLogSource) (codersdk.WorkspaceAgentLogSource, error)
- func (c *Client) PostMetadata(ctx context.Context, req PostMetadataRequest) error
- func (c *Client) PostStartup(ctx context.Context, req PostStartupRequest) error
- func (c *Client) PostStats(ctx context.Context, stats *Stats) (StatsResponse, error)
- func (c *Client) RPC(ctx context.Context) (agentproto.DRPCAgentClient, error)
- func (c *Client) ReportStats(ctx context.Context, log slog.Logger, statsChan <-chan *Stats, ...) (io.Closer, error)
- func (c *Client) SetSessionToken(token string)
- type DERPMapUpdate
- type ExternalAuthRequest
- type ExternalAuthResponse
- type GitSSHKey
- type GoogleInstanceIdentityToken
- type Log
- type LogSource
- type LogsNotifyMessage
- type Manifest
- type Metadata
- type PatchLogs
- type PostAppHealthsRequest
- type PostLifecycleRequest
- type PostLogSource
- type PostMetadataRequest
- type PostMetadataRequestDeprecated
- type PostStartupRequest
- type Script
- type Stats
- type StatsResponse
Constants ¶
This section is empty.
Variables ¶
var ExternalLogSourceID = uuid.MustParse("3b579bf4-1ed8-4b99-87a8-e9a1e3410410")
ExternalLogSourceID is the statically-defined ID of a log-source that appears as "External" in the dashboard.
This is to support legacy API-consumers that do not create their own log-source. This should be removed in the future.
Functions ¶
func LogsNotifyChannel ¶
LogsNotifyChannel returns the channel name responsible for notifying of new logs.
func LogsSender ¶
func LogsSender(sourceID uuid.UUID, patchLogs func(ctx context.Context, req PatchLogs) error, logger slog.Logger, opts ...func(*logsSenderOptions)) (sendLog func(ctx context.Context, log ...Log) error, flushAndClose func(context.Context) error)
LogsSender will send agent startup logs to the server. Calls to sendLog are non-blocking and will return an error if flushAndClose has been called. Calling sendLog concurrently is not supported. If the context passed to flushAndClose is canceled, any remaining logs will be discarded.
func LogsSenderFlushTimeout ¶ added in v2.3.0
LogsSenderFlushTimeout changes the default flush timeout (250ms), this is mostly useful for tests.
func LogsWriter ¶ added in v2.2.0
func LogsWriter(ctx context.Context, sender func(ctx context.Context, log ...Log) error, source uuid.UUID, level codersdk.LogLevel) io.WriteCloser
LogsWriter returns an io.WriteCloser that sends logs via the provided sender. The sender is expected to be non-blocking. Calling Close flushes any remaining partially written log lines but is otherwise no-op. If the context passed to LogsWriter is canceled, any remaining logs will be discarded.
Neither Write nor Close is safe for concurrent use and must be used by a single goroutine.
Types ¶
type AgentMetric ¶
type AgentMetric struct { Name string `json:"name" validate:"required"` Type AgentMetricType `json:"type" validate:"required" enums:"counter,gauge"` Value float64 `json:"value" validate:"required"` Labels []AgentMetricLabel `json:"labels,omitempty"` }
type AgentMetricLabel ¶
type AgentMetricType ¶
type AgentMetricType string
const ( AgentMetricTypeCounter AgentMetricType = "counter" AgentMetricTypeGauge AgentMetricType = "gauge" )
type AuthenticateResponse ¶
type AuthenticateResponse struct {
SessionToken string `json:"session_token"`
}
AuthenticateResponse is returned when an instance ID has been exchanged for a session token. @typescript-ignore AuthenticateResponse
type Client ¶
Client wraps `codersdk.Client` with specific functions scoped to a workspace agent.
func (*Client) AuthAWSInstanceIdentity ¶
func (c *Client) AuthAWSInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
AuthWorkspaceAWSInstanceIdentity uses the Amazon Metadata API to fetch a signed payload, and exchange it for a session token for a workspace agent.
The requesting instance must be registered as a resource in the latest history for a workspace.
func (*Client) AuthAzureInstanceIdentity ¶
func (c *Client) AuthAzureInstanceIdentity(ctx context.Context) (AuthenticateResponse, error)
AuthWorkspaceAzureInstanceIdentity uses the Azure Instance Metadata Service to fetch a signed payload, and exchange it for a session token for a workspace agent.
func (*Client) AuthGoogleInstanceIdentity ¶
func (c *Client) AuthGoogleInstanceIdentity(ctx context.Context, serviceAccount string, gcpClient *metadata.Client) (AuthenticateResponse, error)
AuthWorkspaceGoogleInstanceIdentity uses the Google Compute Engine Metadata API to fetch a signed JWT, and exchange it for a session token for a workspace agent.
The requesting instance must be registered as a resource in the latest history for a workspace.
func (*Client) DERPMapUpdates ¶
DERPMapUpdates connects to the DERP map updates WebSocket.
func (*Client) ExternalAuth ¶ added in v2.3.0
func (c *Client) ExternalAuth(ctx context.Context, req ExternalAuthRequest) (ExternalAuthResponse, error)
ExternalAuth submits a URL or provider ID to fetch an access token for. nolint:revive
func (*Client) GetServiceBanner ¶
GetServiceBanner relays the service banner config.
func (*Client) Listen ¶
Listen connects to the workspace agent coordinate WebSocket that handles connection negotiation.
func (*Client) Manifest ¶
Manifest fetches manifest for the currently authenticated workspace agent.
func (*Client) PatchLogs ¶
PatchLogs writes log messages to the agent startup script. Log messages are limited to 1MB in total.
func (*Client) PostAppHealth ¶
func (c *Client) PostAppHealth(ctx context.Context, req PostAppHealthsRequest) error
PostAppHealth updates the workspace agent app health status.
func (*Client) PostLifecycle ¶
func (c *Client) PostLifecycle(ctx context.Context, req PostLifecycleRequest) error
func (*Client) PostLogSource ¶ added in v2.2.0
func (c *Client) PostLogSource(ctx context.Context, req PostLogSource) (codersdk.WorkspaceAgentLogSource, error)
func (*Client) PostMetadata ¶
func (c *Client) PostMetadata(ctx context.Context, req PostMetadataRequest) error
func (*Client) PostStartup ¶
func (c *Client) PostStartup(ctx context.Context, req PostStartupRequest) error
func (*Client) RPC ¶ added in v2.6.0
func (c *Client) RPC(ctx context.Context) (agentproto.DRPCAgentClient, error)
func (*Client) ReportStats ¶
func (c *Client) ReportStats(ctx context.Context, log slog.Logger, statsChan <-chan *Stats, setInterval func(time.Duration)) (io.Closer, error)
ReportStats begins a stat streaming connection with the Coder server. It is resilient to network failures and intermittent coderd issues.
func (*Client) SetSessionToken ¶
type DERPMapUpdate ¶
type ExternalAuthRequest ¶ added in v2.3.0
type ExternalAuthRequest struct { // ID is the ID of a provider to request authentication for. ID string // Match is an arbitrary string matched against the regex of the provider. Match string // Listen indicates that the request should be long-lived and listen for // a new token to be requested. Listen bool }
ExternalAuthRequest is used to request an access token for a provider. Either ID or Match must be specified, but not both.
type ExternalAuthResponse ¶ added in v2.3.0
type ExternalAuthResponse struct { AccessToken string `json:"access_token"` TokenExtra map[string]interface{} `json:"token_extra"` URL string `json:"url"` Type string `json:"type"` // Deprecated: Only supported on `/workspaceagents/me/gitauth` // for backwards compatibility. Username string `json:"username"` Password string `json:"password"` }
type GoogleInstanceIdentityToken ¶
type GoogleInstanceIdentityToken struct {
JSONWebToken string `json:"json_web_token" validate:"required"`
}
type LogsNotifyMessage ¶
type LogsNotifyMessage struct {
CreatedAfter int64 `json:"created_after"`
}
type Manifest ¶
type Manifest struct { AgentID uuid.UUID `json:"agent_id"` AgentName string `json:"agent_name"` // OwnerName and WorkspaceID are used by an open-source user to identify the workspace. // We do not provide insurance that this will not be removed in the future, // but if it's easy to persist lets keep it around. OwnerName string `json:"owner_name"` WorkspaceID uuid.UUID `json:"workspace_id"` WorkspaceName string `json:"workspace_name"` // GitAuthConfigs stores the number of Git configurations // the Coder deployment has. If this number is >0, we // set up special configuration in the workspace. GitAuthConfigs int `json:"git_auth_configs"` VSCodePortProxyURI string `json:"vscode_port_proxy_uri"` Apps []codersdk.WorkspaceApp `json:"apps"` DERPMap *tailcfg.DERPMap `json:"derpmap"` DERPForceWebSockets bool `json:"derp_force_websockets"` EnvironmentVariables map[string]string `json:"environment_variables"` Directory string `json:"directory"` MOTDFile string `json:"motd_file"` DisableDirectConnections bool `json:"disable_direct_connections"` Metadata []codersdk.WorkspaceAgentMetadataDescription `json:"metadata"` Scripts []codersdk.WorkspaceAgentScript `json:"scripts"` }
type Metadata ¶ added in v2.3.1
type Metadata struct { Key string `json:"key"` codersdk.WorkspaceAgentMetadataResult }
type PostAppHealthsRequest ¶
type PostAppHealthsRequest struct { // Healths is a map of the workspace app name and the health of the app. Healths map[uuid.UUID]codersdk.WorkspaceAppHealth }
type PostLifecycleRequest ¶
type PostLifecycleRequest struct { State codersdk.WorkspaceAgentLifecycle `json:"state"` ChangedAt time.Time `json:"changed_at"` }
type PostLogSource ¶ added in v2.2.0
type PostLogSource struct { // ID is a unique identifier for the log source. // It is scoped to a workspace agent, and can be statically // defined inside code to prevent duplicate sources from being // created for the same agent. ID uuid.UUID `json:"id"` DisplayName string `json:"display_name"` Icon string `json:"icon"` }
type PostMetadataRequest ¶
type PostMetadataRequest struct {
Metadata []Metadata `json:"metadata"`
}
type PostMetadataRequestDeprecated ¶ added in v2.3.1
type PostMetadataRequestDeprecated = codersdk.WorkspaceAgentMetadataResult
In the future, we may want to support sending back multiple values for performance.
type PostStartupRequest ¶
type PostStartupRequest struct { Version string `json:"version"` ExpandedDirectory string `json:"expanded_directory"` Subsystems []codersdk.AgentSubsystem `json:"subsystems"` }
type Stats ¶
type Stats struct { // ConnectionsByProto is a count of connections by protocol. ConnectionsByProto map[string]int64 `json:"connections_by_proto"` // ConnectionCount is the number of connections received by an agent. ConnectionCount int64 `json:"connection_count"` // ConnectionMedianLatencyMS is the median latency of all connections in milliseconds. ConnectionMedianLatencyMS float64 `json:"connection_median_latency_ms"` // RxPackets is the number of received packets. RxPackets int64 `json:"rx_packets"` // RxBytes is the number of received bytes. RxBytes int64 `json:"rx_bytes"` // TxPackets is the number of transmitted bytes. TxPackets int64 `json:"tx_packets"` // TxBytes is the number of transmitted bytes. TxBytes int64 `json:"tx_bytes"` // SessionCountVSCode is the number of connections received by an agent // that are from our VS Code extension. SessionCountVSCode int64 `json:"session_count_vscode"` // SessionCountJetBrains is the number of connections received by an agent // that are from our JetBrains extension. SessionCountJetBrains int64 `json:"session_count_jetbrains"` // SessionCountReconnectingPTY is the number of connections received by an agent // that are from the reconnecting web terminal. SessionCountReconnectingPTY int64 `json:"session_count_reconnecting_pty"` // SessionCountSSH is the number of connections received by an agent // that are normal, non-tagged SSH sessions. SessionCountSSH int64 `json:"session_count_ssh"` // Metrics collected by the agent Metrics []AgentMetric `json:"metrics"` }
Stats records the Agent's network connection statistics for use in user-facing metrics and debugging.