vcs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package vcs implements the remote-only Artifactory VCS archive protocol.

Index

Constants

View Source
const (
	MaxArchiveBytes  = 256 << 20
	MaxExpandedBytes = 1 << 30
	MaxArchiveFiles  = 100000
)
View Source
const (
	MaxRefsBytes = 8 << 20
	MaxRefs      = 65536
)
View Source
const MaxFileZIPBytes = MaxSelectedFileBytes + 1<<20
View Source
const MaxSelectedFileBytes = 64 << 20

Variables

View Source
var ErrInvalidArchive = errors.New("vcs: invalid vcs archive")
View Source
var ErrInvalidPath = errors.New("vcs: invalid vcs path")
View Source
var ErrInvalidRefs = errors.New("vcs: invalid vcs references")

Functions

func ArchiveURL

func ArchiveURL(c repo.Config, owner, name, ref, ext string) (*url.URL, error)

ArchiveURL builds an archive address for a provider's HTTP source. The returned URL remains subject to the configured remote destination policy.

func CustomFileZIP

func CustomFileZIP(ctx context.Context, archive []byte, ext, filename string) ([]byte, error)

CustomFileZIP preserves custom templates that return rootless or wrapped archives. An exact repository path takes precedence; fallback still rejects multiple matching wrapper directories.

func FileZIP

func FileZIP(ctx context.Context, archive []byte, ext, filename string) ([]byte, error)

FileZIP selects one file from an already validated provider archive and returns a ZIP with that file at its repository-relative path.

func GitRefsURL

func GitRefsURL(c repo.Config, owner, name string) (*url.URL, error)

GitRefsURL points at Git smart-HTTP discovery on the configured provider. It does not ask for protocol v2, so a v1 ref advertisement is expected.

func PeerFileURL

func PeerFileURL(c repo.Config, owner, name, kind, ref, filename string) (*url.URL, error)

PeerFileURL addresses the peer's selected-file API. Its reference is mutable; callers must not cache the response as an immutable commit archive.

func ValidCommitID

func ValidCommitID(s string) bool

ValidCommitID accepts the Git SHA-1 and SHA-256 object ID forms.

func ValidExtension

func ValidExtension(ext string) bool

func ValidFilePath

func ValidFilePath(path string) bool

func ValidProject

func ValidProject(owner, name string) bool

ValidProject accepts the provider's owner path and repository name. GitLab owners can contain subgroups; the number of segments is bounded because this path also becomes a source URL and an authorization/cache key.

func ValidRef

func ValidRef(name string) bool

ValidRef is a conservative Git branch/tag name. It rejects syntax that can alter a URL's authority or path meaning when passed to a provider.

func ValidateArchive

func ValidateArchive(ctx context.Context, body io.ReadSeeker, size int64, ext string) error

ValidateArchive checks a complete provider archive before it is admitted to the shared source cache. It leaves the read seeker at an unspecified offset.

func ValidateCommitArchive

func ValidateCommitArchive(
	ctx context.Context,
	body io.ReadSeeker,
	size int64,
	ext, commit string,
) error

ValidateCommitArchive also binds Git archive commit metadata, when present, to the immutable object requested from the provider.

func ValidateFileZIP

func ValidateFileZIP(ctx context.Context, body io.ReadSeeker, size int64, filename string) error

ValidateFileZIP admits only a bounded ZIP containing the exact selected file. A peer response is returned unchanged after validation, without root inference.

func WrappedFileZIP

func WrappedFileZIP(ctx context.Context, archive []byte, ext, filename string) ([]byte, error)

WrappedFileZIP selects a path from providers whose archive contract adds one enclosing directory. Rootless providers must use FileZIP instead.

Types

type Ref

type Ref struct {
	Name     string
	CommitID string
	Branch   bool
}

Ref is a Git branch or tag and the object ID it resolves to. Annotated tags use the peeled object ID when one is advertised.

func ParseRefs

func ParseRefs(data []byte) ([]Ref, error)

ParseRefs accepts the packet-lined Git upload-pack discovery response. This is the data Git providers expose at info/refs?service=git-upload-pack without a Git-Protocol: version=2 request header.

type RefEndpoint

type RefEndpoint struct {
	URL *url.URL
	// contains filtered or unexported fields
}

RefEndpoint binds a provider's discovery URL to its metadata parser.

func RefEndpoints

func RefEndpoints(c repo.Config, owner, name string) ([]RefEndpoint, error)

RefEndpoints uses Git discovery for Git providers and the publisher's documented tag/branch JSON schema for an Artifactory peer.

func (RefEndpoint) Parse

func (e RefEndpoint) Parse(data []byte) ([]Ref, error)

func (RefEndpoint) Variant

func (e RefEndpoint) Variant() string

Jump to

Keyboard shortcuts

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