The scanner can be used to read any BSR data file. When creating a new scanner, it will first verify the BSR magic string. Individual Chunks can then be read back by calling Scan. The scanner will compute a sha256sum while it is reading chunks. If the scanner was created using the WithSha256Sum option, it will compare the computed checksum with the one provided via the option once the scanner encounters an end chunk (DONE) or an io.EOF error from the reader. If the checksums do not match, and error will be returned from Scan. The current sha256sum can be returned from the scanner using the Sum method. There is also a convenience function, ChunkWalk that can be used to call a function on each Chunk returned by a scanner.
42 lines
1.4 KiB
Go
42 lines
1.4 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package bsr
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
var (
|
|
// ErrUnknown represents an unknown error
|
|
ErrUnknown = errors.New("unknown error")
|
|
|
|
// ErrInvalidParameter represents an invalid parameter error
|
|
ErrInvalidParameter = errors.New("invalid parameter")
|
|
|
|
// ErrBsrKeyPersistenceFailure indicates a failure in persisting BSR encryption keys
|
|
ErrBsrKeyPersistenceFailure = errors.New("could not persist BSR keys")
|
|
|
|
// ErrSummaryUnavailable indicates a BSR summary is unavailable
|
|
ErrSummaryUnavailable = errors.New("summary not available")
|
|
|
|
// ErrNotSupported represents an operation that is not supported for a
|
|
// particular protocol.
|
|
ErrNotSupported = errors.New("not supported by protocol")
|
|
|
|
// ErrAlreadyRegistered is an error with registering chunk decoder functions.
|
|
ErrAlreadyRegistered = errors.New("chunk type already registered")
|
|
|
|
// ErrEndChunkNotEmpty indicates a malformed END chunk.
|
|
ErrEndChunkNotEmpty = errors.New("end chunk not empty")
|
|
|
|
// ErrChunkDecode indicates an error when decoding a chunk.
|
|
ErrChunkDecode = errors.New("error decoding chunk")
|
|
|
|
// ErrInvalidMagic is used when a binary bsr file is missing the magic string.
|
|
ErrInvalidMagic = errors.New("invalid magic string")
|
|
|
|
// ErrChecksum indicates that a checksum did not match.
|
|
ErrChecksum = errors.New("computed checksum did NOT match")
|
|
)
|