Documentation ¶
Index ¶
- func GetSizeOfObjects(note pushtypes.PushNote) (uint64, error)
- func MakeReferenceUpdateRequestPack(note pushtypes.PushNote) (io.ReadSeeker, error)
- type BasicHandler
- func (h *BasicHandler) DoAuth(ur *packp.ReferenceUpdateRequest, targetRef string, ignorePostRefs bool) error
- func (h *BasicHandler) EnsureReferencesHaveTxDetail() error
- func (h *BasicHandler) GetChange(ref string) (*remotetypes.ItemChange, error)
- func (h *BasicHandler) HandleAnnouncement(cb func(errCount int))
- func (h *BasicHandler) HandleAuthorization(ur *packp.ReferenceUpdateRequest) error
- func (h *BasicHandler) HandleGCAndSizeCheck() error
- func (h *BasicHandler) HandlePushNote(note types.PushNote) (err error)
- func (h *BasicHandler) HandleRefMismatch(note types.PushNote, ref string, netMismatch bool) (err error)
- func (h *BasicHandler) HandleReference(ref string) (errs []error)
- func (h *BasicHandler) HandleReferences() error
- func (h *BasicHandler) HandleReversion() []error
- func (h *BasicHandler) HandleStream(packfile io.Reader, gitReceive io.WriteCloser, gitRcvCmd util.Cmd, ...) error
- func (h *BasicHandler) HandleUpdate(targetNote types.PushNote) (err error)
- type HandleAuthorizationFunc
- type HandleReferenceFunc
- type Handler
- type MakeReferenceUpdateRequestPackFunc
- type ObjectObserver
- func (o *ObjectObserver) OnFooter(plumbing.Hash) error
- func (o *ObjectObserver) OnHeader(uint32) error
- func (o *ObjectObserver) OnInflatedObjectContent(h plumbing.Hash, pos int64, crc uint32, content []byte) error
- func (o *ObjectObserver) OnInflatedObjectHeader(t plumbing.ObjectType, objSize int64, pos int64) error
- type PackObject
- type PackedReferenceObject
- type PackedReferences
- type PushedObjects
- type Reader
- func (r *Reader) GetSizeObjects() int64
- func (r *Reader) GetUpdateRequest() *packp.ReferenceUpdateRequest
- func (r *Reader) Read() error
- func (r *Reader) SetUpdateRequest(request *packp.ReferenceUpdateRequest)
- func (r *Reader) UseReferenceUpdateRequestRead(cb func(ur *packp.ReferenceUpdateRequest) error)
- func (r *Reader) Write(p []byte) (int, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSizeOfObjects ¶
GetSizeOfObjects returns the size of objects required to fulfil the push note.
func MakeReferenceUpdateRequestPack ¶
func MakeReferenceUpdateRequestPack(note pushtypes.PushNote) (io.ReadSeeker, error)
MakeReferenceUpdateRequestPack creates a reference update request to send to git-receive-pack program.
Types ¶
type BasicHandler ¶
type BasicHandler struct { Repo remotetypes.LocalRepo // The target repository Server core.RemoteServer // The repository remote server OldState remotetypes.RepoRefsState // The old state of the repo before the current push was written PushReader *Reader // The push reader for reading pushed git objects NoteID string // The push note unique ID ChangeValidator validation.ChangeValidatorFunc // Repository state change validator Reverter plumbing.RevertFunc // Repository state reverser function MergeChecker validation.MergeComplianceCheckFunc // Merge request checker function TxDetails remotetypes.ReferenceTxDetails // Map of references to their transaction details ReferenceHandler HandleReferenceFunc // Pushed reference handler function AuthorizationHandler HandleAuthorizationFunc // Authorization handler function PolicyChecker policy.PolicyChecker // Policy checker function // contains filtered or unexported fields }
BasicHandler implements Handler. It provides handles all phases of a push operation.
func NewHandler ¶
func NewHandler( repo remotetypes.LocalRepo, txDetails []*remotetypes.TxDetail, polEnforcer policy.EnforcerFunc, rMgr core.RemoteServer) *BasicHandler
NewHandler returns an instance of BasicHandler
func (*BasicHandler) DoAuth ¶
func (h *BasicHandler) DoAuth(ur *packp.ReferenceUpdateRequest, targetRef string, ignorePostRefs bool) error
DoAuth implements Handler. It performs access-level checks.
func (*BasicHandler) EnsureReferencesHaveTxDetail ¶
func (h *BasicHandler) EnsureReferencesHaveTxDetail() error
EnsureReferencesHaveTxDetail implements Handler. It ensures each references have a signed push transaction detail.
func (*BasicHandler) GetChange ¶
func (h *BasicHandler) GetChange(ref string) (*remotetypes.ItemChange, error)
GetChange computes and returns the change made to the given reference
func (*BasicHandler) HandleAnnouncement ¶
func (h *BasicHandler) HandleAnnouncement(cb func(errCount int))
HandleAnnouncement announces the repository name, pushed commit and tag objects. cb is called with the number of failed announcements.
func (*BasicHandler) HandleAuthorization ¶
func (h *BasicHandler) HandleAuthorization(ur *packp.ReferenceUpdateRequest) error
HandleAuthorization implements Handler
func (*BasicHandler) HandleGCAndSizeCheck ¶
func (h *BasicHandler) HandleGCAndSizeCheck() error
HandleRepoSize implements Handler. Performs garbage collection and repo size limit check.
func (*BasicHandler) HandlePushNote ¶
func (h *BasicHandler) HandlePushNote(note types.PushNote) (err error)
HandlePushNote implements Handler by handing incoming push note
func (*BasicHandler) HandleRefMismatch ¶
func (h *BasicHandler) HandleRefMismatch(note types.PushNote, ref string, netMismatch bool) (err error)
HandleRefMismatch handles cases where a reference in the push note differs from the hash of its corresponding local or network reference hash. We react by attempting resyncing the reference.
func (*BasicHandler) HandleReference ¶
func (h *BasicHandler) HandleReference(ref string) (errs []error)
HandleReference implements Handler
func (*BasicHandler) HandleReferences ¶
func (h *BasicHandler) HandleReferences() error
HandleReferences implements Handler. It processes pushed references.
func (*BasicHandler) HandleReversion ¶
func (h *BasicHandler) HandleReversion() []error
HandleReversion reverts the pushed references back to their pre-push state. It will do nothing and return nil if already called successfully.
func (*BasicHandler) HandleStream ¶
func (h *BasicHandler) HandleStream(packfile io.Reader, gitReceive io.WriteCloser, gitRcvCmd util.Cmd, pktEnc *pktline.Encoder) error
HandleStream implements Handler. It reads the packfile and pipes it to git.
func (*BasicHandler) HandleUpdate ¶
func (h *BasicHandler) HandleUpdate(targetNote types.PushNote) (err error)
HandleUpdate implements Handler
type HandleAuthorizationFunc ¶
type HandleAuthorizationFunc func(ur *packp.ReferenceUpdateRequest) error
HandleAuthorizationFunc describes a function for checking authorization to access a reference
type HandleReferenceFunc ¶
HandleReferenceFunc describes a function for processing a reference
type Handler ¶
type Handler interface { // HandleStream starts the process of handling a pushed packfile. // // It reads the pushed updates from the packfile, extracts useful // information and writes the update to gitReceive which is the // git-receive-pack process. // // Access the git-receive-pack process using gitReceiveCmd. // // pktEnc provides access to the git output encoder. HandleStream(packfile io.Reader, gitReceive io.WriteCloser, gitRcvCmd util.Cmd, pktEnc *pktline.Encoder) error // EnsureReferencesHaveTxDetail checks that each pushed reference // have a transaction detail that provide more information about // the transaction. EnsureReferencesHaveTxDetail() error // DoAuth performs authorization checks on the specified target reference. // If targetRef is unset, all references are checked. If ignorePostRefs is // true, post references like issue and merge references are not checked. DoAuth(ur *packp.ReferenceUpdateRequest, targetRef string, ignorePostRefs bool) error // HandleAuthorization performs authorization checks on all pushed references. HandleAuthorization(ur *packp.ReferenceUpdateRequest) error // HandleReferences process pushed references. HandleReferences() error // HandleRepoSize performs garbage collection and repo size validation. // // It will return error if repo size exceeds the allowed maximum. // // It will also reload the repository handle since GC makes // go-git internal state stale. HandleGCAndSizeCheck() error // HandleUpdate creates a push note to represent the push operation and // adds it to the push pool and then have it broadcast to peers. HandleUpdate(targetNote types.PushNote) error // HandleReference performs validation and update reversion for a single pushed reference. // // When revertOnly is true, only reversion operation is performed. HandleReference(ref string) []error // HandleReversion reverts the pushed references back to their pre-push state. HandleReversion() []error // HandlePushNote implements Handler by handing incoming push note HandlePushNote(note types.PushNote) (err error) }
Handler describes an interface for handling incoming push updates.
type MakeReferenceUpdateRequestPackFunc ¶
type MakeReferenceUpdateRequestPackFunc func(tx pushtypes.PushNote) (io.ReadSeeker, error)
MakeReferenceUpdateRequestPackFunc describes a function for create git packfile from a push note and a target repository
type ObjectObserver ¶
type ObjectObserver struct { Objects []*PackObject MaxBlobSize int64 // contains filtered or unexported fields }
ObjectObserver implements packfile.Observer. It allows us to read objects of a packfile and also set limitation of blob size.
func (*ObjectObserver) OnHeader ¶
func (o *ObjectObserver) OnHeader(uint32) error
func (*ObjectObserver) OnInflatedObjectContent ¶
func (o *ObjectObserver) OnInflatedObjectContent(h plumbing.Hash, pos int64, crc uint32, content []byte) error
OnInflatedObjectContent implements packfile.Observer.
func (*ObjectObserver) OnInflatedObjectHeader ¶
func (o *ObjectObserver) OnInflatedObjectHeader(t plumbing.ObjectType, objSize int64, pos int64) error
OnInflatedObjectHeader implements packfile.Observer. Returns error if a blob object size surpasses maxBlobSize.
type PackObject ¶
type PackObject struct { Type plumbing.ObjectType Hash plumbing.Hash }
type PackedReferenceObject ¶
PackedReferenceObject represent references added to a pack file
type PackedReferences ¶
type PackedReferences map[string]*PackedReferenceObject
PackedReferences represents a collection of packed references
func (*PackedReferences) ID ¶
func (p *PackedReferences) ID() string
ID returns the ID of the packed references
func (*PackedReferences) Names ¶
func (p *PackedReferences) Names() (refs []string)
Names return the Names of the references
type PushedObjects ¶
type PushedObjects []*PackObject
PushedObjects is a collection of PackObject
func (*PushedObjects) Hashes ¶
func (po *PushedObjects) Hashes() (objs []string)
Hashes returns the string equivalent of the object hashes
type Reader ¶
type Reader struct { References PackedReferences Objects PushedObjects // contains filtered or unexported fields }
PushReader inspects push data from git client, extracting data such as the pushed references, objects and object to reference mapping. It also pipes the pushed stream to a destination (git-receive-pack) when finished.
func NewPushReader ¶
NewPushReader creates an instance of PushReader, and after inspection, the written content will be copied to dst.
func (*Reader) GetSizeObjects ¶
GetSizeObjects returns the size of pushed objects
func (*Reader) GetUpdateRequest ¶
func (r *Reader) GetUpdateRequest() *packp.ReferenceUpdateRequest
GetUpdateRequest returns the reference update request object
func (*Reader) Read ¶
Read reads the packfile, extracting object and reference information and finally writes the read data to a provided destination
func (*Reader) SetUpdateRequest ¶
func (r *Reader) SetUpdateRequest(request *packp.ReferenceUpdateRequest)
SetUpdateRequest sets the reference update request
func (*Reader) UseReferenceUpdateRequestRead ¶
func (r *Reader) UseReferenceUpdateRequestRead(cb func(ur *packp.ReferenceUpdateRequest) error)
UseReferenceUpdateRequestRead sets a callback that is called after the push requested has been decoded but yet to be written to git. If the callback returns an error, the push request is aborted.