Documentation
¶
Index ¶
- Variables
- func CollectAndRegexpCompare(colltor prometheus.Collector, expectRdr io.Reader, metricNames ...string) error
- func RedactUrl(dsnUrl string) string
- func SimpleRegexpLineDiff(regexpLines []string, gotLines []string) string
- func UnrootedPath(pathStr string) string
- type NonRandomReader
- type RandomSecretData
- type RandomSecretSink
- type SafeMapFS
- func (mfs *SafeMapFS) AddMapFile(pathStr string, mapf *fstest.MapFile) error
- func (mfs *SafeMapFS) GetMapFile(pathStr string) (*fstest.MapFile, error)
- func (mfs *SafeMapFS) Glob(pattern string) ([]string, error)
- func (mfs *SafeMapFS) Open(name string) (fs.File, error)
- func (mfs *SafeMapFS) ReadDir(name string) ([]fs.DirEntry, error)
- func (mfs *SafeMapFS) ReadFile(name string) ([]byte, error)
- func (mfs *SafeMapFS) RemoveMapFile(pathStr string) (*fstest.MapFile, error)
- func (mfs *SafeMapFS) Stat(name string) (fs.FileInfo, error)
- func (mfs *SafeMapFS) Sub(dir string) (fs.FS, error)
- func (mfs *SafeMapFS) UpsertMapFile(pathStr string, mapf *fstest.MapFile) error
- type SecretSink
Constants ¶
This section is empty.
Variables ¶
var ( ErrDuplicatePath = errors.New("duplicate path") ErrPathNotFound = errors.New("path not found") )
Functions ¶
func CollectAndRegexpCompare ¶
func CollectAndRegexpCompare(colltor prometheus.Collector, expectRdr io.Reader, metricNames ...string) error
CollectAndRegexpCompare is similar to testutil.CollectAndCompare() but the expected lines are regexp patterns. Note that unlike testutil.CollectAndCompare(), the metricName MUST be specified to get any collected result.
func SimpleRegexpLineDiff ¶
SimpleRegexpLineDiff performs a simple/dumb line-by-line diff between two arrays of lines. The expected array of lines are regexp patterns. Returns line(s) which diff. Empty string is returned if there are no diffs.
func UnrootedPath ¶
Types ¶
type NonRandomReader ¶ added in v1.5.0
NonRandomReader is a reader that returns a deterministic (non-random) sequence of bytes. Intended for testing to supply deterministic "random" values. The sequence of bytes eventually rolls over and repeats itself, so this reader should NOT be used in production code.
func NewNonRandomReader ¶ added in v1.5.0
func NewNonRandomReader(startVal byte) *NonRandomReader
NewNonRandomReader returns a new NonRandomReader. The first byte supplied will be `startVal`.
func (*NonRandomReader) Read ¶ added in v1.5.0
func (nrr *NonRandomReader) Read(buf []byte) (count int, err error)
Read is thread-safe and implements io.Reader interface. Fills buffer with non-random bytes and returns count of filled bytes, which in this case is always the length of the buffer.
Returns byte values in the following deterministic sequence (note that all byte values are modulo 256): 1st set of 256 bytes: [(start)..(start+255)] 2nd set of 256 bytes: [(start+1)..(start+1+255)] 3rd set of 256 bytes: [(start+2)..(start+2+255)] ... 255th set of 256 bytes: [(start+254)..(start+254+255)] 256th set of 256 bytes: [(start+255)..(start+255+255)] 257th set of 256 bytes: [(start)..(start+255)] (rolled over, sequence repeats itself)
Reason for doing this is that uuid consumes 16 bytes on each uuid generation. If we don't shift the sequence after every 256 bytes, than NonRandomReader will only supply enough bytes for 16 unique uuids. If we shift the sequence after every 256 bytes, than NonRandomReader will supply enough bytes for 256 unique uuids before rolling over.
type RandomSecretData ¶ added in v1.5.0
type RandomSecretData struct {
// contains filtered or unexported fields
}
type RandomSecretSink ¶ added in v1.5.0
RandomSecretSink binds a secret value with a random value. The count of secret/random pairs stored is limited. When full, any new secret/random pair added results in deleting the oldest pair. If a secret has already been added previously, a new secret/random pair is not created/added, but its last-used timestamp is updated.
func (*RandomSecretSink) Add ¶ added in v1.5.0
func (rss *RandomSecretSink) Add(actualSecret string) (randomSecret string, err error)
Add is thread-safe and creates/binds a random value with the secret. If secret has already been previously added, then it returns the secret's previously-created random value. The secret/random pair's last-used timestamp is updated. If full, the oldest secret/random pair is deleted.
type SafeMapFS ¶
SafeMapFS is a thread-safe wrapper around fstest.MapFS
func NewSafeMapFS ¶
func NewSafeMapFS() *SafeMapFS
func (*SafeMapFS) AddMapFile ¶
func (*SafeMapFS) GetMapFile ¶
func (*SafeMapFS) RemoveMapFile ¶
type SecretSink ¶ added in v1.5.0
SecretSink returns a
func NewRandomSecretSink ¶ added in v1.5.0
func NewRandomSecretSink(maxCount int) SecretSink
NewRandomSecretSink returns a SecretSink that can hold `maxCount` secret/random pairs.