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 ¶
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 ¶
Types ¶
type Affects ¶
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 ¶
Feed is a validated notices feed: its serial, the instant it expires and its notices in document order.
func ParseFeed ¶
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.
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.
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 ¶
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.