artifact

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CniPlugins              = "cniPlugins"
	IamAuthenticator        = "iamAuthenticator"
	IamRolesAnywhere        = "iamRolesAnywhere"
	ImageCredentialProvider = "imageCredentialProvider"
	Kubectl                 = "kubectl"
	Kubelet                 = "kubelet"
	Ssm                     = "ssm"
	Containerd              = "containerd"
	Iptables                = "iptables"
)
View Source
const DefaultDirPerms = fs.ModeDir | 0o755

DefaultDirPerms are the permissions assigned to a directory when an Install* func is called and it has to create the parent directories for the destination.

Variables

This section is empty.

Functions

func InstallFile

func InstallFile(dst string, src io.Reader, perms fs.FileMode) error

InstallFile installs src to dst with perms permissions. It ensures any base paths exist before installing.

func InstallPackageWithRetries

func InstallPackageWithRetries(ctx context.Context, pkgSource Package, backoff time.Duration) error

InstallPackageWithRetries installs a package and retries errors until the context is cancelled. The backoff duration is the time to wait between retries.

func InstallTarGz

func InstallTarGz(dst, src string) error

InstallTarGz untars the src file into the dst directory and deletes the src tgz file

func NewChecksumError

func NewChecksumError(src Source) error

NewChecksumError creates an error of type ChecksumError.

func ParseGNUChecksum

func ParseGNUChecksum(gnuChecksum []byte) ([]byte, error)

ParseGNUChecksum parses r as GNU checksum format and returns the checksum value. GNU checksums are a space separated digest and filename:

<digest> <filename>

func UninstallPackageWithRetries added in v1.0.1

func UninstallPackageWithRetries(ctx context.Context, pkgSource Package, backoff time.Duration) error

UninstallPackageWithRetries uninstalls a package and retries errors until the context is cancelled. The backoff duration is the time to wait between retries.

Types

type ChecksumError

type ChecksumError struct {
	Expect []byte
	Actual []byte
}

func (ChecksumError) Error

func (ce ChecksumError) Error() string

Error implements the error interface.

func (ChecksumError) Is

func (ce ChecksumError) Is(err error) bool

Is implements the errors.Is interface.

type ChecksumVerifier

type ChecksumVerifier interface {
	// VerifyChecksum returns true if ExpectedChecksum() is equal to ActualChecksum(). Otherwise
	// it returns false. If expected and actual are nil, it returns true.
	VerifyChecksum() bool

	// ExpectedChecksum returns the expected checksum of the underlying data.
	ExpectedChecksum() []byte

	// ActualChecksum returns the actual checksum of underlying data.
	ActualChecksum() []byte
}

ChecksumVerifier verifies the checksum of a data source.

type Cmd

type Cmd struct {
	Path string
	Args []string
}

Cmd represents a command to be executed.

func NewCmd

func NewCmd(path string, args ...string) Cmd

NewCmd returns a new Cmd.

func (Cmd) Command

func (c Cmd) Command(ctx context.Context) *exec.Cmd

Command returns a new exec.Cmd.

type Package

type Package interface {
	// InstallCmd returns the command to install the package.
	// Every invocation guarantees a new command.
	InstallCmd(context.Context) *exec.Cmd
	// UninstallCmd returns the command to uninstall the package.
	// Every invocation guarantees a new command.
	UninstallCmd(context.Context) *exec.Cmd
}

Package interface defines a package source It defines the install and uninstall command to be executed

func NewPackageSource

func NewPackageSource(installCmd, uninstallCmd Cmd) Package

type Source

type Source interface {
	io.ReadCloser
	ChecksumVerifier
}

Source is a binary data source. Sources must be streamed in their entirety before their checksums can be validated. Sources are closable. It is up to the producer to determine who is responsible for closing the Source.

func WithChecksum

func WithChecksum(rc io.ReadCloser, digest hash.Hash, expect []byte) (Source, error)

WithChecksum creates a checksumVerifier. The digest is used to calculate srcs checksum. The returned Source should be used to read the artifact contents.

func WithNopChecksum

func WithNopChecksum(rc io.ReadCloser) Source

WithNopChecksum turns rc into a Source that nops when the ChecksumVerifier methods are called. Both ActualChecksum() and ExpectedChecksum() will return nil.

Jump to

Keyboard shortcuts

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