package updater

import "github.com/theupdateframework/go-tuf/v2/metadata/updater"

Index

Functions

func IsWindowsPath

func IsWindowsPath(path string) bool

Types

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Client update workflow implementation

The "Updater" provides an implementation of the TUF client workflow (ref. https://theupdateframework.github.io/specification/latest/#detailed-client-workflow). "Updater" provides an API to query available targets and to download them in a secure manner: All downloaded files are verified by signed metadata. High-level description of "Updater" functionality:

Thread Safety: Updater is NOT safe for concurrent use. If multiple goroutines need to use an Updater concurrently, external synchronization is required (e.g., a sync.Mutex). Alternatively, create separate Updater instances for each goroutine.

func New

func New(config *config.UpdaterConfig) (*Updater, error)

New creates a new Updater instance and loads trusted root metadata

func (*Updater) DownloadTarget

func (update *Updater) DownloadTarget(targetFile *metadata.TargetFiles, filePath, targetBaseURL string) (string, []byte, error)

DownloadTarget downloads the target file specified by targetFile

func (*Updater) FindCachedTarget

func (update *Updater) FindCachedTarget(targetFile *metadata.TargetFiles, filePath string) (string, []byte, error)

FindCachedTarget checks whether a local file is an up to date target

func (*Updater) GetTargetInfo

func (update *Updater) GetTargetInfo(targetPath string) (*metadata.TargetFiles, error)

GetTargetInfo returns metadata.TargetFiles instance with information for targetPath. The return value can be used as an argument to DownloadTarget() and FindCachedTarget(). If Refresh() has not been called before calling GetTargetInfo(), the refresh will be done implicitly. As a side-effect this method downloads all the additional (delegated targets) metadata it needs to return the target information.

func (*Updater) GetTopLevelTargets

func (update *Updater) GetTopLevelTargets() map[string]*metadata.TargetFiles

GetTopLevelTargets returns the top-level target files

func (*Updater) GetTrustedMetadataSet

func (update *Updater) GetTrustedMetadataSet() trustedmetadata.TrustedMetadata

GetTrustedMetadataSet returns the trusted metadata set

func (*Updater) Refresh

func (update *Updater) Refresh() error

Refresh loads and possibly refreshes top-level metadata. Downloads, verifies, and loads metadata for the top-level roles in the specified order (root -> timestamp -> snapshot -> targets) implementing all the checks required in the TUF client workflow. A Refresh() can be done only once during the lifetime of an Updater. If Refresh() has not been explicitly called before the first GetTargetInfo() call, it will be done implicitly at that time. The metadata for delegated roles is not updated by Refresh(): that happens on demand during GetTargetInfo(). However, if the repository uses consistent snapshots (ref. https://theupdateframework.github.io/specification/latest/#consistent-snapshots), then all metadata downloaded by the Updater will use the same consistent repository state.

If UnsafeLocalMode is set, no network interaction is performed, only the cached files on disk are used. If the cached data is not complete, this call will fail.

func (*Updater) UnsafeSetRefTime

func (update *Updater) UnsafeSetRefTime(t time.Time)

UnsafeSetRefTime sets the reference time that the updater uses. This should only be done in tests. Using this function is useful when testing time-related behavior in go-tuf.

Source Files

updater.go

Version
v2.4.1 (latest)
Published
Jan 26, 2026
Platform
linux/amd64
Imports
15 packages
Last checked
4 hours ago

Tools for package owners.