diff options
author | Brandon Lum <lumjjb@gmail.com> | 2022-07-19 16:43:48 -0400 |
---|---|---|
committer | Brandon Lum <lumjjb@gmail.com> | 2022-07-19 22:43:24 -0400 |
commit | 9ae1bd2f8e0dabb0845f1225b54f23e8f3a429f1 (patch) | |
tree | a43213aadfb9bde3d9ec15634a39305f19ff38b2 /spdxlib/described_elements.go | |
parent | 41d2272711255f5a25e16e3507ec3318bc550189 (diff) | |
download | spdx-tools-9ae1bd2f8e0dabb0845f1225b54f23e8f3a429f1.tar.gz |
replace all v2_1, v2_2 with new convention
Signed-off-by: Brandon Lum <lumjjb@gmail.com>
Diffstat (limited to 'spdxlib/described_elements.go')
-rw-r--r-- | spdxlib/described_elements.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/spdxlib/described_elements.go b/spdxlib/described_elements.go index 21d8e7e..61833b4 100644 --- a/spdxlib/described_elements.go +++ b/spdxlib/described_elements.go @@ -5,7 +5,10 @@ package spdxlib import ( "fmt" - "github.com/spdx/tools-golang/spdx" + + "github.com/spdx/tools-golang/spdx/common" + "github.com/spdx/tools-golang/spdx/v2_1" + "github.com/spdx/tools-golang/spdx/v2_2" ) // GetDescribedPackageIDs2_1 returns a slice of ElementIDs for all Packages @@ -13,7 +16,7 @@ import ( // - If the document has only one Package, its ID is returned. // - If the document has 2+ Packages, it returns the IDs of those that have // a DESCRIBES (or DESCRIBED_BY) relationship to this DOCUMENT. -func GetDescribedPackageIDs2_1(doc *spdx.Document2_1) ([]spdx.ElementID, error) { +func GetDescribedPackageIDs2_1(doc *v2_1.Document) ([]common.ElementID, error) { // if nil Packages map or zero packages in it, return empty slice if doc.Packages == nil { return nil, fmt.Errorf("Packages map is nil") @@ -24,7 +27,7 @@ func GetDescribedPackageIDs2_1(doc *spdx.Document2_1) ([]spdx.ElementID, error) if len(doc.Packages) == 1 { // get first (only) one and return its ID for _, pkg := range doc.Packages { - return []spdx.ElementID{pkg.PackageSPDXIdentifier}, nil + return []common.ElementID{pkg.PackageSPDXIdentifier}, nil } } @@ -35,8 +38,8 @@ func GetDescribedPackageIDs2_1(doc *spdx.Document2_1) ([]spdx.ElementID, error) return nil, fmt.Errorf("multiple Packages in Document but Relationships slice is nil") } - eIDs, err := FilterRelationships2_1(doc, func(relationship *spdx.Relationship2_1) *spdx.ElementID { - refDocument := spdx.MakeDocElementID("", "DOCUMENT") + eIDs, err := FilterRelationships2_1(doc, func(relationship *v2_1.Relationship) *common.ElementID { + refDocument := common.MakeDocElementID("", "DOCUMENT") if relationship.Relationship == "DESCRIBES" && relationship.RefA == refDocument { return &relationship.RefB.ElementRefID @@ -64,7 +67,7 @@ func GetDescribedPackageIDs2_1(doc *spdx.Document2_1) ([]spdx.ElementID, error) // - If the document has only one Package, its ID is returned. // - If the document has 2+ Packages, it returns the IDs of those that have // a DESCRIBES (or DESCRIBED_BY) relationship to this DOCUMENT. -func GetDescribedPackageIDs2_2(doc *spdx.Document2_2) ([]spdx.ElementID, error) { +func GetDescribedPackageIDs2_2(doc *v2_2.Document) ([]common.ElementID, error) { // if nil Packages map or zero packages in it, return empty slice if doc.Packages == nil { return nil, fmt.Errorf("Packages map is nil") @@ -75,7 +78,7 @@ func GetDescribedPackageIDs2_2(doc *spdx.Document2_2) ([]spdx.ElementID, error) if len(doc.Packages) == 1 { // get first (only) one and return its ID for _, pkg := range doc.Packages { - return []spdx.ElementID{pkg.PackageSPDXIdentifier}, nil + return []common.ElementID{pkg.PackageSPDXIdentifier}, nil } } @@ -86,8 +89,8 @@ func GetDescribedPackageIDs2_2(doc *spdx.Document2_2) ([]spdx.ElementID, error) return nil, fmt.Errorf("multiple Packages in Document but Relationships slice is nil") } - eIDs, err := FilterRelationships2_2(doc, func(relationship *spdx.Relationship2_2) *spdx.ElementID { - refDocument := spdx.MakeDocElementID("", "DOCUMENT") + eIDs, err := FilterRelationships2_2(doc, func(relationship *v2_2.Relationship) *common.ElementID { + refDocument := common.MakeDocElementID("", "DOCUMENT") if relationship.Relationship == "DESCRIBES" && relationship.RefA == refDocument { return &relationship.RefB.ElementRefID |