Help us shape the future of Go! Take the 2026 Go Developer Survey

notices

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package notices holds the bentoo notices feed contract: the types a notice is carried in, and the parser that turns the site's JSON Feed 1.1 document into them.

The validation here is the subset the tray needs to match packages safely. It is deliberately more lenient than the site, which enforces text lengths and control characters at the producer; notification text is escaped by the notifier anyway, so strings are carried verbatim.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidFeed = errors.New("invalid notices feed")

ErrInvalidFeed is wrapped by every error ParseFeed returns: the document is not a bentoo notices feed, or one of its items breaks the contract.

Functions

func Applies

func Applies(n Notice, installed []pkgdb.Package) bool

Applies reports whether n concerns this system: a news item always applies, since portage already filtered it; a notice with no affects entry applies everywhere; otherwise at least one entry must match a package installed from the bentoo repository.

Types

type Affects

type Affects struct {
	CP, Slot string
	Ranges   []Range
}

Affects names a package a notice is about. Slot is empty when the notice covers every slot; Ranges are ANDed, and an empty list covers every version.

type Feed

type Feed struct {
	Serial  int64
	Expires time.Time
	Items   []Notice
}

Feed is a validated notices feed: its serial, the instant it expires and its notices in document order.

func ParseFeed

func ParseFeed(data []byte) (Feed, error)

ParseFeed decodes and validates a JSON Feed 1.1 document carrying the bentoo _bentoo extension. Every error wraps ErrInvalidFeed; an item that breaks the contract is reported as an *ItemError naming its ID and the failing field. A feed is all or nothing: one bad item rejects the whole document, so the caller keeps its previous notices.

type ItemError

type ItemError struct {
	ID, Field, Reason string
}

ItemError reports an item that breaks the feed contract: ID is the item's id as written (possibly empty or itself the invalid value), Field the failing field's path inside the item (for example "affects[0].ranges[1].ver") and Reason what is wrong with it. It wraps ErrInvalidFeed.

func (*ItemError) Error

func (e *ItemError) Error() string

Error quotes the ID and the field, because both can come from the network.

func (*ItemError) Unwrap

func (e *ItemError) Unwrap() error

Unwrap makes errors.Is(err, ErrInvalidFeed) hold for every item error.

type Notice

type Notice struct {
	ID, Title, Summary, URL, Type, Severity string
	Affects                                 []Affects
	Published, Updated                      time.Time
	Source                                  Source
}

Notice is one validated notice.

func Merge

func Merge(feed []Notice, news []Notice) []Notice

Merge unites the feed and news notices into one notice per ID, sorted by ID. When both sources carry an ID, the feed item wins; a repeated news ID yields one notice.

type Range

type Range struct{ Op, Ver string }

Range is one version bound of an affects entry: Op is one of < <= = >= > and Ver a PMS version.

func ParseAffectsRange

func ParseAffectsRange(op, ver string) (Range, error)

ParseAffectsRange builds a Range from an operator and a version bound. The operator must be one of < <= = >= > and the version a PMS version written without surrounding whitespace: ebuild.CompareVersions sorts an invalid version below every valid one, so an invalid bound would silently match.

type Source

type Source uint8

Source tells where a Notice came from.

const (
	// SourceFeed is a notice read from the site's JSON Feed.
	SourceFeed Source = iota + 1
	// SourceNews is a notice read from the portage news of the bentoo
	// repository, the offline source.
	SourceNews
)

func (Source) String

func (s Source) String() string

String names the source for logs.

Jump to

Keyboard shortcuts

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