updater

package
v0.4.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: BSD-3-Clause, GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const DownloadDiskSpace = uint64(12)
View Source
const ExtractDiskSpace = uint64(10)
View Source
const GiB = uint64(1024 * 1024 * 1024)

Variables

This section is empty.

Functions

func DownloadAndExtract

func DownloadAndExtract(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool, temp *paths.Path) (*paths.Path, string, error)

func DownloadImage

func DownloadImage(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool, downloadPath *paths.Path) (*paths.Path, string, error)

func ExtractImage

func ExtractImage(archive, temp *paths.Path) error

func Flash

func Flash(ctx context.Context, imagePath *paths.Path, version string, forceYes bool, tempDir string) error

func FlashBoard

func FlashBoard(ctx context.Context, downloadedImagePath string, version string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) error

func SetTempDir added in v0.4.0

func SetTempDir(prefix string, tempDir string) (*paths.Path, error)

SetTempDir returns a temporary directory inside the user's cache directory (default). The tempDir parameter is used to change the download/extraction directory. The caller is responsible for removing the directory when no longer needed.

Types

type Client

type Client struct {
	HTTPClient HTTPDoer
	Headers    map[string]string // Optional headers to add to each request
}

Client holds the base URL, command name, allows custom HTTP client, and optional headers.

func NewClient

func NewClient(opts ...Option) *Client

NewClient creates a new Client with optional configuration.

func (*Client) FetchZip

func (c *Client) FetchZip(zipURL string) (io.ReadCloser, int64, error)

FetchZip fetches the Debian image archive.

func (*Client) GetInfoManifest

func (c *Client) GetInfoManifest() (Manifest, error)

GetInfoManifest fetches and decodes the Debian images info.json.

type DownloadConfirmCB

type DownloadConfirmCB func(target string) (bool, error)

DownloadConfirmCB is a function that is called when a Debian image is ready to be downloaded.

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer is an interface for http.Client or mocks.

type Manifest

type Manifest struct {
	Latest   Release   `json:"latest"`
	Releases []Release `json:"releases"`
}

type Option

type Option func(*Client)

Option is a functional option for configuring Client.

func WithHTTPClient

func WithHTTPClient(client HTTPDoer) Option

WithHTTPClient sets a custom HTTP client for the Client.

func WithHeaders

func WithHeaders(headers map[string]string) Option

WithHeaders sets custom headers for the Client.

type Release

type Release struct {
	Version string `json:"version"`
	Url     string `json:"url"`
	Sha256  string `json:"sha256"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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