Documentation
¶
Overview ¶
Package cas implements a content-addressable storage for git content.
Blobs are copied from cloned repositories to a local store, along with trees. When the same content is requested again, the content is read from the local store, avoiding the need to clone the repository or read from the network.
Index ¶
- Constants
- Variables
- func GetRepoName(repo string) string
- type CAS
- type CASGetter
- type CloneOptions
- type Content
- func (c *Content) Ensure(l *log.Logger, hash string, data []byte) error
- func (c *Content) EnsureCopy(l *log.Logger, hash, src string) error
- func (c *Content) GetTmpHandle(hash string) (*os.File, error)
- func (c *Content) Link(hash, targetPath string) error
- func (c *Content) Read(hash string) ([]byte, error)
- func (c *Content) Store(l *log.Logger, hash string, data []byte) error
- type Error
- type GitRunner
- func (g *GitRunner) CatFile(ctx context.Context, hash string, out io.Writer) error
- func (g *GitRunner) Clone(ctx context.Context, repo string, bare bool, depth int, branch string) error
- func (g *GitRunner) CreateTempDir() (string, func() error, error)
- func (g *GitRunner) LsRemote(ctx context.Context, repo, ref string) ([]LsRemoteResult, error)
- func (g *GitRunner) LsTree(ctx context.Context, reference, path string) (*Tree, error)
- func (g *GitRunner) RequiresWorkDir() error
- func (g *GitRunner) SetWorkDir(dir string)
- func (g *GitRunner) WithWorkDir(workDir string) *GitRunner
- type LsRemoteResult
- type Options
- type Store
- type Tree
- type TreeEntry
- type WrappedError
Constants ¶
const ( // DefaultDirPerms represents standard directory permissions (rwxr-xr-x) DefaultDirPerms = os.FileMode(0755) // StoredFilePerms represents read-only file permissions (r--r--r--) StoredFilePerms = os.FileMode(0444) // RegularFilePerms represents standard file permissions (rw-r--r--) RegularFilePerms = os.FileMode(0644) )
Variables ¶
var ( ErrCommandSpawn = errors.New("failed to spawn git command") ErrNoMatchingReference = errors.New("no matching reference") ErrReadTree = errors.New("failed to read tree") ErrNoWorkDir = errors.New("working directory not set") )
Git operation errors
Functions ¶
func GetRepoName ¶
GetRepoName extracts the repository name from a git URL
Types ¶
type CAS ¶
type CAS struct {
// contains filtered or unexported fields
}
CAS clones a git repository using content-addressable storage.
type CASGetter ¶
type CASGetter struct {
CAS *CAS
Logger *log.Logger
Opts *CloneOptions
Detectors []getter.Detector
}
CASGetter is a go-getter Getter implementation.
func NewCASGetter ¶
func NewCASGetter(l *log.Logger, cas *CAS, opts *CloneOptions) *CASGetter
type CloneOptions ¶
type CloneOptions struct {
// Dir specifies the target directory for the clone
// If empty, uses the repository name
Dir string
// Branch specifies which branch to clone
// If empty, uses HEAD
Branch string
// IncludedGitFiles specifies the files to preserve from the .git directory
// If empty, does not preserve any files
IncludedGitFiles []string
}
CloneOptions configures the behavior of a specific clone operation
type Content ¶
type Content struct {
// contains filtered or unexported fields
}
Content manages git object storage and linking
func (*Content) EnsureCopy ¶
EnsureCopy ensures that a content item exists in the store by copying from a file
func (*Content) GetTmpHandle ¶
GetTmpHandle returns a file handle to a temporary file where content will be stored.
type Error ¶
type Error string
Error types that can be returned by the cas package
const ( // ErrTempDir is returned when failing to create or close a temporary directory ErrTempDir Error = "failed to create or manage temporary directory" // ErrCreateDir is returned when failing to create a directory ErrCreateDir Error = "failed to create directory" // ErrReadFile is returned when failing to read a file ErrReadFile Error = "failed to read file" // ErrParseTree is returned when failing to parse git tree output ErrParseTree Error = "failed to parse git tree output" // ErrGitClone is returned when the git clone operation fails ErrGitClone Error = "failed to complete git clone" // ErrCreateTempDir is returned when failing to create a temporary directory ErrCreateTempDir Error = "failed to create temporary directory" // ErrCleanupTempDir is returned when failing to clean up a temporary directory ErrCleanupTempDir Error = "failed to clean up temporary directory" )
type GitRunner ¶
type GitRunner struct {
WorkDir string
}
GitRunner handles git command execution
func (*GitRunner) Clone ¶
func (g *GitRunner) Clone(ctx context.Context, repo string, bare bool, depth int, branch string) error
Clone performs a git clone operation
func (*GitRunner) CreateTempDir ¶
CreateTempDir creates a new temporary directory for git operations
func (*GitRunner) LsRemote ¶
LsRemote runs git ls-remote for a specific reference. If ref is empty, we check HEAD instead.
func (*GitRunner) RequiresWorkDir ¶
RequiresWorkDir returns an error if no working directory is set
func (*GitRunner) SetWorkDir ¶
SetWorkDir sets the working directory for git commands
func (*GitRunner) WithWorkDir ¶
WithWorkDir returns a new GitRunner with the specified working directory
type LsRemoteResult ¶
LsRemoteResult represents the output of git ls-remote
type Options ¶
type Options struct {
// StorePath specifies a custom path for the content store
// If empty, uses $HOME/.cache/terragrunt/cas/store
StorePath string
}
Options configures the behavior of CAS
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the store directory and locks to prevent concurrent writes
func (*Store) NeedsWrite ¶
NeedsWrite checks if a given hash needs to be stored
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree represents a git tree object with its entries
type TreeEntry ¶
TreeEntry represents a single entry in a git tree
func ParseTreeEntry ¶
ParseTreeEntry parses a single line from git ls-tree output
type WrappedError ¶
type WrappedError struct {
Op string // Operation that failed
Path string // File path if applicable
Err error // Original error
Context string // Additional context
}
WrappedError provides additional context for errors
func (*WrappedError) Error ¶
func (e *WrappedError) Error() string
func (*WrappedError) Unwrap ¶
func (e *WrappedError) Unwrap() error