diff options
author | Keith Zantow <kzantow@gmail.com> | 2022-10-07 12:11:31 -0400 |
---|---|---|
committer | Keith Zantow <kzantow@gmail.com> | 2022-10-07 12:11:31 -0400 |
commit | 066a798c363d64d11c5831c11c0aff4ce3eb286e (patch) | |
tree | b9a44b68b630f5197a5ccb4d787da15bc34364b9 | |
parent | edca4e815e896fe3f9a42befac2870ca97997cef (diff) | |
download | spdx-tools-066a798c363d64d11c5831c11c0aff4ce3eb286e.tar.gz |
chore: missed YAML writer for v2.3 data model
Signed-off-by: Keith Zantow <kzantow@gmail.com>
-rw-r--r-- | yaml/writer.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/yaml/writer.go b/yaml/writer.go index cbc6508..06ef69a 100644 --- a/yaml/writer.go +++ b/yaml/writer.go @@ -6,6 +6,7 @@ import ( "io" "github.com/spdx/tools-golang/spdx/v2_2" + "github.com/spdx/tools-golang/spdx/v2_3" "sigs.k8s.io/yaml" ) @@ -23,3 +24,18 @@ func Save2_2(doc *v2_2.Document, w io.Writer) error { return nil } + +// Save2_3 takes an SPDX Document (version 2.3) and an io.Writer, and writes the document to the writer in YAML format. +func Save2_3(doc *v2_3.Document, w io.Writer) error { + buf, err := yaml.Marshal(doc) + if err != nil { + return err + } + + _, err = w.Write(buf) + if err != nil { + return err + } + + return nil +} |