maven

package
v0.0.0-...-877fc11 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 28 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

type Coordinates

type Coordinates 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"`
	// Classifier of the Maven artifact.
	Classifier *string `json:"classifier,omitempty"`
	// Extension of the Maven artifact.
	Extension *string `json:"extension,omitempty"`
}

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 it's 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) FileNamePrefix

func (c *Coordinates) FileNamePrefix() 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) GAV

func (c *Coordinates) GAV() string

GAV returns the GAV coordinates of the Maven Coordinates.

func (*Coordinates) GavLocation

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

func (*Coordinates) GavPath

func (c *Coordinates) GavPath() string

GavPath returns the Maven repository path.

func (*Coordinates) GroupPath

func (c *Coordinates) GroupPath() string

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

func (*Coordinates) Location

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

func (*Coordinates) MimeType

func (c *Coordinates) MimeType() string

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

func (*Coordinates) Purl

func (c *Coordinates) Purl() string

Purl returns the Package URL of the Maven Coordinates.

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 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) (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 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 io.ReadCloser, 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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