Documentation ¶
Index ¶
- Constants
- func ExitCode(rw ssh.Channel, code uint32)
- func NewServer(gs GitServer, opts ...ServerOption) func(*ssh.ServerConn, <-chan ssh.NewChannel, <-chan *ssh.Request, error) error
- type DebugLogger
- type GitServer
- type GoGitServer
- func (s *GoGitServer) NewReceivePack(repoName string) ReceivePacker
- func (s *GoGitServer) NewUploadPack(repoName string) UploadPacker
- func (s *GoGitServer) WithLogger(logger ...interface{})
- func (s *GoGitServer) WithPostReceiveHook(fn cfg.PostReceivePackHookFunc)
- func (s *GoGitServer) WithPreReceiveHook(fn cfg.PreReceivePackHookFunc)
- type HandlerFunc
- type InfoLogger
- type Mux
- type ReceivePack
- type ReceivePacker
- type Server
- type ServerOption
- type UploadPack
- type UploadPacker
Constants ¶
const ( ErrSession strErr = "%s session: %v" ErrSessionAdvRefs strErr = "%s session advertised references: %v" ErrAdvRefsEncode strErr = "%s advertied references encode: %v" ErrPackDecode strErr = "pack decode: %v" ErrPackScanAdvRefs strErr = "pack scan [1] advertised references: %v" ErrResponseEncode strErr = "%s response encode: %v" ErrRequestDecode strErr = "%s request decode: %v" ErrReceivePack strErr = "bad receive pack: %v" ErrUploadPack strErr = "bad upload pack: %v" ErrTransportEndpoint strErr = "repo [%s] endpoint invalid: %v" ErrEmptyHookData strErr = "empty receive-pack hook data" )
returns all of the errors
Variables ¶
This section is empty.
Functions ¶
func ExitCode ¶
ExitCode sends a specific exit status back to the SSH channel. If no code is sent then the channel closes with a error code of -1
func NewServer ¶
func NewServer(gs GitServer, opts ...ServerOption) func(*ssh.ServerConn, <-chan ssh.NewChannel, <-chan *ssh.Request, error) error
NewServer returns a function that can wrap a SSH ssh.NewServer() function. It will then handle all requests for SSH
Types ¶
type DebugLogger ¶
DebugLogger wrap *log.Loggers with this to display debug logging
type GitServer ¶
type GitServer interface { NewReceivePack(repoName string) ReceivePacker NewUploadPack(repoName string) UploadPacker WithLogger(...interface{}) WithPreReceiveHook(cfg.PreReceivePackHookFunc) WithPostReceiveHook(cfg.PostReceivePackHookFunc) }
GitServer is the interface used to interact with the git server via SSH
type GoGitServer ¶
type GoGitServer struct {
// contains filtered or unexported fields
}
GoGitServer wraps concepts for go-git into a GitServer SSH interface
func LoadGoGit ¶
func LoadGoGit(m map[string]*git.Repository, endpoint string) *GoGitServer
LoadGoGit loads a mapping of git repositories (go-git) to a repository endpoint
func (*GoGitServer) NewReceivePack ¶
func (s *GoGitServer) NewReceivePack(repoName string) ReceivePacker
NewReceivePack returns a new ReceivePack object
func (*GoGitServer) NewUploadPack ¶
func (s *GoGitServer) NewUploadPack(repoName string) UploadPacker
NewUploadPack returns a new UploadPack object
func (*GoGitServer) WithLogger ¶
func (s *GoGitServer) WithLogger(logger ...interface{})
WithLogger takes in logger/s to display debug and info logs for the GoGitServer object
func (*GoGitServer) WithPostReceiveHook ¶
func (s *GoGitServer) WithPostReceiveHook(fn cfg.PostReceivePackHookFunc)
WithPostReceiveHook sets the post-receive hook for receive-pack requests
func (*GoGitServer) WithPreReceiveHook ¶
func (s *GoGitServer) WithPreReceiveHook(fn cfg.PreReceivePackHookFunc)
WithPreReceiveHook sets the pre-receive hook for receive-pack requests
type HandlerFunc ¶
HandlerFunc is an adapter to allow the use of ordinary functions as SSH handlers
type InfoLogger ¶
InfoLogger wrap *log.Loggers with this to display info logging
type Mux ¶
type Mux struct { Handlers map[string]HandlerFunc NotFoundHandler HandlerFunc }
Mux holds the handlers and a command associated with it.
func (*Mux) HandlerFunc ¶
func (m *Mux) HandlerFunc(command string, fn HandlerFunc)
HandlerFunc adds a handler with a command to the Mux
type ReceivePack ¶
type ReceivePack struct { *GoGitServer // contains filtered or unexported fields }
ReceivePack holds all of the data needed to handle the git interface for receive-pack requests through SSH
func (*ReceivePack) Cleanup ¶
func (rp *ReceivePack) Cleanup()
Cleanup takes any functions that were collected and runs them. This is for deferred processes
func (*ReceivePack) DoSSH ¶
func (rp *ReceivePack) DoSSH(rw ssh.Channel) ReceivePacker
DoSSH takes in a SSH channel and processes what is supposed to happen if there are any errors then this method is skipped, and errors can be checked with the Err() method
func (*ReceivePack) Err ¶
func (rp *ReceivePack) Err() error
Err returns the error that was collected during the receive-pack processing
type ReceivePacker ¶
type ReceivePacker interface { DoSSH(ssh.Channel) ReceivePacker Cleanup() Err() error }
ReceivePacker returns SSH requests for 'receive-pack'
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server holds the handlers for requests that the git client can make via SSH
func (*Server) ReceivePackHandler ¶
ReceivePackHandler handles SSH calls to 'receive-pack'
func (*Server) ServeSSH ¶
ServeSSH provides the internal handling for SSH channels accepted on a connection
func (*Server) UploadPackHandler ¶
UploadPackHandler handles SSH calls to 'upload-pack'
func (*Server) WithLogger ¶
func (s *Server) WithLogger(logger ...interface{})
WithLogger takes in logger/s to display debug and info logs for the server object
type ServerOption ¶
type ServerOption func(*Server)
ServerOption is the optional function type used for cfghttp
func WithLogger ¶
func WithLogger(l ...interface{}) ServerOption
WithLogger adds a logger to the library. If *log.Logger is used then both debug and info logs will be populated. wrap a *log.Logger in DebugLogger or InfoLogger to just view the logs for one level
func WithPostReceiveHook ¶
func WithPostReceiveHook(fn func(io.Writer, *cfg.PostReceivePackHookData)) ServerOption
WithPostReceiveHook adds a post-recieve hook to the handler, sending nil to the handler will sucessfully execute the git commad send a non nil error to reject the recieve. All writes the the writer will be done with newlines, otherwise it may be cut off.
func WithPreReceiveHook ¶
func WithPreReceiveHook(fn func(io.Writer, *cfg.PreReceivePackHookData) (string, *cfg.ReceivePackHookError)) ServerOption
WithPreReceiveHook adds a pre-recieve hook to the handler, sending nil to the handler will sucessfully execute the git commad send a non nil error to reject the recieve. All writes the the writer will be done with newlines, otherwise it may be cut off.
type UploadPack ¶
type UploadPack struct { *GoGitServer // contains filtered or unexported fields }
UploadPack holds all of the data needed to handle the git interface for upload-pack requests for SSH
func (*UploadPack) Cleanup ¶
func (up *UploadPack) Cleanup()
Cleanup takes any functions that were collected and runs them. This is for deferred processes
func (*UploadPack) DoSSH ¶
func (up *UploadPack) DoSSH(rw ssh.Channel) UploadPacker
DoSSH takes in a ssh channel and decodes what is supposed to happen if there are any errors then this method is skipped, and errors can be checked with the Err() method
func (*UploadPack) Err ¶
func (up *UploadPack) Err() error
Err returns the error that was collected during the upload-pack processing
type UploadPacker ¶
type UploadPacker interface { DoSSH(ssh.Channel) UploadPacker Cleanup() Err() error }
UploadPacker returns HTTP requests for 'upload-pack'