aboutsummaryrefslogtreecommitdiff
path: root/tvsaver/saver2v1/save_creation_info.go
blob: 15929232871787f5a0f338377e42468c1b2fd36f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later

package saver2v1

import (
	"fmt"
	"io"

	"github.com/spdx/tools-golang/spdx"
)

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", ci.SPDXIdentifier)
	}
	if ci.DocumentName != "" {
		fmt.Fprintf(w, "DocumentName: %s\n", ci.DocumentName)
	}
	if ci.DocumentNamespace != "" {
		fmt.Fprintf(w, "DocumentNamespace: %s\n", ci.DocumentNamespace)
	}
	for _, s := range ci.ExternalDocumentReferences {
		fmt.Fprintf(w, "ExternalDocumentRef: %s\n", s)
	}
	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)
	}
	if ci.Created != "" {
		fmt.Fprintf(w, "Created: %s\n", ci.Created)
	}
	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")

	return nil
}