maven

package
v0.17.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var REALM = logging.DefineSubRealm("Maven repository", "maven")

Functions

func HashExt

func HashExt(h crypto.Hash) string

HashExt returns the 'maven' hash extension for the given hash. Maven usually uses sha1, sha256, sha512, md5 instead of SHA-1, SHA-256, SHA-512, MD5.

func IsResource

func IsResource(fileName string) bool

IsResource returns true if the filename is not a checksum or signature file.

Types

type BasicAuthCredentials

type BasicAuthCredentials struct {
	Username string
	Password string
}

func (*BasicAuthCredentials) SetForRequest

func (b *BasicAuthCredentials) SetForRequest(req *http.Request) error

type Body

type Body struct {
	Repo        string            `json:"repo"`
	Path        string            `json:"path"`
	DownloadUri string            `json:"downloadUri"`
	Uri         string            `json:"uri"`
	MimeType    string            `json:"mimeType"`
	Size        string            `json:"size"`
	Checksums   map[string]string `json:"checksums"`
}

Body is the response struct of a deployment from the MVN repository (JFrog Artifactory).

type CoordinateOption

type CoordinateOption = optionutils.Option[*Coordinates]

func WithOptionalClassifier

func WithOptionalClassifier(c *string) CoordinateOption

func WithOptionalExtension

func WithOptionalExtension(e *string) CoordinateOption

func WithOptionalMediaType added in v0.16.0

func WithOptionalMediaType(mt *string) CoordinateOption

type Coordinates

type Coordinates struct {
	PackageCoordinates `json:",inline"`
	FileCoordinates    `json:",inline"`
}

Coordinates holds the typical Maven coordinates groupId, artifactId, version. Optional also classifier and extension. https://maven.apache.org/ref/3.9.6/maven-core/artifact-handlers.html

func NewCoordinates

func NewCoordinates(groupId, artifactId, version string, opts ...CoordinateOption) *Coordinates

func Parse

func Parse(serializedArtifact string) (*Coordinates, error)

Parse creates a Coordinates from its serialized form (see Coordinates.String).

func (*Coordinates) Copy

func (c *Coordinates) Copy() *Coordinates

Copy creates a new Coordinates with the same values.

func (*Coordinates) FileName

func (c *Coordinates) FileName() string

func (*Coordinates) FilePath

func (c *Coordinates) FilePath() string

FilePath returns the Maven Coordinates's GAV-name with classifier and extension. Which is equal to the URL-path of the artifact in the repository. Default extension is jar.

func (*Coordinates) FilterFileMap

func (c *Coordinates) FilterFileMap(fileMap map[string]crypto.Hash) map[string]crypto.Hash

func (*Coordinates) Location

func (c *Coordinates) Location(repo *Repository) *Location

func (*Coordinates) SetClassifierExtensionBy

func (c *Coordinates) SetClassifierExtensionBy(filename string) error

SetClassifierExtensionBy extracts the classifier and extension from the filename (without any path prefix).

func (*Coordinates) String

func (c *Coordinates) String() string

String returns the Coordinates as a string (GroupId:ArtifactId:Version:WithClassifier:WithExtension).

type Credentials

type Credentials interface {
	SetForRequest(req *http.Request) error
}

type FileCoordinates

type FileCoordinates struct {
	// Classifier of the Maven artifact.
	Classifier *string `json:"classifier,omitempty"`
	// Extension of the Maven artifact.
	Extension *string `json:"extension,omitempty"`
	// MediaType of the files.
	MediaType *string `json:"mediaType,omitempty"`
}

func (*FileCoordinates) IsFile

func (c *FileCoordinates) IsFile() bool

IsFile returns true if a dedicated single file is addressed.

func (*FileCoordinates) IsFileSet

func (c *FileCoordinates) IsFileSet() bool

IsFileSet returns true if a file pattern is specified (and therefore, potentially multiple files are addressed).

func (*FileCoordinates) IsPackage

func (c *FileCoordinates) IsPackage() bool

IsPackage returns true if the complete GAV content is addressed.

func (*FileCoordinates) MimeType

func (c *FileCoordinates) MimeType() string

MimeType returns the MIME type of the Maven Coordinates based on the file extension. Default is application/x-tgz.

type FileMeta

type FileMeta struct {
	MimeType string
	HashType crypto.Hash
	Hash     string
	Location *Location
}

type Location

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

func (*Location) AddExtension

func (l *Location) AddExtension(ext string) *Location

func (*Location) AddPath

func (l *Location) AddPath(path string) *Location

func (*Location) GetHash

func (l *Location) GetHash(creds Credentials, hash crypto.Hash) (string, error)

func (*Location) GetReader

func (l *Location) GetReader(creds Credentials, tweakIndexOf ...func(loc *Location, req *http.Request)) (io.ReadCloser, error)

func (*Location) IsFileSystem

func (l *Location) IsFileSystem() bool

func (*Location) MarshalJSON

func (l *Location) MarshalJSON() ([]byte, error)

func (*Location) String

func (l *Location) String() string

type PackageCoordinates

type PackageCoordinates struct {
	// GroupId of the Maven artifact.
	GroupId string `json:"groupId"`
	// ArtifactId of the Maven artifact.
	ArtifactId string `json:"artifactId"`
	// Version of the Maven artifact.
	Version string `json:"version"`
}

func (*PackageCoordinates) FileNamePrefix

func (c *PackageCoordinates) FileNamePrefix() string

func (*PackageCoordinates) GAV

func (c *PackageCoordinates) GAV() string

GAV returns the GAV coordinates of the Maven Coordinates.

func (*PackageCoordinates) GavLocation

func (c *PackageCoordinates) GavLocation(repo *Repository) *Location

func (*PackageCoordinates) GavPath

func (c *PackageCoordinates) GavPath() string

GavPath returns the Maven repository path.

func (*PackageCoordinates) GroupPath

func (c *PackageCoordinates) GroupPath() string

GroupPath returns GroupId with `/` instead of `.`.

func (*PackageCoordinates) Purl

func (c *PackageCoordinates) Purl() string

Purl returns the Package URL of the Maven Coordinates.

func (*PackageCoordinates) String

func (c *PackageCoordinates) String() string

type Repository

type Repository struct {
	Location
}

func NewFileRepository

func NewFileRepository(path string, fss ...vfs.FileSystem) *Repository

func NewUrlRepository

func NewUrlRepository(repoUrl string, fss ...vfs.FileSystem) (*Repository, error)

func (*Repository) Download

func (r *Repository) Download(coords *Coordinates, creds Credentials, enforceVerification ...bool) (io.ReadCloser, error)

func (*Repository) GavFiles

func (r *Repository) GavFiles(coords *Coordinates, creds Credentials) (map[string]crypto.Hash, error)

func (*Repository) GetFileMeta

func (r *Repository) GetFileMeta(c *Coordinates, file string, hash crypto.Hash, creds Credentials) (*FileMeta, error)

func (*Repository) Upload

func (r *Repository) Upload(coords *Coordinates, reader ioutils.DupReadCloser, creds Credentials, hashes iotools.Hashes) (rerr error)

func (*Repository) Url

func (r *Repository) Url() (string, error)

type WithClassifier

type WithClassifier string

func (WithClassifier) ApplyTo

func (o WithClassifier) ApplyTo(c *Coordinates)

type WithExtension

type WithExtension string

func (WithExtension) ApplyTo

func (o WithExtension) ApplyTo(c *Coordinates)

type WithMediaType added in v0.16.0

type WithMediaType string

func (WithMediaType) ApplyTo added in v0.16.0

func (o WithMediaType) ApplyTo(c *Coordinates)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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