utils

package
v0.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package utils implements common utility functions.

Index

Constants

View Source
const TmpDirPrefix = "falcoctl-registry-push"

TmpDirPrefix prefix used for the temporary directory where the tar.gz archives live before pushing to the OCI registry.

Variables

View Source
var ErrNotTarGz = errors.New("not a tar.gz archive")

ErrNotTarGz returned when the file is not a tar.gz archive.

Functions

func ClientCredentials

func ClientCredentials(reg string) (*clientcredentials.Config, error)

ClientCredentials retrieves the client credentials for a specific registry.

func ClientForRegistry

func ClientForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (remote.Client, error)

ClientForRegistry returns a new auth.Client for the given registry. It authenticates the client if credentials are found in the system.

func CreateTarGzArchive added in v0.5.0

func CreateTarGzArchive(path string) (file string, err error)

CreateTarGzArchive compresses and saves in a tar archive the passed file.

func ExistsAndIsWritable

func ExistsAndIsWritable(path string) error

ExistsAndIsWritable checks if the directory specified by the path exists and is writable.

func ExtractTarGz

func ExtractTarGz(gzipStream io.Reader, destDir string) ([]string, error)

ExtractTarGz extracts a *.tar.gz compressed archive and moves its content to destDir. Returns a slice containing the full path of the extracted files.

func GetCredentials

func GetCredentials(p *output.Printer) (username, password string, err error)

GetCredentials is used to retrieve username and password from standard input.

func GetRegistryFromRef

func GetRegistryFromRef(ref string) (string, error)

GetRegistryFromRef extracts the registry from a ref string.

func Indexes

func Indexes(indexConfig *index.Config, path string) (*index.MergedIndexes, error)

Indexes returns the merge of all configured indexes.

func IsTarGz added in v0.5.0

func IsTarGz(fileName string) error

IsTarGz checks if the file is of type tar.gz.

func Move

func Move(oldPath, newPath string) error

Move moves oldPath file to to newPath file. It works also on different file system types.

func NameFromRef

func NameFromRef(ref string) (string, error)

NameFromRef extracts the name of the artifact from a ref string.

func PullerForRegistry

func PullerForRegistry(ctx context.Context, reg string, plainHTTP bool, printer *output.Printer) (*ocipuller.Puller, error)

PullerForRegistry returns a new ocipuller.Puller ready to be used for the given registry.

func PusherForRegistry

func PusherForRegistry(ctx context.Context, plainHTTP bool, reg string, printer *output.Printer) (*ocipusher.Pusher, error)

PusherForRegistry returns ane ocipusher.Pusher ready to be used for the given registry.

func WriteClientCredentials

func WriteClientCredentials(registry string, cred *clientcredentials.Config) error

WriteClientCredentials writes client credentials to config file.

Types

type RegistryClientCredentials

type RegistryClientCredentials map[string]clientcredentials.Config

RegistryClientCredentials is used to store registry:clientCrendetials key value. This is done to be in accordance with the way Docker stores credentials, so that users will be able to store only one credential per registry.

Jump to

Keyboard shortcuts

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