drop

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 41 Imported by: 1 module, 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

Index

Constants

View Source
const (
	EventObjectArchive      = "archive"
	EventObjectAsset        = "asset"
	EventObjectAttestation  = "attestation"
	EventObjectInstall      = "install"
	EventObjectPolicy       = "policy"
	EventObjectRemove       = "remove"
	EventObjectVerification = "verification"

	EventVerbDone    = "done"
	EventVerbGet     = "get"
	EventVerbRunning = "running"
	EventVerbSaved   = "saved"
	EventVerbSkipped = "skipped"

	// EventDataCommunity flags policy events about the community repository
	EventDataCommunity = "community"
)
View Source
const CommunityPolicyRepositoryURL = "https://github.com/policylabs/oss"

CommunityPolicyRepositoryURL is the repository of community maintained policies, consulted when a project publishes none of its own.

View Source
const DefaultAttestationFormat = "ampel"

DefaultAttestationFormat is the attestation type written when none is specified.

View Source
const PolicyRequestTitlePrefix = "✨ Community Policies Request: "

PolicyRequestTitlePrefix marks community policy request issues so they stand out in the community policy repository's issue list.

Variables

View Source
var (
	// ErrNoBinaryInArchive is returned when an archive holds no native
	// executable for the target platform.
	ErrNoBinaryInArchive = errors.New("archive contains no executable for the platform")

	// ErrNoMatchingArchiveEntry is returned when an archive ships executables
	// but none is named after the installable.
	ErrNoMatchingArchiveEntry = errors.New("no executable named after the installable in the archive")

	// ErrBadArchiveEntry is returned when the entry the user asked for is
	// not in the archive or is not an executable for the platform.
	ErrBadArchiveEntry = errors.New("requested archive entry cannot be installed")
)
View Source
var (
	ErrNoPolicyAvailable  = errors.New("no verification policies available for artifact")
	ErrVerificationFailed = errors.New("asset failed verification, refusing to install")
	ErrNoPlatformVariant  = errors.New("no installable variant found for the specified platform")
	ErrInstallAborted     = errors.New("installation aborted")
	ErrAlreadyInstalled   = errors.New("already installed")
)
View Source
var (
	ErrNoInstallableArtifact = errors.New("release has no binary or compatible package for this platform")
	ErrOnlyArchives          = errors.New("release only ships archives in unsupported formats for this platform")
	ErrAmbiguousInstallable  = errors.New("release ships several installables")
)

AttestationFormats lists the types of attestation drop can write about a verification: the full ampel result set, a SLSA verification summary (vsa) or an in-toto simple verification result (svr).

View Source
var ErrInvalidAttestationFormat = errors.New("invalid attestation format")

ErrInvalidAttestationFormat is returned when an unknown attestation format is requested.

Functions

func AcceptSingleArchiveEntry

func AcceptSingleArchiveEntry(_, wanted string, candidates []string) (string, error)

AcceptSingleArchiveEntry is an ArchiveEntrySelector for runs that opted out of prompts: it installs the only executable found in an archive and fails when there are several to choose from.

func CommunityPolicyPath

func CommunityPolicyPath(org, repo string) string

CommunityPolicyPath returns the directory inside the community policy repository holding the release policies of a repository.

func DefaultPolicyRepository

func DefaultPolicyRepository(host, org string) string

DefaultPolicyRepository returns the URL of the repository where drop looks for the policies of a publisher when no alternative source is configured: the organization's .github repository.

func OrgPolicyPath

func OrgPolicyPath() string

OrgPolicyPath returns the directory inside a policy repository holding the policies that apply to the releases of every repository in the organization.

func PolicyPath

func PolicyPath(repo string) string

PolicyPath returns the directory inside a policy repository holding the release policies of a repository.

func PolicyPaths

func PolicyPaths(repo string) []string

PolicyPaths returns the directories read for a repository's policies, the organization-wide one first.

func PolicyPathsLabel

func PolicyPathsLabel(repo string) string

PolicyPathsLabel renders the policy directories of a repository compactly for messages: ampel/policies/release/{_,repo}/

Types

type ArchiveEntrySelector

type ArchiveEntrySelector func(archiveName, wanted string, candidates []string) (string, error)

ArchiveEntrySelector chooses which executable inside an archive to install when none is named after the installable. It receives the archive filename, the installable name and the paths of the executables found, and returns the chosen path, or ErrInstallAborted when the user declines. The CLI injects an interactive implementation when running on a terminal.

type ArtifactKind

type ArtifactKind string

ArtifactKind distinguishes the kinds of artifacts the installer can handle.

const (
	ArtifactBinary  ArtifactKind = "binary"
	ArtifactPackage ArtifactKind = "package"
	ArtifactArchive ArtifactKind = "archive"
)

type ArtifactSelector

type ArtifactSelector func(candidates []*InstallArtifact) (*InstallArtifact, error)

ArtifactSelector resolves an ambiguous choice between install candidates. The CLI injects an interactive implementation when running on a terminal.

type Dropper

type Dropper struct {
	Options Options
	// contains filtered or unexported fields
}

func New

func New(funcs ...FuncOption) (*Dropper, error)

func (*Dropper) CheckUpdates

func (dropper *Dropper) CheckUpdates() ([]*UpdateStatus, error)

CheckUpdates reads the inventory of installed apps and checks the GitHub releases of each of them to see if a newer version is available.

func (*Dropper) Get

func (dropper *Dropper) Get(spec github.AssetDataProvider, funcs ...FuncGetOption) error

Get downloads and verifies an artifact from a GitHub release.

func (*Dropper) Install

func (dropper *Dropper) Install(spec github.AssetDataProvider, funcs ...FuncGetOption) error

Install downloads, verifies and installs an artifact from a release

func (*Dropper) Update

func (dropper *Dropper) Update(status *UpdateStatus, funcs ...FuncGetOption) error

Update reinstalls an app from the latest release of its repository, reusing the choices recorded when it was originally installed.

type Event

type Event struct {
	Object string
	Verb   string
	Data   map[string]string
}

func (*Event) GetDataField

func (e *Event) GetDataField(field string) string

type FuncGetOption

type FuncGetOption func(*GetOptions) error

func WithArchiveEntry

func WithArchiveEntry(entryPath string) FuncGetOption

WithArchiveEntry pins the file to install from an archive, falling back to the regular selection when the archive does not hold it anymore.

func WithArchiveEntrySelector

func WithArchiveEntrySelector(fn ArchiveEntrySelector) FuncGetOption

func WithArtifactSelector

func WithArtifactSelector(fn ArtifactSelector) FuncGetOption

func WithAttestationPath

func WithAttestationPath(path string) FuncGetOption

WithAttestationPath sets where the attestation of the verification is written: a file path, a directory or empty for the default location.

func WithBinDir

func WithBinDir(dir string) FuncGetOption

func WithDownloadPath

func WithDownloadPath(path string) FuncGetOption

func WithDownloadType

func WithDownloadType(t string) FuncGetOption

func WithPlatform

func WithPlatform(slug string) FuncGetOption

GetOptions

func WithReinstall

func WithReinstall(reinstall bool) FuncGetOption

WithReinstall allows installing an app that is already installed. The choices made when it was first installed are reused unless overridden.

func WithRequiredArchiveEntry

func WithRequiredArchiveEntry(entryPath string) FuncGetOption

WithRequiredArchiveEntry names the file to install from an archive. The installation fails if the archive does not hold an executable at that path.

func WithTransferTimeOut

func WithTransferTimeOut(seconds int) FuncGetOption

func WithVerifyDownloads

func WithVerifyDownloads(verify bool) FuncGetOption

type FuncOption

type FuncOption func(*Dropper) error

func WithAttestation

func WithAttestation(format string) FuncOption

WithAttestation enables writing an attestation of every verification in the specified format (one of AttestationFormats, the default when empty).

func WithCommunityPolicyRepository

func WithCommunityPolicyRepository(repoURL string) FuncOption

WithCommunityPolicyRepository sets the repository of community policies consulted when a project has none of its own. An empty URL disables the fallback.

func WithListener

func WithListener(listener ProgressListener) FuncOption

func WithPolicyRepository

func WithPolicyRepository(repoURL string) FuncOption

WithPolicyRepository sets the repository policies are read from instead of the .github repository of the artifact's organization: a GitHub repository (URL or org/repo slug) or a local git checkout given as a file:// URL or a directory path (the committed contents are read, not the working tree). Policies are read from ampel/policies/release/<repo>/ and the org-wide ampel/policies/release/_/ in either case.

func WithSigner

func WithSigner(s *signer.Signer) FuncOption

WithSigner sets the signer used to sign attestations. A nil signer writes unsigned statements.

type GetOptions

type GetOptions struct {
	// Embedded dropper options to pass to implementation
	Options

	// Directory where the asset will be downloaded
	DownloadPath string

	// Platform to download
	OS   string
	Arch string

	// Filename to store the downloaded asset
	FileName string

	// TransferTimeOut is the number of seconds after which the http request
	// will time out.
	TransferTimeOut int

	// SkipVerification instructs the dropper engine to skip the artifact
	// security verification. This allows the tool to be used as a curl-like
	// thing for repos.
	SkipVerification bool

	// DownloadType is "a","b" or "p" and determines which download we do
	DownloadType string

	// BinDir is the directory where binaries are installed by the install
	// subcommand.
	BinDir string

	// Selector resolves the choice between a binary and a package when a
	// release offers both for the local system.
	Selector ArtifactSelector

	// ArchiveEntry pins the path inside the archive of the file to install
	// when installing from an archive. Updates set it from the inventory
	// so the choice made when the app was first installed is reused.
	ArchiveEntry string

	// ArchiveEntryRequired makes a missing or non installable ArchiveEntry
	// an error instead of falling back to the regular selection. It is set
	// when the user names the entry explicitly.
	ArchiveEntryRequired bool

	// EntrySelector chooses the executable to install from an archive when
	// none is named after the installable.
	EntrySelector ArchiveEntrySelector

	// AttestationPath is where the attestation of the verification is
	// written: a file path, a directory (which gets the default filename)
	// or empty to use the default filename in the download directory.
	AttestationPath string

	// Reinstall allows installing an app that is already recorded in the
	// inventory. The recorded choices (artifact kind, archive entry) are
	// reused unless overridden, and when the new installation replaces the
	// previous one in another format, the previous artifact is removed.
	Reinstall bool
	// contains filtered or unexported fields
}

type InstallArtifact

type InstallArtifact struct {
	// Kind is the artifact type: binary, package or archive.
	Kind ArtifactKind

	// PackageFormat is the package type (rpm, deb, apk) when Kind is package.
	PackageFormat string

	// Asset is the release asset variant to download.
	Asset *github.Asset

	// Name is the installable name identifying the app. It keys the app in
	// the inventory and is the name updates look up in newer releases.
	Name string

	// InstallName is the name the binary gets when installed into the path.
	// It usually matches Name (plus .exe on windows) but can differ when
	// the installed file is not named after the installable.
	InstallName string

	// ArchiveEntry is the path inside the archive of the installed file
	// when Kind is archive. It is filled in once the archive is inspected
	// and stays empty for bare compressed files.
	ArchiveEntry string
}

InstallArtifact is a concrete release asset chosen for installation.

type NoopListener

type NoopListener struct{}

NoopListener is a listener tht just swallows events without doing anything

func (*NoopListener) HandleEvent

func (*NoopListener) HandleEvent(event *Event)

type Options

type Options struct {
	// PolicyRepository overrides the repository policies are read from.
	PolicyRepository string

	// CommunityPolicyRepository is consulted when a project publishes no
	// policies of its own (and no PolicyRepository override is set). Empty
	// disables the fallback.
	CommunityPolicyRepository string

	Listener ProgressListener

	// Attest enables writing an attestation of every verification
	// performed, in the AttestFormat format.
	Attest bool

	// AttestFormat is the type of attestation written (see
	// AttestationFormats).
	AttestFormat string

	// Signer signs the attestations. When nil, the bare in-toto statement
	// is written instead.
	Signer *signer.Signer
}

type PolicyRequest

type PolicyRequest struct {
	// Repository coordinates of the project lacking policies
	Host string
	Org  string
	Repo string

	// PolicyRepository is the URL where drop looked for policies
	PolicyRepository string

	// CommunityRepository is the URL of the community policy repository
	// that was checked as well, empty when none was.
	CommunityRepository string

	// Release is the tag of the release drop checked for policies
	Release string

	// Version and Platform of the drop binary filing the request
	Version  string
	Platform string
}

PolicyRequest describes a request for the community to write policies for an open source repository that has none. Requests are filed as issues in the community policy repository.

func (*PolicyRequest) Body

func (pr *PolicyRequest) Body() string

Body returns the markdown body of the request issue.

func (*PolicyRequest) ReleaseURL

func (pr *PolicyRequest) ReleaseURL() string

ReleaseURL returns the URL of the release that was checked, or an empty string when no release is recorded.

func (*PolicyRequest) RepositoryURL

func (pr *PolicyRequest) RepositoryURL() string

RepositoryURL returns the URL of the requested repository.

func (*PolicyRequest) Slug

func (pr *PolicyRequest) Slug() string

Slug returns the org/repo slug of the requested repository.

func (*PolicyRequest) Title

func (pr *PolicyRequest) Title() string

Title returns the title of the request issue.

func (*PolicyRequest) URL

func (pr *PolicyRequest) URL() string

URL returns the link to open a prefilled issue in the community policy repository (CommunityRepository, or the default when empty). Filing the issue happens in the browser, where the user is signed in to GitHub, so no token is required.

type ProgressListener

type ProgressListener interface {
	HandleEvent(event *Event)
}

ProgressListener is an object that reacts to the events from the downloader.

type UpdateStatus

type UpdateStatus struct {
	// Record is the inventory entry of the installed app.
	Record *inventory.Record

	// LatestVersion is the newest release available in the repository.
	LatestVersion string

	// UpdateAvailable is true when the latest release is newer than the
	// installed version.
	UpdateAvailable bool

	// Error captures a per-app check failure (API errors, repository
	// gone, etc) without aborting the rest of the checks.
	Error error
}

UpdateStatus describes the update state of an app installed with drop.

Jump to

Keyboard shortcuts

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