Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make known type strings const instead of var #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 91 additions & 89 deletions packageurl.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var (
// 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 (
const (
// TypeAlpm is a pkg:alpm purl.
TypeAlpm = "alpm"
// TypeApk is a pkg:apk purl.
Expand Down Expand Up @@ -112,42 +112,44 @@ var (
TypeSWID = "swid"
// TypeSwift is pkg:swift purl
TypeSwift = "swift"
)

// KnownTypes is a map of types that are officially supported by the spec.
// See https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#known-purl-types
KnownTypes = map[string]struct{}{
TypeAlpm: {},
TypeApk: {},
TypeBitbucket: {},
TypeBitnami: {},
TypeCargo: {},
TypeCocoapods: {},
TypeComposer: {},
TypeConan: {},
TypeConda: {},
TypeCran: {},
TypeDebian: {},
TypeDocker: {},
TypeGem: {},
TypeGeneric: {},
TypeGithub: {},
TypeGolang: {},
TypeHackage: {},
TypeHex: {},
TypeHuggingface: {},
TypeMaven: {},
TypeMLFlow: {},
TypeNPM: {},
TypeNuget: {},
TypeOCI: {},
TypePub: {},
TypePyPi: {},
TypeQpkg: {},
TypeRPM: {},
TypeSWID: {},
TypeSwift: {},
}
// KnownTypes is a map of types that are officially supported by the spec.
// See https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#known-purl-types
var KnownTypes = map[string]struct{}{
TypeAlpm: {},
TypeApk: {},
TypeBitbucket: {},
TypeBitnami: {},
TypeCargo: {},
TypeCocoapods: {},
TypeComposer: {},
TypeConan: {},
TypeConda: {},
TypeCran: {},
TypeDebian: {},
TypeDocker: {},
TypeGem: {},
TypeGeneric: {},
TypeGithub: {},
TypeGolang: {},
TypeHackage: {},
TypeHex: {},
TypeHuggingface: {},
TypeMaven: {},
TypeMLFlow: {},
TypeNPM: {},
TypeNuget: {},
TypeOCI: {},
TypePub: {},
TypePyPi: {},
TypeQpkg: {},
TypeRPM: {},
TypeSWID: {},
TypeSwift: {},
}

const (
TypeApache = "apache"
TypeAndroid = "android"
TypeAtom = "atom"
Expand Down Expand Up @@ -196,62 +198,62 @@ var (
TypeVim = "vim"
TypeWORDPRESS = "wordpress"
TypeYocto = "yocto"

// CandidateTypes is a map of types that are not yet officially supported by the spec,
// but are being considered for inclusion.
// See https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#other-candidate-types-to-define
CandidateTypes = map[string]struct{}{
TypeApache: {},
TypeAndroid: {},
TypeAtom: {},
TypeBower: {},
TypeBrew: {},
TypeBuildroot: {},
TypeCarthage: {},
TypeChef: {},
TypeChocolatey: {},
TypeClojars: {},
TypeCoreos: {},
TypeCpan: {},
TypeCtan: {},
TypeCrystal: {},
TypeDrupal: {},
TypeDtype: {},
TypeDub: {},
TypeElm: {},
TypeEclipse: {},
TypeGitea: {},
TypeGitlab: {},
TypeGradle: {},
TypeGuix: {},
TypeHaxe: {},
TypeHelm: {},
TypeJulia: {},
TypeLua: {},
TypeMelpa: {},
TypeMeteor: {},
TypeNim: {},
TypeNix: {},
TypeOpam: {},
TypeOpenwrt: {},
TypeOsgi: {},
TypeP2: {},
TypePear: {},
TypePecl: {},
TypePERL6: {},
TypePlatformio: {},
TypeEbuild: {},
TypePuppet: {},
TypeSourceforge: {},
TypeSublime: {},
TypeTerraform: {},
TypeVagrant: {},
TypeVim: {},
TypeWORDPRESS: {},
TypeYocto: {},
}
)

// CandidateTypes is a map of types that are not yet officially supported by the spec,
// but are being considered for inclusion.
// See https://github.com/package-url/purl-spec/blob/master/PURL-TYPES.rst#other-candidate-types-to-define
var CandidateTypes = map[string]struct{}{
TypeApache: {},
TypeAndroid: {},
TypeAtom: {},
TypeBower: {},
TypeBrew: {},
TypeBuildroot: {},
TypeCarthage: {},
TypeChef: {},
TypeChocolatey: {},
TypeClojars: {},
TypeCoreos: {},
TypeCpan: {},
TypeCtan: {},
TypeCrystal: {},
TypeDrupal: {},
TypeDtype: {},
TypeDub: {},
TypeElm: {},
TypeEclipse: {},
TypeGitea: {},
TypeGitlab: {},
TypeGradle: {},
TypeGuix: {},
TypeHaxe: {},
TypeHelm: {},
TypeJulia: {},
TypeLua: {},
TypeMelpa: {},
TypeMeteor: {},
TypeNim: {},
TypeNix: {},
TypeOpam: {},
TypeOpenwrt: {},
TypeOsgi: {},
TypeP2: {},
TypePear: {},
TypePecl: {},
TypePERL6: {},
TypePlatformio: {},
TypeEbuild: {},
TypePuppet: {},
TypeSourceforge: {},
TypeSublime: {},
TypeTerraform: {},
TypeVagrant: {},
TypeVim: {},
TypeWORDPRESS: {},
TypeYocto: {},
}

// Qualifier represents a single key=value qualifier in the package url
type Qualifier struct {
Key string
Expand Down
Loading