agent

package
v0.9.6 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: MPL-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const ContainerActivityFile = "/tmp/devpod.activity"
View Source
const ContainerDevPodHelperLocation = "/usr/local/bin/devpod"
View Source
const DefaultInactivityTimeout = time.Minute * 20
View Source
const EnvDevPodAgentPreferDownload = "DEVPOD_AGENT_PREFER_DOWNLOAD"
View Source
const EnvDevPodAgentURL = "DEVPOD_AGENT_URL"
View Source
const RemoteDevPodHelperLocation = "/tmp/devpod"
View Source
const WorkspaceBusyFile = "workspace.lock"

Variables

View Source
var (
	ErrBinaryNotFound = errors.New("agent binary not found")
	ErrInjectTimeout  = errors.New("injection timeout")
	ErrArchMismatch   = errors.New("architecture mismatch")
)
View Source
var ErrFindAgentHomeFolder = fmt.Errorf("couldn't find devpod home directory")

Functions

func Bool added in v0.9.1

func Bool(b bool) *bool

func CloneRepositoryForWorkspace

func CloneRepositoryForWorkspace(
	ctx context.Context,
	source *provider2.WorkspaceSource,
	agentConfig *provider2.ProviderAgentConfig,
	workspaceDir, helper string,
	options provider2.CLIOptions,
	overwriteContent bool,
	log log.Logger,
) error

func CreateAgentWorkspaceDir

func CreateAgentWorkspaceDir(agentFolder, context, workspaceID string) (string, error)

func CreateWorkspaceBusyFile

func CreateWorkspaceBusyFile(folder string)

func DecodeContainerWorkspaceInfo

func DecodeContainerWorkspaceInfo(workspaceInfoRaw string) (*provider2.ContainerWorkspaceInfo, string, error)

func DecodeWorkspaceInfo

func DecodeWorkspaceInfo(workspaceInfoRaw string) (*provider2.AgentWorkspaceInfo, string, error)

func DefaultAgentDownloadURL

func DefaultAgentDownloadURL() string

func DeleteWorkspaceBusyFile

func DeleteWorkspaceBusyFile(folder string)

func FindAgentHomeFolder

func FindAgentHomeFolder(agentFolder string) (string, error)

func GetAgentBinariesDir

func GetAgentBinariesDir(agentFolder, context, workspaceID string) (string, error)

func GetAgentBinariesDirFromWorkspaceDir

func GetAgentBinariesDirFromWorkspaceDir(workspaceDir string) (string, error)

func GetAgentDaemonLogFolder

func GetAgentDaemonLogFolder(agentFolder string) (string, error)

func GetAgentWorkspaceContentDir

func GetAgentWorkspaceContentDir(workspaceDir string) string

func GetAgentWorkspaceDir

func GetAgentWorkspaceDir(agentFolder, context, workspaceID string) (string, error)

func HasWorkspaceBusyFile

func HasWorkspaceBusyFile(folder string) bool

func InjectAgent

func InjectAgent(opts *InjectOptions) error

func ParseAgentWorkspaceInfo

func ParseAgentWorkspaceInfo(workspaceConfigFile string) (*provider2.AgentWorkspaceInfo, error)

func PrepareAgentHomeFolder

func PrepareAgentHomeFolder(agentFolder string) (string, error)

func ReadAgentWorkspaceInfo

func ReadAgentWorkspaceInfo(agentFolder, context, id string, log log.Logger) (bool, *provider2.AgentWorkspaceInfo, error)

func RetryWithDeadline added in v0.9.1

func RetryWithDeadline(
	ctx context.Context,
	log log.Logger,
	cfg RetryConfig,
	fn RetryFunc,
) error

func Tunnel

func Tunnel(
	ctx context.Context,
	exec Exec,
	user string,
	stdin io.Reader,
	stdout io.Writer,
	stderr io.Writer,
	log log.Logger,
	timeout time.Duration,
) error

func WorkspaceInfo

func WorkspaceInfo(workspaceInfoEncoded string, log log.Logger) (bool, *provider2.AgentWorkspaceInfo, error)

func WriteWorkspaceInfo

func WriteWorkspaceInfo(workspaceInfoEncoded string, log log.Logger) (bool, *provider2.AgentWorkspaceInfo, error)

func WriteWorkspaceInfoAndDeleteOld

func WriteWorkspaceInfoAndDeleteOld(workspaceInfoEncoded string, deleteWorkspace func(workspaceInfo *provider2.AgentWorkspaceInfo, log log.Logger) error, log log.Logger) (bool, *provider2.AgentWorkspaceInfo, error)

Types

type BinaryCache added in v0.9.1

type BinaryCache struct {
	BaseDir string
}

func (*BinaryCache) Get added in v0.9.1

func (c *BinaryCache) Get(arch string) (io.ReadCloser, error)

func (*BinaryCache) Set added in v0.9.1

func (c *BinaryCache) Set(arch string, data io.Reader) error

type BinaryManager added in v0.9.1

type BinaryManager struct {
	// contains filtered or unexported fields
}

func NewBinaryManager added in v0.9.1

func NewBinaryManager(logger log.Logger, downloadURL string) *BinaryManager

func (*BinaryManager) AcquireBinary added in v0.9.1

func (m *BinaryManager) AcquireBinary(ctx context.Context, arch string) (io.ReadCloser, string, error)

type BinarySource added in v0.9.1

type BinarySource interface {
	GetBinary(ctx context.Context, arch string) (io.ReadCloser, error)
	SourceName() string
}

type Exec

type Exec func(ctx context.Context, user string, command string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error

type FileCacheSource added in v0.9.1

type FileCacheSource struct {
	Cache *BinaryCache
}

func (*FileCacheSource) GetBinary added in v0.9.1

func (s *FileCacheSource) GetBinary(ctx context.Context, arch string) (io.ReadCloser, error)

func (*FileCacheSource) SourceName added in v0.9.1

func (s *FileCacheSource) SourceName() string

type HTTPDownloadSource added in v0.9.1

type HTTPDownloadSource struct {
	BaseURL string
	Cache   *BinaryCache
}

func (*HTTPDownloadSource) GetBinary added in v0.9.1

func (s *HTTPDownloadSource) GetBinary(ctx context.Context, arch string) (io.ReadCloser, error)

func (*HTTPDownloadSource) SourceName added in v0.9.1

func (s *HTTPDownloadSource) SourceName() string

type InjectError added in v0.9.1

type InjectError struct {
	Stage string
	Cause error
}

func (*InjectError) Error added in v0.9.1

func (e *InjectError) Error() string

func (*InjectError) Unwrap added in v0.9.1

func (e *InjectError) Unwrap() error

type InjectOptions added in v0.9.1

type InjectOptions struct {
	// Ctx is the context for the injection operation. Required.
	Ctx context.Context
	// Exec is the function used to execute commands on the remote machine. Required.
	Exec inject.ExecFunc
	// Log is the logger for capturing injection output. Required.
	Log log.Logger

	// IsLocal indicates if the injection target is the local machine.
	IsLocal bool
	// RemoteAgentPath is the path where the agent binary should be placed on the remote machine. Defaults to RemoteDevPodHelperLocation.
	RemoteAgentPath string
	// DownloadURL is the base URL to download the agent binary from. Defaults to DefaultAgentDownloadURL().
	DownloadURL string
	// PreferDownloadFromRemoteUrl forces downloading the agent even if a local binary is available.
	// Defaults to true for release versions, false for dev versions.
	PreferDownloadFromRemoteUrl *bool
	// Timeout is the maximum duration to wait for the injection to complete. Defaults to 5 minutes.
	Timeout time.Duration

	// Command is the command to execute after successful injection.
	Command string

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	// LocalVersion is the version of the local DevPod binary. Defaults to version.GetVersion().
	LocalVersion string
	// RemoteVersion is the expected version of the remote agent. Defaults to LocalVersion.
	RemoteVersion string
	// SkipVersionCheck disables the validation of the remote agent's version. Defaults to false, unless DEVPOD_AGENT_URL is set.
	SkipVersionCheck bool
	// MetricsCollector handles the recording of injection metrics. Defaults to LogMetricsCollector.
	MetricsCollector MetricsCollector
}

InjectOptions defines the parameters for injecting the DevPod agent into a remote environment.

func (*InjectOptions) ApplyDefaults added in v0.9.1

func (o *InjectOptions) ApplyDefaults()

func (*InjectOptions) Validate added in v0.9.1

func (o *InjectOptions) Validate() error

type InjectSource added in v0.9.1

type InjectSource struct{}

func (*InjectSource) GetBinary added in v0.9.1

func (s *InjectSource) GetBinary(ctx context.Context, arch string) (io.ReadCloser, error)

func (*InjectSource) SourceName added in v0.9.1

func (s *InjectSource) SourceName() string

type InjectionMetrics added in v0.9.1

type InjectionMetrics struct {
	StartTime    time.Time
	EndTime      time.Time
	Attempts     int
	BinarySource string
	AgentVersion string
	VersionCheck bool
	Success      bool
	Error        error
}

type LogMetricsCollector added in v0.9.1

type LogMetricsCollector struct {
	Log log.Logger
}

func (*LogMetricsCollector) RecordInjection added in v0.9.1

func (c *LogMetricsCollector) RecordInjection(metrics *InjectionMetrics)

type MetricsCollector added in v0.9.1

type MetricsCollector interface {
	RecordInjection(metrics *InjectionMetrics)
}

type RetryConfig added in v0.9.1

type RetryConfig struct {
	MaxAttempts  int
	InitialDelay time.Duration
	MaxDelay     time.Duration
	Deadline     time.Time
}

type RetryFunc added in v0.9.1

type RetryFunc func(attempt int) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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