common

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CurrentBranchStub = func(output string, err error) CurrentBranchFunc {
	return func(_ string) (string, error) {
		if err != nil {
			return "", err
		}

		return output, nil
	}
}

CurrentBranchStub creates a stub CurrentBranchFunc that returns the provided output or error.

View Source
var WorkDirStub = func(dir string, err error) WorkDirFunc {
	return func() (string, error) { return dir, err }
}

WorkDirStub creates a stub WorkDirFunc that returns the provided directory or error.

Functions

func NewGitCliWrapper

func NewGitCliWrapper() *gitCliWrapper

NewGitCliWrapper creates a new git CLI wrapper using FUNC_GIT env var or "git" as default.

Types

type CurrentBranchFunc

type CurrentBranchFunc func(path string) (string, error)

CurrentBranchFunc is a function type that retrieves the current git branch for a given path.

var DefaultCurrentBranch CurrentBranchFunc = NewGitCliWrapper().CurrentBranch

DefaultCurrentBranch is the default implementation for getting the current git branch.

type FunctionLoader

type FunctionLoader interface {
	Load(path string) (fn.Function, error)
}

FunctionLoader loads a function from a filesystem path.

type FunctionLoaderSaver

type FunctionLoaderSaver interface {
	FunctionLoader
	FunctionSaver
}

FunctionLoaderSaver combines loading and saving capabilities for functions.

var DefaultLoaderSaver FunctionLoaderSaver = standardLoaderSaver{}

DefaultLoaderSaver implements FunctionLoaderSaver composite interface

type FunctionSaver

type FunctionSaver interface {
	Save(f fn.Function) error
}

FunctionSaver persists a function to storage.

type MockLoaderSaver

type MockLoaderSaver struct {
	LoadFn func(path string) (fn.Function, error)
	SaveFn func(f fn.Function) error
}

MockLoaderSaver provides configurable function loading and saving for testing purposes.

func NewMockLoaderSaver

func NewMockLoaderSaver() *MockLoaderSaver

NewMockLoaderSaver creates a MockLoaderSaver with default no-op implementations.

func (MockLoaderSaver) Load

func (m MockLoaderSaver) Load(path string) (fn.Function, error)

Load invokes the configured LoadFn to load a function from the given path.

func (MockLoaderSaver) Save

func (m MockLoaderSaver) Save(f fn.Function) error

Save invokes the configured SaveFn to persist the given function.

type WorkDirFunc

type WorkDirFunc func() (string, error)

WorkDirFunc is a function type that retrieves the current working directory.

var DefaultWorkDir WorkDirFunc = os.Getwd

DefaultWorkDir is the default implementation for getting the current working directory.

Jump to

Keyboard shortcuts

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