package packageurl
import "github.com/package-url/packageurl-go"
Package packageurl implements the package-url spec
Index ¶
- Variables
- type PackageURL
- func FromString(purl string) (PackageURL, error)
- func NewPackageURL(purlType, namespace, name, version string, qualifiers Qualifiers, subpath string) *PackageURL
- func (p PackageURL) String() string
- func (p *PackageURL) ToString() string
- type Qualifier
- type Qualifiers
Variables ¶
var ( // TypeBitbucket is a pkg:bitbucket purl. TypeBitbucket = "bitbucket" // TypeCocoapods is a pkg:cocoapods purl. TypeCocoapods = "cocoapods" // TypeCargo is a pkg:cargo purl. TypeCargo = "cargo" // TypeComposer is a pkg:composer purl. TypeComposer = "composer" // TypeConan is a pkg:conan purl. TypeConan = "conan" // TypeConda is a pkg:conda purl. TypeConda = "conda" // TypeCran is a pkg:cran purl. TypeCran = "cran" // TypeDebian is a pkg:deb purl. TypeDebian = "deb" // TypeDocker is a pkg:docker purl. TypeDocker = "docker" // TypeGem is a pkg:gem purl. TypeGem = "gem" // TypeGeneric is a pkg:generic purl. TypeGeneric = "generic" // TypeGithub is a pkg:github purl. TypeGithub = "github" // TypeGolang is a pkg:golang purl. TypeGolang = "golang" // TypeHackage is a pkg:hackage purl. TypeHackage = "hackage" // TypeHex is a pkg:hex purl. TypeHex = "hex" // TypeMaven is a pkg:maven purl. TypeMaven = "maven" // TypeNPM is a pkg:npm purl. TypeNPM = "npm" // TypeNuget is a pkg:nuget purl. TypeNuget = "nuget" // TypeOCI is a pkg:oci purl TypeOCI = "oci" // TypePyPi is a pkg:pypi purl. TypePyPi = "pypi" // TypeRPM is a pkg:rpm purl. TypeRPM = "rpm" // TypeSwift is pkg:swift purl TypeSwift = "swift" // TypeHuggingface is pkg:huggingface purl. TypeHuggingface = "huggingface" // TypeMLflow is pkg:mlflow purl. TypeMLFlow = "mlflow" )
These are the known purl types as defined in the spec. Some of these require special treatment during parsing. https://github.com/package-url/purl-spec#known-purl-types
var ( // QualifierKeyPattern describes a valid qualifier key: // // - The key must be composed only of ASCII letters and numbers, '.', // '-' and '_' (period, dash and underscore). // - A key cannot start with a number. QualifierKeyPattern = regexp.MustCompile(`^[A-Za-z\.\-_][0-9A-Za-z\.\-_]*$`) )
Types ¶
type PackageURL ¶
type PackageURL struct { Type string Namespace string Name string Version string Qualifiers Qualifiers Subpath string }
PackageURL is the struct representation of the parts that make a package url
func FromString ¶
func FromString(purl string) (PackageURL, error)
FromString parses a valid package url string into a PackageURL structure
func NewPackageURL ¶
func NewPackageURL(purlType, namespace, name, version string, qualifiers Qualifiers, subpath string) *PackageURL
NewPackageURL creates a new PackageURL struct instance based on input
func (PackageURL) String ¶
func (p PackageURL) String() string
func (*PackageURL) ToString ¶
func (p *PackageURL) ToString() string
ToString returns the human-readable instance of the PackageURL structure. This is the literal purl as defined by the spec.
type Qualifier ¶
Qualifier represents a single key=value qualifier in the package url
func (Qualifier) String ¶
type Qualifiers ¶
type Qualifiers []Qualifier
Qualifiers is a slice of key=value pairs, with order preserved as it appears in the package URL.
func QualifiersFromMap ¶
func QualifiersFromMap(mm map[string]string) Qualifiers
QualifiersFromMap constructs a Qualifiers slice from a string map. To get a deterministic qualifier order (despite maps not providing any iteration order guarantees) the returned Qualifiers are sorted in increasing order of key.
func (Qualifiers) Map ¶
func (qq Qualifiers) Map() map[string]string
Map converts a Qualifiers struct to a string map.
func (Qualifiers) String ¶
func (qq Qualifiers) String() string
Source Files ¶
- Version
- v0.1.1
- Published
- Jun 19, 2023
- Platform
- windows/amd64
- Imports
- 6 packages
- Last checked
- 3 weeks ago –
Tools for package owners.