artifact

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2025 License: Apache-2.0 Imports: 18 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 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 Upgrade added in v1.0.4

func Upgrade(artifactName, path string, source Source, perms fs.FileMode, log *zap.Logger) error

Upgrade upgrades an artifact from the source only if the expected checksum doesn't match with the checksum of artifact already installed.

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
	// UpgradeCmd return the command to upgrade the package
	// Every invocation guarantees a new command.
	UpgradeCmd(ctx context.Context) *exec.Cmd
}

Package interface defines a package source It defines the install, uninstall & upgrade commands to be executed

func NewPackageSource

func NewPackageSource(installCmd, uninstallCmd, upgradeCmd 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 GzippedWithChecksum added in v1.0.6

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

GzippedWithChecksum creates a gzip reader around rc and a checksum verifier. The returned Source should be used to read the artifact contents.

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