Documentation
¶
Overview ¶
Package flagcheck validates the bytes of a flag object with the engine of the relay: the same decoder and the same validity checks the relay applies when it loads a flag file, and that "semaphore-cli lint" applies.
The check is what the relay would do, so a flag that passes here is not dropped at load time. Besides the structural rules of controlplane.ValidateFlags it compiles the targeting queries, checks the percentages, the variations and the rollouts, as the engine does.
The package imports the engine, which is heavy. It is separate from controlplane on purpose: a program that only needs the document format does not pull it in.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("flagcheck: invalid flag file")
ErrInvalid is matched (errors.Is) by every *Error, and by the failure to decode the file.
Functions ¶
Types ¶
type Decoded ¶ added in v1.3.0
type Decoded struct {
// contains filtered or unexported fields
}
Decoded is a flag file decoded with the loader of the relay, from a tree that was read once, and not yet checked.
func DecodeTree ¶ added in v1.3.0
func DecodeTree(tree *controlplane.FlagsTree, entries []controlplane.FlagEntry) (*Decoded, error)
DecodeTree decodes the flags of a tree, as Check decodes the file, a chunk of flags at a time (see controlplane.FlagsTree.DecodeEntries): the time grows with the number of flags. entries are the ones that controlplane.FlagsTree.Entries listed. The error is not meant to be shown: a caller that needs the text of the refusal calls Check. Call it before any other read of the tree that rewrites its nodes.
type Error ¶
type Error struct {
Problems []FlagProblem
}
Error lists the flags that the engine rejects, sorted by flag key.
type FlagProblem ¶
type FlagProblem struct {
// Err is the reason given by the engine, as it is: it may quote the file (a query, a value), so do not log it
// where an API key matters. Error() of the *Error does not carry that text.
Err error
// Flag is the key of the flag.
Flag string
}
FlagProblem is one flag that the engine rejects.
func (FlagProblem) Message ¶
func (p FlagProblem) Message() string
Message is the text for one problem: "flag <key>: <category>". It is safe to print and to log: the key, and the category of the engine's reason, never the text of the engine (see Err).