aboutsummaryrefslogtreecommitdiff
path: root/builder/builder2v1/build_creation_info.go
diff options
context:
space:
mode:
Diffstat (limited to 'builder/builder2v1/build_creation_info.go')
-rw-r--r--builder/builder2v1/build_creation_info.go42
1 files changed, 13 insertions, 29 deletions
diff --git a/builder/builder2v1/build_creation_info.go b/builder/builder2v1/build_creation_info.go
index 1d8c77f..c838b92 100644
--- a/builder/builder2v1/build_creation_info.go
+++ b/builder/builder2v1/build_creation_info.go
@@ -3,7 +3,6 @@
package builder2v1
import (
- "fmt"
"time"
"github.com/spdx/tools-golang/spdx"
@@ -11,29 +10,21 @@ import (
// BuildCreationInfoSection2_1 creates an SPDX Package (version 2.1), returning that
// package or error if any is encountered. Arguments:
-// - packageName: name of package / directory
-// - code: verification code from Package
-// - namespacePrefix: prefix for DocumentNamespace (packageName and code will be added)
// - creatorType: one of Person, Organization or Tool
// - creator: creator string
// - testValues: for testing only; call with nil when using in production
-func BuildCreationInfoSection2_1(packageName string, code string, namespacePrefix string, creatorType string, creator string, testValues map[string]string) (*spdx.CreationInfo2_1, error) {
+func BuildCreationInfoSection2_1(creatorType string, creator string, testValues map[string]string) (*spdx.CreationInfo2_1, error) {
// build creator slices
- cPersons := []string{}
- cOrganizations := []string{}
- cTools := []string{}
- // add builder as a tool
- cTools = append(cTools, "github.com/spdx/tools-golang/builder")
-
- switch creatorType {
- case "Person":
- cPersons = append(cPersons, creator)
- case "Organization":
- cOrganizations = append(cOrganizations, creator)
- case "Tool":
- cTools = append(cTools, creator)
- default:
- cPersons = append(cPersons, creator)
+ creators := []spdx.Creator{
+ // add builder as a tool
+ {
+ Creator: "github.com/spdx/tools-golang/builder",
+ CreatorType: "Tool",
+ },
+ {
+ Creator: creator,
+ CreatorType: creatorType,
+ },
}
// use test Created time if passing test values
@@ -45,15 +36,8 @@ func BuildCreationInfoSection2_1(packageName string, code string, namespacePrefi
}
ci := &spdx.CreationInfo2_1{
- SPDXVersion: "SPDX-2.1",
- DataLicense: "CC0-1.0",
- SPDXIdentifier: spdx.ElementID("DOCUMENT"),
- DocumentName: packageName,
- DocumentNamespace: fmt.Sprintf("%s%s-%s", namespacePrefix, packageName, code),
- CreatorPersons: cPersons,
- CreatorOrganizations: cOrganizations,
- CreatorTools: cTools,
- Created: created,
+ Creators: creators,
+ Created: created,
}
return ci, nil
}