github.com/eliastor/durgaform@v0.0.0-20220816172711-d0ab2d17673e/internal/states/statefile/write.go (about) 1 package statefile 2 3 import ( 4 "io" 5 6 tfversion "github.com/eliastor/durgaform/version" 7 ) 8 9 // Write writes the given state to the given writer in the current state 10 // serialization format. 11 func Write(s *File, w io.Writer) error { 12 // Always record the current durgaform version in the state. 13 s.DurgaformVersion = tfversion.SemVer 14 15 diags := writeStateV4(s, w) 16 return diags.Err() 17 } 18 19 // WriteForTest writes the given state to the given writer in the current state 20 // serialization format without recording the current durgaform version. This is 21 // intended for use in tests that need to override the current durgaform 22 // version. 23 func WriteForTest(s *File, w io.Writer) error { 24 diags := writeStateV4(s, w) 25 return diags.Err() 26 }