airgap

package
v0.0.0-...-bde254b Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 23 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AirgapInUse

func AirgapInUse() bool

func Read

func Read(installBundlePath string, f ReadVisitFunc) error

Read reads an install bundle. It calls the provided ReadVisitFunc for each item in the install bundle.

Types

type FileCacher

type FileCacher interface {
	IsCached(filename string) bool
	CacheFile(filename string, w func(io.Writer) error) error
}

FileCacher caches files

type HabBinaryDownloader

type HabBinaryDownloader interface {
	// Download the hab binary for the given version, release tuple. It is copied
	// to the writer
	DownloadHabBinary(version string, release string, w io.Writer) error
}

HabBinaryDownloader can download a hab binary

func NewNetHabDownloader

func NewNetHabDownloader() HabBinaryDownloader

NewNetHabDownloader returns a new HabBinaryDownloader that pulls from packages.chef.io based on the version being requested.

type HartifactCache

type HartifactCache interface {
	// IsCached returns true if the given package already exists
	IsCached(habpkg.VersionedPackage) bool
	// CacheArtifact stores harts in the cache
	CacheArtifact(habpkg.VersionedPackage, func(io.Writer) error) error
}

HartifactCache stores harts

func NewHartifactCache

func NewHartifactCache(cacheDir string) HartifactCache

NewHartifactCache returns a new HartifactCache

type InstallBundleCreator

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

InstallBundleCreator creates installation bundles

func NewInstallBundleCreator

func NewInstallBundleCreator(opts ...InstallBundleCreatorOpt) *InstallBundleCreator

NewInstallBundleCreator initializes a new artifact creator

func (*InstallBundleCreator) Create

func (creator *InstallBundleCreator) Create(progress InstallBundleCreatorProgress) (string, error)

Create creates the install bundle

type InstallBundleCreatorOpt

type InstallBundleCreatorOpt func(*InstallBundleCreator)

InstallBundleCreatorOpt are functional options for the InstallBundleCreator

func WithInstallBundleChannel

func WithInstallBundleChannel(channel string) InstallBundleCreatorOpt

WithInstallBundleChannel sets the release channel from which to download the manifest.

func WithInstallBundleHartifactsPath

func WithInstallBundleHartifactsPath(hartifactsPath string, overrideOrigin string) InstallBundleCreatorOpt

WithInstallBundleHartifactsPath sets the path to search for override harts

func WithInstallBundleManifestFile

func WithInstallBundleManifestFile(path string) InstallBundleCreatorOpt

WithInstallBundleManifestFile sets the path for manifest

func WithInstallBundleOutputPath

func WithInstallBundleOutputPath(outputPath string) InstallBundleCreatorOpt

WithInstallBundleOutputPath tells the install bundle creator the exact file to use

func WithInstallBundleRetries

func WithInstallBundleRetries(r int) InstallBundleCreatorOpt

WithInstallBundleRetries sets the number of retries to attempt for failed package downloads.

func WithInstallBundleRetryDelay

func WithInstallBundleRetryDelay(d int) InstallBundleCreatorOpt

WithInstallBundleRetryDelay sets the number of seconds between retries, if not set, an exponential backoff based on the number of tries is used.

func WithInstallBundleVersion

func WithInstallBundleVersion(version string) InstallBundleCreatorOpt

WithInstallBundleVersion sets the version whose manifest should be used.

func WithInstallBundleVersionsPath

func WithInstallBundleVersionsPath(versionsPath string) InstallBundleCreatorOpt

WithInstallBundleVersionsPath sets the path to search for override versions

func WithInstallBundleWorkspacePath

func WithInstallBundleWorkspacePath(path string) InstallBundleCreatorOpt

WithInstallBundleWorkspacePath sets the path for caching artifacts

type InstallBundleCreatorProgress

type InstallBundleCreatorProgress interface {
	Downloading(name string, tries int)
	DownloadComplete(name string, wasCached bool)
	RetriableDownloadError(name string, info string, delay time.Duration)
}

InstallBundleCreatorProgress gets progress reports from the creator

type InstallBundleFileTypeFlag

type InstallBundleFileTypeFlag byte

InstallBundleFileTypeFlag signifies which type of file an item in the install bundle is

const (
	// Hartifact signifies that the file is a .hart
	Hartifact InstallBundleFileTypeFlag = iota
	// OriginKey signifies the file is one of the public origin keys
	OriginKey
	// HabBin signifies the file is the hab executable
	HabBin
	// Manifest signifies the file is the manifest.json
	Manifest
)

type InstallBundleItem

type InstallBundleItem struct {
	Typeflag InstallBundleFileTypeFlag
	Name     string
	FileInfo os.FileInfo
}

InstallBundleItem represents an item in the install bundle

type KeyCache

type KeyCache interface {
	// IsCached returns true if the given key already exists
	IsCached(depot.OriginKeyName) bool
	// CacheKey stores the key
	CacheKey(depot.OriginKeyName, func(io.Writer) error) error
}

KeyCache stores origin public keys

func NewKeyCache

func NewKeyCache(cacheDir string) KeyCache

NewKeyCache returns a new KeyCache

type ReadVisitFunc

type ReadVisitFunc func(InstallBundleItem, io.Reader) error

ReadVisitFunc is the func called for each item in the install bundle. The receiver may choose to ignore it or read from the provided reader

type UnpackMetadata

type UnpackMetadata struct {
	HartifactPaths []string
	OriginKeyPaths []string
	ManifestPath   string
	HabBinPath     string
}

UnpackMetadata is the result of unpacking an install bundle. It contains the paths to the files that were unpacked

func GetMetadata

func GetMetadata(installBundlePath string) (UnpackMetadata, []byte, error)

func Unpack

func Unpack(installBundlePath string, opts ...UnpackOpt) (UnpackMetadata, error)

Unpack puts the files in the given install bundle at the right place on disk

type UnpackOpt

type UnpackOpt func(*unpackOpts)

UnpackOpt are functional options for Unpack

func WithUnpackHartsOnly

func WithUnpackHartsOnly(hartsOnly bool) UnpackOpt

WithUnpackHartsOnly only unpacks the hartifacts and their keys.

func WithUnpackRoot

func WithUnpackRoot(root string) UnpackOpt

WithUnpackRoot sets the root directory for unpacking. By default, it is /

Jump to

Keyboard shortcuts

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