executor

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package executor abstracts git repository operations and filesystem access.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// EnsureRepo clones the repository if it is not already present on disk, or
	// verifies it is accessible if it already exists.
	EnsureRepo(ctx context.Context) error

	// Pull fetches the latest changes from origin and fast-forwards the local
	// working tree to match.
	Pull(ctx context.Context) error

	// WalkManifests calls fn exactly once for each version directory found under
	// the repository's manifests/ tree. The dirPath argument is a slash-separated
	// path relative to the repository root, e.g.
	// "manifests/m/Microsoft/PowerShell/7.5.0.0".
	// Walking stops and returns the first non-nil error returned by fn, or any
	// filesystem error encountered during traversal.
	WalkManifests(ctx context.Context, fn func(dirPath string) error) error

	// ReadFile returns the raw contents of the file at the given repository-relative
	// path (forward-slash separated).
	ReadFile(ctx context.Context, path string) ([]byte, error)

	// ListFiles returns the file names (not full paths) of all regular files in the
	// given repository-relative directory.
	ListFiles(ctx context.Context, dirPath string) ([]string, error)

	// RepoRoot returns the absolute local filesystem path to the cloned repository.
	RepoRoot() string

	// GetLogger returns the zap logger configured for this executor. Services and
	// index builders use this to obtain a consistent logger without holding their
	// own reference.
	GetLogger() *zap.Logger
}

Executor abstracts the operations needed to access a cloned WinGet repository. It is satisfied by the go-git implementation in production and by the in-memory mock in tests.

type GoGitExecutor

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

GoGitExecutor implements Executor using a local clone of the repository managed by go-git.

func NewGoGitExecutor

func NewGoGitExecutor(cfg *config.Config) *GoGitExecutor

NewGoGitExecutor constructs a GoGitExecutor. It does not perform any I/O; call EnsureRepo to clone or verify the repository.

func (*GoGitExecutor) EnsureRepo

func (g *GoGitExecutor) EnsureRepo(ctx context.Context) error

EnsureRepo clones the repository if the cache directory does not yet contain it. If the directory already exists it is opened and verified to be a valid git repository.

func (*GoGitExecutor) GetLogger

func (g *GoGitExecutor) GetLogger() *zap.Logger

GetLogger returns the zap logger configured for this executor.

func (*GoGitExecutor) ListFiles

func (g *GoGitExecutor) ListFiles(_ context.Context, dirPath string) ([]string, error)

ListFiles returns the names of all regular files in the given repository-relative slash-separated directory path.

func (*GoGitExecutor) Pull

func (g *GoGitExecutor) Pull(ctx context.Context) error

Pull fetches the latest changes from origin and fast-forwards the working tree.

func (*GoGitExecutor) ReadFile

func (g *GoGitExecutor) ReadFile(_ context.Context, path string) ([]byte, error)

ReadFile returns the raw bytes of the file at the given repository-relative slash-separated path.

func (*GoGitExecutor) RepoRoot

func (g *GoGitExecutor) RepoRoot() string

RepoRoot returns the absolute path of the local repository clone.

func (*GoGitExecutor) WalkManifests

func (g *GoGitExecutor) WalkManifests(ctx context.Context, fn func(dirPath string) error) error

WalkManifests walks the manifests/ tree and calls fn exactly once for each version directory (a leaf directory containing YAML files). dirPath is slash-separated and relative to the repository root.

Directories

Path Synopsis
Package mock provides an in-memory Executor implementation for unit tests.
Package mock provides an in-memory Executor implementation for unit tests.

Jump to

Keyboard shortcuts

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