utils

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 14 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 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(ctx context.Context, gzipStream io.Reader, destDir string, stripPathComponents int) ([]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 FileExists added in v0.7.0

func FileExists(filename string) (bool, error)

FileExists checks if a file exists on disk.

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 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 ReplaceLineInFile added in v0.7.0

func ReplaceLineInFile(filePath, searchFor, newLine string, n int) error

ReplaceLineInFile searches for occurrences of searchFor in the file pointed by filePath, and substitutes the whole matching line with the provided one. At most n substitutions are made. If n < 0, there is no limit on the number of replacements.

func ReplaceTextInFile added in v0.7.0

func ReplaceTextInFile(filePath, searchFor, newText string, n int) error

ReplaceTextInFile searches for occurrences of searchFor in the file pointed by filePath, and substitutes the matching string with the provided one. At most n substitutions are made. If n < 0, there is no limit on the number of replacements.

func RepositoryFromRef added in v0.6.0

func RepositoryFromRef(ref string) (string, error)

RepositoryFromRef extracts the registry+repository from a ref string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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