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

refactor(purl): use pub from package-url #5784

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions pkg/purl/purl.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import (
)

const (
TypeOCI = "oci"
TypeDart = "dart"
TypeOCI = "oci"

// TypeK8s is a custom type for Kubernetes components in PURL.
// - namespace: The service provider such as EKS or GKE. It is not case sensitive and must be lowercased.
Expand Down Expand Up @@ -141,7 +140,7 @@ func (p *PackageURL) LangType() ftypes.LangType {
return ftypes.Hex
case packageurl.TypeConan:
return ftypes.Conan
case TypeDart: // TODO: replace with packageurl.TypeDart once they add it.
case packageurl.TypePub:
return ftypes.Pub
case packageurl.TypeBitnami:
return ftypes.Bitnami
Expand Down Expand Up @@ -432,7 +431,7 @@ func purlType(t ftypes.TargetType) string {
case ftypes.Conan:
return packageurl.TypeConan
case ftypes.Pub:
return TypeDart // TODO: replace with packageurl.TypeDart once they add it.
return packageurl.TypePub
case ftypes.RustBinary, ftypes.Cargo:
return packageurl.TypeCargo
case ftypes.Alpine:
Expand Down
6 changes: 3 additions & 3 deletions pkg/purl/purl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestNewPackageURL(t *testing.T) {
},
want: &purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: purl.TypeDart,
Type: packageurl.TypePub,
Name: "http",
Version: "0.13.2",
},
Expand Down Expand Up @@ -512,10 +512,10 @@ func TestFromString(t *testing.T) {
},
{
name: "happy path for dart",
purl: "pkg:dart/http@0.13.2",
purl: "pkg:pub/http@0.13.2",
want: purl.PackageURL{
PackageURL: packageurl.PackageURL{
Type: purl.TypeDart,
Type: packageurl.TypePub,
Name: "http",
Version: "0.13.2",
Qualifiers: packageurl.Qualifiers{},
Expand Down