notifier

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const ChangesUnavailable = "Changes could not be computed"

ChangesUnavailable labels a notification entry for an update whose changes could not be computed.

View Source
const MaxListedChanges = 50

MaxListedChanges is the number of changes ChangeList shows for one flag.

View Source
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

func ChangeList(changes []string, bullet string, maxLength int) string

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

func DescribeChanges(before, after flag.Flag) ([]string, error)

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

func DescribeChangesPlain(before, after flag.Flag) ([]string, error)

DescribeChangesPlain is DescribeChanges without inline code, for destinations that cannot display it.

func ReadableValue

func ReadableValue(value any) string

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

func UpdatedBy(f flag.Flag) string

UpdatedBy returns the updatedBy metadata of a *flag.InternalFlag, or "" when it is missing, empty or not a string.

func UpdatedBySuffix

func UpdatedBySuffix(f flag.Flag) string

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 ...)

func (*DiffCache) HasDiff

func (d *DiffCache) HasDiff() bool

HasDiff check if we have differences.

type DiffUpdated

type DiffUpdated struct {
	Before flag.Flag `json:"old_value"`
	After  flag.Flag `json:"new_value"`
}

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.

type Notifier

type Notifier interface {
	// Notify is the function doing all the work when a Notifier is called.
	Notify(cache DiffCache) error
}

Notifier is the interface to represent a Semaphore notifier.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL