Skip to content

Commit 3c7fd17

Browse files
authored
Merge pull request #133 from ion-channel/struct-refactor
Overhaul structs, refactor JSON parser and saver
2 parents 94b44ab + 460cf54 commit 3c7fd17

File tree

165 files changed

+5264
-9735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+5264
-9735
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ tools-golang provides the following packages:
2626
* *tvloader* - tag-value document loader
2727
* *tvsaver* - tag-value document saver
2828
* *rdfloader* - RDF document loader
29-
* *jsonloader* - JSON document loader
30-
* *jsonsaver* - JSON document saver
29+
* *json* - JSON document parser and writer
3130
* *builder* - builds "empty" SPDX document (with hashes) for directory contents
3231
* *idsearcher* - searches for [SPDX short-form IDs](https://spdx.org/ids/) and builds SPDX document
3332
* *licensediff* - compares concluded licenses between files in two packages

builder/build.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package builder
66

77
import (
8+
"fmt"
89
"github.com/spdx/tools-golang/builder/builder2v1"
910
"github.com/spdx/tools-golang/builder/builder2v2"
1011
"github.com/spdx/tools-golang/spdx"
@@ -55,7 +56,7 @@ func Build2_1(packageName string, dirRoot string, config *Config2_1) (*spdx.Docu
5556
return nil, err
5657
}
5758

58-
ci, err := builder2v1.BuildCreationInfoSection2_1(packageName, pkg.PackageVerificationCode, config.NamespacePrefix, config.CreatorType, config.Creator, config.TestValues)
59+
ci, err := builder2v1.BuildCreationInfoSection2_1(config.CreatorType, config.Creator, config.TestValues)
5960
if err != nil {
6061
return nil, err
6162
}
@@ -66,9 +67,14 @@ func Build2_1(packageName string, dirRoot string, config *Config2_1) (*spdx.Docu
6667
}
6768

6869
doc := &spdx.Document2_1{
69-
CreationInfo: ci,
70-
Packages: map[spdx.ElementID]*spdx.Package2_1{pkg.PackageSPDXIdentifier: pkg},
71-
Relationships: []*spdx.Relationship2_1{rln},
70+
SPDXVersion: "SPDX-2.1",
71+
DataLicense: "CC0-1.0",
72+
SPDXIdentifier: spdx.ElementID("DOCUMENT"),
73+
DocumentName: packageName,
74+
DocumentNamespace: fmt.Sprintf("%s%s-%s", config.NamespacePrefix, packageName, pkg.PackageVerificationCode),
75+
CreationInfo: ci,
76+
Packages: []*spdx.Package2_1{pkg},
77+
Relationships: []*spdx.Relationship2_1{rln},
7278
}
7379

7480
return doc, nil
@@ -119,7 +125,7 @@ func Build2_2(packageName string, dirRoot string, config *Config2_2) (*spdx.Docu
119125
return nil, err
120126
}
121127

122-
ci, err := builder2v2.BuildCreationInfoSection2_2(packageName, pkg.PackageVerificationCode, config.NamespacePrefix, config.CreatorType, config.Creator, config.TestValues)
128+
ci, err := builder2v2.BuildCreationInfoSection2_2(config.CreatorType, config.Creator, config.TestValues)
123129
if err != nil {
124130
return nil, err
125131
}
@@ -130,9 +136,14 @@ func Build2_2(packageName string, dirRoot string, config *Config2_2) (*spdx.Docu
130136
}
131137

132138
doc := &spdx.Document2_2{
133-
CreationInfo: ci,
134-
Packages: map[spdx.ElementID]*spdx.Package2_2{pkg.PackageSPDXIdentifier: pkg},
135-
Relationships: []*spdx.Relationship2_2{rln},
139+
SPDXVersion: "SPDX-2.2",
140+
DataLicense: "CC0-1.0",
141+
SPDXIdentifier: spdx.ElementID("DOCUMENT"),
142+
DocumentName: packageName,
143+
DocumentNamespace: fmt.Sprintf("%s%s-%s", config.NamespacePrefix, packageName, pkg.PackageVerificationCode),
144+
CreationInfo: ci,
145+
Packages: []*spdx.Package2_2{pkg},
146+
Relationships: []*spdx.Relationship2_2{rln},
136147
}
137148

138149
return doc, nil

0 commit comments

Comments
 (0)