pkgecosystem

package
v0.0.0-...-c4af43d Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package pkgecosystem defines the open source ecosystems supported by Package Analysis.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupported = errors.New("ecosystem unsupported")

ErrUnsupported is returned by Ecosystem.UnmarshalText when bytes that do not correspond to a defined ecosystem constant is passed in as a parameter.

View Source
var SupportedEcosystems = []Ecosystem{
	CratesIO,
	NPM,
	Packagist,
	PyPI,
	RubyGems,
}

SupportedEcosystems is a list of all the ecosystems supported.

View Source
var SupportedEcosystemsStrings = EcosystemsAsStrings(SupportedEcosystems)

SupportedEcosystemsStrings is the list of supported ecosystems represented as strings.

Functions

func EcosystemsAsStrings

func EcosystemsAsStrings(es []Ecosystem) []string

EcosystemsAsStrings converts a slice of Ecosystems to a string slice.

func Unsupported

func Unsupported(name string) error

Unsupported returns a new ErrUnsupported that adds the unsupported ecosystem name to the error message

Types

type Ecosystem

type Ecosystem string

Ecosystem represents an open source package ecosystem from which packages can be downloaded.

It implements encoding.TextUnmarshaler and encoding.TextMarshaler so it can be used with flag.TextVar.

const (
	None      Ecosystem = ""
	CratesIO  Ecosystem = "crates.io"
	NPM       Ecosystem = "npm"
	Packagist Ecosystem = "packagist"
	PyPI      Ecosystem = "pypi"
	RubyGems  Ecosystem = "rubygems"
)

func Parse

func Parse(name string) (Ecosystem, error)

Parse returns an Ecosystem corresponding to the given string name, or the None ecosystem along with an error if there is no matching Ecosystem. If name == "", then the None ecosystem is returned with no error.

func ParsePurlType

func ParsePurlType(purlType string) (Ecosystem, error)

ParsePurlType converts from a Package URL type, defined at https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst to an Ecosystem object

func (Ecosystem) MarshalText

func (e Ecosystem) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (Ecosystem) String

func (e Ecosystem) String() string

String implements the fmt.Stringer interface.

func (*Ecosystem) UnmarshalText

func (e *Ecosystem) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

It will only succeed when unmarshaling ecosytems in SupportedEcosystems or empty.

Jump to

Keyboard shortcuts

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