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

notice

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

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

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

func Fingerprint(key string, facts ...string) string

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.

func Compute

func Compute(in Inputs) []Notice

Compute is an app's notices, in the order the Overview lists them.

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

type Service struct {
	Revisions Revisions
	Backups   Backups
	Security  Security
	Ignores   Ignores
}

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.

func (*Service) List

func (s *Service) List(ctx context.Context, userID string, app state.App) ([]Notice, error)

List returns every current notice on an app, each marked with whether the person asking has ignored it. userID is empty for a caller who is not a person, who sees every notice unignored.

func (*Service) Restore

func (s *Service) Restore(ctx context.Context, userID string, app state.App, key string) error

Restore shows a notice to one person again. Restoring a notice that is not ignored, or that no longer exists, is not an error.

Jump to

Keyboard shortcuts

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