diff options
author | Ian Ling <ian@iancaling.com> | 2022-04-08 08:52:57 -0700 |
---|---|---|
committer | Ian Ling <ian@iancaling.com> | 2022-04-25 15:00:47 -0700 |
commit | 460cf54ece7eba418c50407ee35544c5d63588a7 (patch) | |
tree | 07ec7aaf51a92a1ae209e540f45241f990561919 /tvsaver/saver2v1/save_creation_info.go | |
parent | fa24fac85dd550a3f815896241081a1246810d2c (diff) | |
download | spdx-tools-460cf54ece7eba418c50407ee35544c5d63588a7.tar.gz |
Overhaul structs, refactor JSON parser and saver
Signed-off-by: Ian Ling <ian@iancaling.com>
Diffstat (limited to 'tvsaver/saver2v1/save_creation_info.go')
-rw-r--r-- | tvsaver/saver2v1/save_creation_info.go | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/tvsaver/saver2v1/save_creation_info.go b/tvsaver/saver2v1/save_creation_info.go index 6ea6086..de8b107 100644 --- a/tvsaver/saver2v1/save_creation_info.go +++ b/tvsaver/saver2v1/save_creation_info.go @@ -4,50 +4,16 @@ package saver2v1 import ( "fmt" - "io" - "sort" - "github.com/spdx/tools-golang/spdx" + "io" ) func renderCreationInfo2_1(ci *spdx.CreationInfo2_1, w io.Writer) error { - if ci.SPDXVersion != "" { - fmt.Fprintf(w, "SPDXVersion: %s\n", ci.SPDXVersion) - } - if ci.DataLicense != "" { - fmt.Fprintf(w, "DataLicense: %s\n", ci.DataLicense) - } - if ci.SPDXIdentifier != "" { - fmt.Fprintf(w, "SPDXID: %s\n", spdx.RenderElementID(ci.SPDXIdentifier)) - } - if ci.DocumentName != "" { - fmt.Fprintf(w, "DocumentName: %s\n", ci.DocumentName) - } - if ci.DocumentNamespace != "" { - fmt.Fprintf(w, "DocumentNamespace: %s\n", ci.DocumentNamespace) - } - // print EDRs in order sorted by identifier - edrIDs := []string{} - for docRefID := range ci.ExternalDocumentReferences { - edrIDs = append(edrIDs, docRefID) - } - sort.Strings(edrIDs) - for _, edrID := range edrIDs { - edr := ci.ExternalDocumentReferences[edrID] - fmt.Fprintf(w, "ExternalDocumentRef: DocumentRef-%s %s %s:%s\n", - edr.DocumentRefID, edr.URI, edr.Alg, edr.Checksum) - } if ci.LicenseListVersion != "" { fmt.Fprintf(w, "LicenseListVersion: %s\n", ci.LicenseListVersion) } - for _, s := range ci.CreatorPersons { - fmt.Fprintf(w, "Creator: Person: %s\n", s) - } - for _, s := range ci.CreatorOrganizations { - fmt.Fprintf(w, "Creator: Organization: %s\n", s) - } - for _, s := range ci.CreatorTools { - fmt.Fprintf(w, "Creator: Tool: %s\n", s) + for _, creator := range ci.Creators { + fmt.Fprintf(w, "Creator: %s: %s\n", creator.CreatorType, creator.Creator) } if ci.Created != "" { fmt.Fprintf(w, "Created: %s\n", ci.Created) @@ -55,9 +21,6 @@ func renderCreationInfo2_1(ci *spdx.CreationInfo2_1, w io.Writer) error { if ci.CreatorComment != "" { fmt.Fprintf(w, "CreatorComment: %s\n", textify(ci.CreatorComment)) } - if ci.DocumentComment != "" { - fmt.Fprintf(w, "DocumentComment: %s\n", textify(ci.DocumentComment)) - } // add blank newline b/c end of a main section fmt.Fprintf(w, "\n") |