Documentation ¶
Overview ¶
Package statefile defines the state file data stream.
This package currently does not include any details regarding the state encoding itself, only details regarding state metadata and data layout.
The file format is defined as follows.
/------------------------------------------------------\ | header (8-bytes) | +------------------------------------------------------+ | metadata length (8-bytes) | +------------------------------------------------------+ | metadata | +------------------------------------------------------+ | data | \------------------------------------------------------/
First, it includes a 8-byte magic header which is the following sequence of bytes [0x67, 0x56, 0x69, 0x73, 0x6f, 0x72, 0x53, 0x46]
This header is followed by an 8-byte length N (big endian), and an ASCII-encoded JSON map that is exactly N bytes long.
This map includes only strings for keys and strings for values. Keys in the map that begin with "_" are for internal use only. They may be read, but may not be provided by the user. In the future, this metadata may contain some information relating to the state encoding itself.
After the map, the remainder of the file is the state data.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadMagic = fmt.Errorf("bad magic header")
ErrBadMagic is returned if the header does not match.
var ErrInvalidMetadataLength = fmt.Errorf("metadata length invalid, maximum size is %d", maxMetadataSize)
ErrInvalidMetadataLength is returned if the metadata length is too large.
var ErrMetadataInvalid = fmt.Errorf("metadata invalid, can't start with _")
ErrMetadataInvalid is returned if passed metadata is invalid.
var ErrMetadataMissing = fmt.Errorf("missing metadata")
ErrMetadataMissing is returned if the state file is missing mandatory metadata.
Functions ¶
func MetadataUnsafe ¶
MetadataUnsafe reads out the metadata from a state file without verifying any HMAC. This function shouldn't be called for untrusted input files.
Types ¶
type WriteCloser ¶
WriteCloser is an io.Closer and wire.Writer.