workspace

package
v0.19.856 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCommitHash

func IsCommitHash(s string) bool

IsCommitHash checks if a string matches the pattern of a git commit hash (5-40 hexadecimal characters).

Types

type CloneErr

type CloneErr struct {
	Url string
	Ref string
	Err error
}

func (CloneErr) Error

func (c CloneErr) Error() string

func (CloneErr) Unwrap

func (c CloneErr) Unwrap() error

type GitSource

type GitSource struct {
	URL  string `json:"url" validate:"required"`
	Ref  string `json:"ref" validate:"required"`
	Path string `json:"path"` // subdirectory within the repo
}

GitSource defines the git repository to clone.

func GitSourceFromPlanTypes

func GitSourceFromPlanTypes(src *plantypes.GitSource) *GitSource

GitSourceFromPlanTypes converts a plantypes.GitSource to a workspace.GitSource.

type Option

type Option func(*Workspace)

Option configures a Workspace.

func WithCleanup

func WithCleanup(cleanup bool) Option

WithCleanup configures whether to remove the workspace directory before initialization. If true, Init() will delete any existing directory at the workspace path before creating it. This is useful when re-using workspace IDs or recovering from failed clones.

func WithGitSource

func WithGitSource(src *GitSource) Option

WithGitSource sets a git source for cloning.

func WithID

func WithID(id string) Option

WithID sets the workspace ID (used as the temp directory name).

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets the logger.

func WithTmpRoot

func WithTmpRoot(root string) Option

WithTmpRoot sets the root temp directory for the workspace.

type PathExistsErr

type PathExistsErr struct {
	Path string
}

func (PathExistsErr) Error

func (p PathExistsErr) Error() string

type Workspace

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

Workspace provides a temporary directory with optional git clone support.

func New

func New(v *validator.Validate, opts ...Option) (*Workspace, error)

New creates a new Workspace with the given options.

func (*Workspace) AbsPath

func (w *Workspace) AbsPath(path string) string

AbsPath returns an absolute path within the workspace.

func (*Workspace) Cleanup

func (w *Workspace) Cleanup(ctx context.Context) error

Cleanup removes the workspace directory.

func (*Workspace) Init

func (w *Workspace) Init(ctx context.Context) error

Init creates the workspace directory and clones the git source if configured.

func (*Workspace) IsDir

func (w *Workspace) IsDir(path string) bool

IsDir returns true if the path exists and is a directory.

func (*Workspace) IsExecutable

func (w *Workspace) IsExecutable(path string) bool

IsExecutable returns true if the path exists and is executable.

func (*Workspace) IsFile

func (w *Workspace) IsFile(path string) bool

IsFile returns true if the path exists and is a file.

func (*Workspace) RmDir

func (w *Workspace) RmDir(path string) error

RmDir removes a directory within the workspace.

func (*Workspace) Root

func (w *Workspace) Root() string

Root returns the workspace root directory path.

func (*Workspace) SourceDir

func (w *Workspace) SourceDir() string

SourceDir returns the absolute path to the source subdirectory within the clone. If no git source path is configured, returns the root directory.

Jump to

Keyboard shortcuts

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