apt

package
v0.0.0-...-8102ba9 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package apt provides package management operations via apt.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Darwin

type Darwin struct{}

Darwin implements the Provider interface for Darwin (macOS). All methods return ErrUnsupported as apt is not available on macOS.

func NewDarwinProvider

func NewDarwinProvider() *Darwin

NewDarwinProvider factory to create a new Darwin instance.

func (*Darwin) Get

func (d *Darwin) Get(
	_ context.Context,
	_ string,
) (*Package, error)

Get returns ErrUnsupported on Darwin.

func (*Darwin) Install

func (d *Darwin) Install(
	_ context.Context,
	_ string,
) (*Result, error)

Install returns ErrUnsupported on Darwin.

func (*Darwin) List

func (d *Darwin) List(
	_ context.Context,
) ([]Package, error)

List returns ErrUnsupported on Darwin.

func (*Darwin) ListUpdates

func (d *Darwin) ListUpdates(
	_ context.Context,
) ([]Update, error)

ListUpdates returns ErrUnsupported on Darwin.

func (*Darwin) Remove

func (d *Darwin) Remove(
	_ context.Context,
	_ string,
) (*Result, error)

Remove returns ErrUnsupported on Darwin.

func (*Darwin) Update

func (d *Darwin) Update(
	_ context.Context,
) (*Result, error)

Update returns ErrUnsupported on Darwin.

type Debian

type Debian struct {
	provider.FactsAware
	// contains filtered or unexported fields
}

Debian implements the Provider interface for Debian-family systems using dpkg-query and apt-get.

func NewDebianProvider

func NewDebianProvider(
	logger *slog.Logger,
	execManager exec.Manager,
) *Debian

NewDebianProvider factory to create a new Debian instance.

func (*Debian) Get

func (d *Debian) Get(
	_ context.Context,
	name string,
) (*Package, error)

Get returns details for a single installed package.

func (*Debian) Install

func (d *Debian) Install(
	_ context.Context,
	name string,
) (*Result, error)

Install installs a package by name using apt-get.

func (*Debian) List

func (d *Debian) List(
	_ context.Context,
) ([]Package, error)

List returns all installed packages by querying dpkg.

func (*Debian) ListUpdates

func (d *Debian) ListUpdates(
	_ context.Context,
) ([]Update, error)

ListUpdates returns packages with available updates by parsing apt list --upgradable output.

func (*Debian) Remove

func (d *Debian) Remove(
	_ context.Context,
	name string,
) (*Result, error)

Remove removes a package by name using apt-get.

func (*Debian) Update

func (d *Debian) Update(
	_ context.Context,
) (*Result, error)

Update refreshes the package index using apt-get update.

type Linux

type Linux struct{}

Linux implements the Provider interface for generic Linux. All methods return ErrUnsupported; use the Debian provider for Debian-family systems.

func NewLinuxProvider

func NewLinuxProvider() *Linux

NewLinuxProvider factory to create a new Linux instance.

func (*Linux) Get

func (l *Linux) Get(
	_ context.Context,
	_ string,
) (*Package, error)

Get returns ErrUnsupported on generic Linux.

func (*Linux) Install

func (l *Linux) Install(
	_ context.Context,
	_ string,
) (*Result, error)

Install returns ErrUnsupported on generic Linux.

func (*Linux) List

func (l *Linux) List(
	_ context.Context,
) ([]Package, error)

List returns ErrUnsupported on generic Linux.

func (*Linux) ListUpdates

func (l *Linux) ListUpdates(
	_ context.Context,
) ([]Update, error)

ListUpdates returns ErrUnsupported on generic Linux.

func (*Linux) Remove

func (l *Linux) Remove(
	_ context.Context,
	_ string,
) (*Result, error)

Remove returns ErrUnsupported on generic Linux.

func (*Linux) Update

func (l *Linux) Update(
	_ context.Context,
) (*Result, error)

Update returns ErrUnsupported on generic Linux.

type Package

type Package struct {
	Name        string `json:"name"`
	Version     string `json:"version"`
	Description string `json:"description,omitempty"`
	Status      string `json:"status"`
	Size        int64  `json:"size,omitempty"`
}

Package represents an installed apt package.

type Provider

type Provider interface {
	// List returns all installed packages.
	List(ctx context.Context) ([]Package, error)
	// Get returns details for a single installed package.
	Get(ctx context.Context, name string) (*Package, error)
	// Install installs a package by name.
	Install(ctx context.Context, name string) (*Result, error)
	// Remove removes a package by name.
	Remove(ctx context.Context, name string) (*Result, error)
	// Update refreshes the package index.
	Update(ctx context.Context) (*Result, error)
	// ListUpdates returns packages with available updates.
	ListUpdates(ctx context.Context) ([]Update, error)
}

Provider implements the methods to interact with apt package management.

type Result

type Result struct {
	Name    string `json:"name,omitempty"`
	Changed bool   `json:"changed"`
	Error   string `json:"error,omitempty"`
}

Result represents the outcome of a package mutation operation.

type Update

type Update struct {
	Name           string `json:"name"`
	CurrentVersion string `json:"current_version"`
	NewVersion     string `json:"new_version"`
}

Update represents a package with an available update.

Directories

Path Synopsis
Package mocks provides mock implementations for testing.
Package mocks provides mock implementations for testing.

Jump to

Keyboard shortcuts

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