Documentation
¶
Overview ¶
Package notice is what an app's Overview asks of somebody: a configuration not yet deployed, variables with no value, a backup that was not taken, a security score below the installation's minimum, the pinned spec's warnings (R-412).
Notices are computed every time they are asked for, from what Pando already holds. None is stored: a notice stored when it was raised would still be there after it was fixed. What is stored is a person's choice to ignore one, together with the notice's fingerprint at that moment — so a notice that says something new comes back.
Ignoring hides a reminder and nothing more. Nothing that plans, deploys or gates on a security score reads an ignore: a deploy a notice warned about is refused for the same reason whether or not it was ignored.
Index ¶
- Constants
- func Fingerprint(key string, facts ...string) string
- type Backups
- type Ignores
- type Inputs
- type Notice
- type Revisions
- type Security
- type Service
- func (s *Service) Counts(ctx context.Context, userID string, apps []state.App) (map[string]int, error)
- func (s *Service) Ignore(ctx context.Context, userID string, app state.App, key string) (Notice, error)
- func (s *Service) List(ctx context.Context, userID string, app state.App) ([]Notice, error)
- func (s *Service) Restore(ctx context.Context, userID string, app state.App, key string) error
Constants ¶
const ( KeyUnshipped = "config.unshipped" KeyUnsetVars = "variables.unset" KeyBackup = "backup.not_taken" KeySecurity = "security.below_threshold" WarningPrefix = "warning." )
The notice keys. A spec warning's key is WarningPrefix followed by its code.
Variables ¶
This section is empty.
Functions ¶
func Fingerprint ¶
Fingerprint is a short, stable digest of what a notice says.
Types ¶
type Backups ¶
type Backups interface {
Attempts(ctx context.Context, appID string, limit int) ([]state.BackupAttempt, error)
}
Backups is the app's scheduled backup attempts.
type Ignores ¶
type Ignores interface {
For(ctx context.Context, userID, appID string) (map[string]string, error)
Ignore(ctx context.Context, userID, appID, key, fingerprint string) error
Restore(ctx context.Context, userID, appID, key string) error
}
Ignores is each person's ignored notices.
type Inputs ¶
type Inputs struct {
// Newest is the app's newest revision and Pinned the one it runs, with
// its body. Either may be nil.
Newest *state.Revision
Pinned *state.Revision
// LastBackup is the app's last scheduled backup attempt, if any.
LastBackup *state.BackupAttempt
// Standing is the app's security standing, if the installation has one.
Standing *security.Standing
}
Inputs is what notices are computed from.
type Notice ¶
type Notice struct {
// Key names the kind of notice and its subject, and is stable: the same
// notice has the same key every time it is listed.
Key string `json:"key"`
// Message says what is wrong and what to do about it (R-105).
Message string `json:"message"`
// Fingerprint changes exactly when what the notice says changes. An
// ignore stored against an older fingerprint does not hide it.
Fingerprint string `json:"fingerprint"`
// Ignored is whether the person asking has ignored this notice as it
// reads now. Always false for a caller who is not a person.
Ignored bool `json:"ignored"`
}
Notice is one thing an app's Overview asks of somebody.
type Revisions ¶
type Revisions interface {
ListRevisions(ctx context.Context, appID string) ([]state.Revision, error)
RevisionByID(ctx context.Context, specID string) (state.Revision, bool, error)
}
Revisions is the app's spec revisions.
type Security ¶
type Security interface {
Report(ctx context.Context, appID, specID string) (security.Report, error)
}
Security is where the app stands against the installation's minimum score.
type Service ¶
Service lists an app's notices and keeps each person's ignores.
Backups and Security may be nil, on an installation with neither: their notices are then never raised.
func (*Service) Counts ¶
func (s *Service) Counts(ctx context.Context, userID string, apps []state.App) (map[string]int, error)
Counts is, for each app, how many of its notices the person asking has not ignored — the number the apps list shows beside each app's status (R-412). Each is List's own answer, so the list and the app's Overview cannot disagree. userID is empty for a caller who is not a person, who has ignored nothing.
func (*Service) Ignore ¶
func (s *Service) Ignore(ctx context.Context, userID string, app state.App, key string) (Notice, error)
Ignore hides a notice from one person until what it says changes. It is refused when the app has no such notice now, because there would be nothing to record the fingerprint of.