Documentation
¶
Index ¶
- Constants
- func ChangeList(changes []string, bullet string, maxLength int) string
- func DescribeChanges(before, after flag.Flag) ([]string, error)
- func DescribeChangesPlain(before, after flag.Flag) ([]string, error)
- func ReadableValue(value any) string
- func UpdatedBy(f flag.Flag) string
- func UpdatedBySuffix(f flag.Flag) string
- type DiffCache
- type DiffUpdated
- type FieldChange
- type Notifier
Constants ¶
ChangesUnavailable labels a notification entry for an update whose changes could not be computed.
const MaxListedChanges = 50
MaxListedChanges is the number of changes ChangeList shows for one flag.
const UpdatedByMetadataKey = "updatedBy"
UpdatedByMetadataKey is the metadata key an external flag editor may set to who last changed a flag.
Variables ¶
This section is empty.
Functions ¶
func ChangeList ¶
ChangeList renders changes one per line, each starting with bullet. It shows at most MaxListedChanges changes and, when maxLength is above zero, stays within maxLength characters. A last line counts the changes left out, and the list is empty when not even that line fits.
func DescribeChanges ¶
DescribeChanges returns one sentence per change between two versions of a flag, in the order the fields appear in a flag file. Names and values are formatted as markdown inline code. It describes every field of flag.InternalFlag and returns an error for any other flag type.
func DescribeChangesPlain ¶
DescribeChangesPlain is DescribeChanges without inline code, for destinations that cannot display it.
func ReadableValue ¶
ReadableValue renders a value for humans: JSON for anything JSON can encode, so pointers and time internals are not shown, and Go syntax otherwise. Characters such as "<" and "&" are kept as typed, not escaped for HTML.
func UpdatedBy ¶
UpdatedBy returns the updatedBy metadata of a *flag.InternalFlag, or "" when it is missing, empty or not a string.
func UpdatedBySuffix ¶
UpdatedBySuffix returns " by <name>" for a flag title when the flag says who changed it, and "" otherwise.
Types ¶
type DiffCache ¶
type DiffCache struct {
Deleted map[string]flag.Flag `json:"deleted"`
Added map[string]flag.Flag `json:"added"`
Updated map[string]DiffUpdated `json:"updated"`
}
DiffCache contains the changes made in the cache, to be able to notify the user that something has changed (logs, webhook ...)
type DiffUpdated ¶
type FieldChange ¶
type FieldChange struct {
// Path is the dot-separated path of the field that changed.
Path string
// From is the readable value before the change, "null" if the field did not exist.
From string
// To is the readable value after the change, "null" if the field was removed.
To string
}
FieldChange is a single field that changed in a flag, ready to be displayed in a notification.
func FlagChanges ¶
func FlagChanges(before, after any) ([]FieldChange, error)
FlagChanges returns every field that changed between two versions of a flag, sorted by path, including fields that were added or removed.