agent

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MPL-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DockerlessEnvVar          = "DOCKERLESS"
	DockerlessContextEnvVar   = "DOCKERLESS_CONTEXT"
	DefaultImageConfigPath    = "/.dockerless/image.json"
	DockerlessCredentialsPath = "/.dockerless/.docker" // #nosec G101 -- not a credential

)
View Source
const ContainerActivityFile = "/tmp/" + config.BinaryName + ".activity"
View Source
const ContainerDataDir = "/var/" + config.BinaryName

ContainerDataDir is the base directory for Devsy data inside containers.

View Source
const ContainerDevsyHelperLocation = "/usr/local/bin/" + config.BinaryName
View Source
const DefaultInactivityTimeout = time.Minute * 20
View Source
const RemoteDevsyHelperLocation = "/tmp/" + config.BinaryName
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 devsy home directory")

Functions

func Bool

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 DockerlessBuild

func DockerlessBuild(opts DockerlessBuildOptions) error

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 GetDockerlessBuildContext

func GetDockerlessBuildContext() string

func HasWorkspaceBusyFile

func HasWorkspaceBusyFile(folder string) bool

func ImageConfigExists

func ImageConfigExists(path string) bool

func InjectAgent

func InjectAgent(opts *InjectOptions) error

func IsDockerlessEnabled

func IsDockerlessEnabled() bool

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 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

type BinaryCache struct {
	BaseDir string
}

func (*BinaryCache) Get

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

func (*BinaryCache) Set

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

type BinaryManager

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

func NewBinaryManager

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

func (*BinaryManager) AcquireBinary

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

type BinarySource

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

type ConfigureCredentialsFunc

type ConfigureCredentialsFunc func(context.Context) (string, error)

type DockerlessBuildOptions

type DockerlessBuildOptions struct {
	Context                  context.Context
	SetupInfo                *config.Result
	DockerlessOptions        *provider2.ProviderDockerlessOptions
	ImageConfigOutput        string
	Debug                    bool
	Log                      log.Logger
	ConfigureCredentialsFunc ConfigureCredentialsFunc
}

type Exec

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

type FileCacheSource

type FileCacheSource struct {
	Cache *BinaryCache
}

func (*FileCacheSource) GetBinary

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

func (*FileCacheSource) SourceName

func (s *FileCacheSource) SourceName() string

type HTTPDownloadSource

type HTTPDownloadSource struct {
	BaseURL string
	Cache   *BinaryCache
}

func (*HTTPDownloadSource) GetBinary

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

func (*HTTPDownloadSource) SourceName

func (s *HTTPDownloadSource) SourceName() string

type InjectError

type InjectError struct {
	Stage InjectStage
	Cause error
}

func (*InjectError) Error

func (e *InjectError) Error() string

func (*InjectError) Unwrap

func (e *InjectError) Unwrap() error

type InjectOptions

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 RemoteDevsyHelperLocation.
	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 Devsy 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 DEVSY_AGENT_URL is set.
	SkipVersionCheck bool
}

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

func (*InjectOptions) ApplyDefaults

func (o *InjectOptions) ApplyDefaults()

func (*InjectOptions) Validate

func (o *InjectOptions) Validate() error

type InjectSource

type InjectSource struct{}

func (*InjectSource) GetBinary

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

func (*InjectSource) SourceName

func (s *InjectSource) SourceName() string

type InjectStage

type InjectStage string
const (
	InjectStageInject           InjectStage = "inject"
	InjectStageCommandExecution InjectStage = "command execution"
	InjectStageVersionCheck     InjectStage = "version check"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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