1// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later 2 3package spdx_yaml 4 5import ( 6 "io" 7 8 "github.com/spdx/tools-golang/spdx/v2_2" 9 "github.com/spdx/tools-golang/spdx/v2_3" 10 "sigs.k8s.io/yaml" 11) 12 13// Save2_2 takes an SPDX Document (version 2.2) and an io.Writer, and writes the document to the writer in YAML format. 14func Save2_2(doc *v2_2.Document, w io.Writer) error { 15 buf, err := yaml.Marshal(doc) 16 if err != nil { 17 return err 18 } 19 20 _, err = w.Write(buf) 21 if err != nil { 22 return err 23 } 24 25 return nil 26} 27 28// Save2_3 takes an SPDX Document (version 2.3) and an io.Writer, and writes the document to the writer in YAML format. 29func Save2_3(doc *v2_3.Document, w io.Writer) error { 30 buf, err := yaml.Marshal(doc) 31 if err != nil { 32 return err 33 } 34 35 _, err = w.Write(buf) 36 if err != nil { 37 return err 38 } 39 40 return nil 41} 42