github.com/leg100/ots@v0.0.7-0.20210919080622-034055ced4bd/parser.go (about) 1 package ots 2 3 import "encoding/json" 4 5 // State represents the schema of terraform state. 6 type State struct { 7 Version int 8 Serial int64 9 Lineage string 10 Outputs map[string]StateOutput 11 } 12 13 // StateOutput represents an output in terraform state. 14 type StateOutput struct { 15 Value string 16 Type string 17 } 18 19 // Parse unmarshals terraform state from a raw byte slice into a State object. 20 func Parse(data []byte) (*State, error) { 21 state := State{} 22 if err := json.Unmarshal(data, &state); err != nil { 23 return nil, err 24 } 25 return &state, nil 26 }