updater

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: BSD-3-Clause, GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadAndExtract

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

func DownloadImage

func DownloadImage(client *Client, targetVersion string, upgradeConfirmCb DownloadConfirmCB, forceYes bool) (*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) error

func FlashBoard

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

func GetTempDir

func GetTempDir(prefix string) (*paths.Path, error)

GetTempDir returns a temporary directory inside the user's cache 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