gitpacklib

package module
v0.0.0-...-37d74e1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2015 License: MIT Imports: 23 Imported by: 0

README

gitpacklib

gitpacklib is an experimental library that facilitates creating an SSH-based git server that receives pushes from git clients and saves git data to an arbitrary storage medium (not just a filesystem .git directory). Rather than wrapping the git-receive-pack command line utility, the git object unpacking code is implemented natively in Go. Similarly, an SSH server is included that is based on golang.org/x/crypto/ssh, so an external SSH daemon is not required.

The current implementation is not designed for efficiency, but for simplicity. The unpacking is done as the pack file is received so large repositories will use a lot of storage space in the backing store. This may change in a future version, where the unpacking can be done on the fly at usage time similar to git itself.

gitpacklib does not include main binary, though the examples provide basic usage with dummy setup, authentication and storage backends. A typical project would fork these examples to implement custom logic for the specific use case.

Documentation

Index

Constants

View Source
const RefsKey = "refs"

Variables

This section is empty.

Functions

func ParseKeysFromBytes

func ParseKeysFromBytes(conf *ssh.ServerConfig, pemBytes []byte) error

func ParseKeysFromFile

func ParseKeysFromFile(conf *ssh.ServerConfig, filename string) error

func RunServer

func RunServer(conf *ServerConfig) error

Types

type BackingStore

type BackingStore interface {
	Lock()
	Unlock()

	Set(name string, value []byte) error
	Get(name string) ([]byte, error)
}

type Client

type Client interface {
	AuthenticatePublicKey(conn ssh.ConnMetadata, key ssh.PublicKey) (bool, error)
	PublicKeyChosen(key ssh.PublicKey)
	GetRepositoryBackingStore(repoPath string) (BackingStore, error)
}

type ClientHandler

type ClientHandler interface {
	NewClient() Client
}

type ClientSession

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

type FileBackingStore

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

func NewFileBackingStore

func NewFileBackingStore(basePath string) (*FileBackingStore, error)

func (*FileBackingStore) Get

func (fs *FileBackingStore) Get(name string) ([]byte, error)

func (*FileBackingStore) Lock

func (fs *FileBackingStore) Lock()

func (*FileBackingStore) Set

func (fs *FileBackingStore) Set(name string, value []byte) (err error)

func (*FileBackingStore) Unlock

func (fs *FileBackingStore) Unlock()

type GitReceiveSession

type GitReceiveSession struct {
	BackingStore BackingStore
	// contains filtered or unexported fields
}

func NewGitReceiveSession

func NewGitReceiveSession() *GitReceiveSession

func (*GitReceiveSession) HandleGitReceivePack

func (session *GitReceiveSession) HandleGitReceivePack(in_ io.Reader, out io.Writer)

type HashingReader

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

HashingReader proxies an io.Reader with optional io.ByteReader support, and hashes all bytes that pass through with a given hash.Hash.

Reset and Sum methods are also proxied to the internal Hash object.

func NewHashingReader

func NewHashingReader(h hash.Hash, r io.Reader) *HashingReader

func NewSHA1Reader

func NewSHA1Reader(r io.Reader) *HashingReader

func (*HashingReader) Read

func (hr *HashingReader) Read(p []byte) (n int, err error)

func (*HashingReader) ReadByte

func (hr *HashingReader) ReadByte() (c byte, err error)

func (*HashingReader) Reset

func (hr *HashingReader) Reset()

func (*HashingReader) Sum

func (hr *HashingReader) Sum(b []byte) []byte

type RefMap

type RefMap struct {
	Refs map[string]string
}

func NewRefMap

func NewRefMap() *RefMap

func (*RefMap) Deserialize

func (r *RefMap) Deserialize(buf []byte)

func (*RefMap) Get

func (r *RefMap) Get(name string) string

func (*RefMap) Length

func (r *RefMap) Length() int

func (*RefMap) Serialize

func (r *RefMap) Serialize() []byte

func (*RefMap) Set

func (r *RefMap) Set(name string, value string)

type ServerConfig

type ServerConfig struct {
	SSHPort   int
	SSHConfig ssh.ServerConfig

	ClientHandler ClientHandler
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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