agentsdk

package
v0.17.3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: AGPL-3.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSInstanceIdentityToken

type AWSInstanceIdentityToken struct {
	Signature string `json:"signature" validate:"required"`
	Document  string `json:"document" validate:"required"`
}

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 AzureInstanceIdentityToken

type AzureInstanceIdentityToken struct {
	Signature string `json:"signature" validate:"required"`
	Encoding  string `json:"encoding" validate:"required"`
}

type Client

type Client struct {
	SDK *codersdk.Client
}

Client wraps `codersdk.Client` with specific functions scoped to a workspace agent.

func New

func New(serverURL *url.URL) *Client

New returns a client that is used to interact with the Coder API from 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) GitAuth

func (c *Client) GitAuth(ctx context.Context, gitURL string, listen bool) (GitAuthResponse, error)

GitAuth submits a URL to fetch a GIT_ASKPASS username and password for. nolint:revive

func (*Client) GitSSHKey

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

GitSSHKey will return the user's SSH key pair for the workspace.

func (*Client) Listen

func (c *Client) Listen(ctx context.Context) (net.Conn, error)

Listen connects to the workspace agent coordinate WebSocket that handles connection negotiation.

func (*Client) Metadata

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

Metadata fetches metadata for the currently authenticated workspace agent.

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) PostStartup added in v0.17.1

func (c *Client) PostStartup(ctx context.Context, req PostStartupRequest) error

func (*Client) PostStats

func (c *Client) PostStats(ctx context.Context, stats *Stats) (StatsResponse, 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

func (c *Client) SetSessionToken(token string)

type GitAuthResponse

type GitAuthResponse struct {
	Username string `json:"username"`
	Password string `json:"password"`
	URL      string `json:"url"`
}

type GitSSHKey

type GitSSHKey struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

type GoogleInstanceIdentityToken

type GoogleInstanceIdentityToken struct {
	JSONWebToken string `json:"json_web_token" validate:"required"`
}

type Metadata

type Metadata struct {
	// 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"`
	EnvironmentVariables map[string]string       `json:"environment_variables"`
	StartupScript        string                  `json:"startup_script"`
	StartupScriptTimeout time.Duration           `json:"startup_script_timeout"`
	Directory            string                  `json:"directory"`
	MOTDFile             string                  `json:"motd_file"`
}

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"`
}

type PostStartupRequest added in v0.17.1

type PostStartupRequest struct {
	Version           string `json:"version"`
	ExpandedDirectory string `json:"expanded_directory"`
}

type Stats

type Stats struct {
	// ConnsByProto is a count of connections by protocol.
	ConnsByProto map[string]int64 `json:"conns_by_proto"`
	// NumConns is the number of connections received by an agent.
	NumConns int64 `json:"num_comms"`
	// 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"`
}

Stats records the Agent's network connection statistics for use in user-facing metrics and debugging.

type StatsResponse

type StatsResponse struct {
	// ReportInterval is the duration after which the agent should send stats
	// again.
	ReportInterval time.Duration `json:"report_interval"`
}

Jump to

Keyboard shortcuts

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