updatepackages

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 8 Imported by: 0 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

Overview

Package updatepackages is the updates behavior: the updates that the package index has for the host.

Index

Constants

This section is empty.

Variables

View Source
var Behavior = behavior.Register(behavior.Define(
	"updates", "The updates the package index has for the host",
	behavior.Title("Package updates"),
	behavior.Node,
	behavior.Under(packages.Behavior),
	behavior.API,
	behavior.Area(area.Software),
	behavior.CLI,
	behavior.Platform(behavior.PlatformDebian, newDebian),
	behavior.Read("list", List).
		NotAFact("the updates are what the repositories of the package index have, not a fact of the host").
		Runs("apt").
		Describe("List the packages the index has newer versions of").
		Explain("Runs apt list --upgradable: each package with its installed "+
			"version and the version the index has. Refresh the index first for "+
			"what the repositories have now.").
		Example("Two updates", ListInput{}, []Available{
			{Name: "curl", CurrentVersion: "8.5.0-2ubuntu10", NewVersion: "8.5.0-2ubuntu10.1"},
			{Name: "openssl", CurrentVersion: "3.0.13-0ubuntu3", NewVersion: "3.0.13-0ubuntu3.1"},
		},
			behavior.Prints("apt list --upgradable", "Listing...\n"+
				"curl/noble-updates 8.5.0-2ubuntu10.1 amd64 [upgradable from: 8.5.0-2ubuntu10]\n"+
				"openssl/noble-updates 3.0.13-0ubuntu3.1 amd64 [upgradable from: 3.0.13-0ubuntu3]\n"),
		),
	behavior.Write("update", Update).
		ReadsNothing("it refreshes the package index, whose updates are what the repositories have: no value of the example is in the read").
		Sudo("apt-get").
		Describe("Refresh the package index").
		Explain("Runs apt-get update. It reports changed: true when the Release file "+
			"of a repository under /var/lib/apt/lists changed, and changed: false when "+
			"each repository was unchanged.").
		Example("The repositories are unchanged since the last refresh", UpdateInput{}, Result{},
			behavior.After(UpdateInput{}),
			behavior.Prints("apt-get update", "Hit:1 http://archive.ubuntu.com/ubuntu noble-updates InRelease\n"),
		),
))

Behavior is the updates the package index has for the host, under the packages: package updates. They are not facts about the host but what its repositories have, so apt reads them, not gohai. It runs on the Debian family. Its permissions are the packages': package:read and package:write.

Functions

This section is empty.

Types

type Available

type Available struct {
	Name           string `json:"name"            doc:"The package"`
	CurrentVersion string `json:"current_version" doc:"The installed version"`
	NewVersion     string `json:"new_version"     doc:"The version the index has"`
}

Available is one package that the index has a newer version of.

func List

func List(
	ctx context.Context,
	p Provider,
	_ ListInput,
) ([]Available, error)

List is each package the index has a newer version of.

type ListInput

type ListInput struct{}

ListInput takes nothing: it lists every update the index has.

type Provider

type Provider interface {
	// Updates is each package the index has a newer version of.
	Updates(ctx context.Context) ([]Available, error)
	// Refresh gets the index again, and reports whether it got new data.
	Refresh(ctx context.Context) (bool, error)
}

Provider reads and refreshes the package index of the host.

type Result

type Result struct {
	Changed bool `json:"changed" doc:"Whether the refresh got new index data"`
}

Result is the index after a refresh.

func Update

func Update(
	ctx context.Context,
	p Provider,
	_ UpdateInput,
) (Result, error)

Update refreshes the package index.

type UpdateInput

type UpdateInput struct{}

UpdateInput takes nothing: it refreshes the whole index.

Directories

Path Synopsis
Package mocks holds the generated double of the updatepackages provider, for the methods' tests.
Package mocks holds the generated double of the updatepackages provider, for the methods' tests.

Jump to

Keyboard shortcuts

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