git

package
v1.4.4 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRepo = errors.New("invalid repo")

ErrInvalidRepo represents an attempt to access a non-existent repo.

View Source
var ErrNotAuthed = errors.New("you are not authorized to do this")

ErrNotAuthed represents unauthorized access.

View Source
var ErrSystemMalfunction = errors.New("something went wrong")

ErrSystemMalfunction represents a general system error returned to clients.

Functions

func EnsureRepo added in v1.3.0

func EnsureRepo(dir, repo string) error

EnsureRepo makes sure the given repo exists within the given dir, and that it is git repository.

If path does not exist, it'll be created. If the path is not a git repo, it will be git init-ed as a bare repository.

func Fatal added in v0.5.0

func Fatal(s ssh.Session, v ...interface{})

Fatal prints to the session's STDOUT as a git response and exit 1.

func Middleware

func Middleware(repoDir string, gh Hooks) wish.Middleware

Middleware adds Git server functionality to the ssh.Server. Repos are stored in the specified repo directory. The provided Hooks implementation will be checked for access on a per repo basis for a ssh.Session public key. Hooks.Push and Hooks.Fetch will be called on successful completion of their commands.

Types

type AccessLevel

type AccessLevel int

AccessLevel is the level of access allowed to a repo.

const (
	// NoAccess does not allow access to the repo.
	NoAccess AccessLevel = iota

	// ReadOnlyAccess allows read-only access to the repo.
	ReadOnlyAccess

	// ReadWriteAccess allows read and write access to the repo.
	ReadWriteAccess

	// AdminAccess allows read, write, and admin access to the repo.
	AdminAccess
)

type GitHooks deprecated

type GitHooks = Hooks // nolint: revive

GitHooks is an interface that allows for custom authorization implementations and post push/fetch notifications. Prior to git access, AuthRepo will be called with the ssh.Session public key and the repo name. Implementers return the appropriate AccessLevel.

Deprecated: use Hooks instead.

type Hooks added in v0.2.0

type Hooks interface {
	AuthRepo(string, ssh.PublicKey) AccessLevel
	Push(string, ssh.PublicKey)
	Fetch(string, ssh.PublicKey)
}

Hooks is an interface that allows for custom authorization implementations and post push/fetch notifications. Prior to git access, AuthRepo will be called with the ssh.Session public key and the repo name. Implementers return the appropriate AccessLevel.

Jump to

Keyboard shortcuts

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