Documentation ¶
Overview ¶
Package utils implements common utility functions.
Index ¶
- Constants
- Variables
- func CreateTarGzArchive(dir, path string) (file string, err error)
- func ExistsAndIsWritable(path string) error
- func ExtractTarGz(ctx context.Context, gzipStream io.Reader, destDir string, ...) ([]string, error)
- func FileExists(filename string) (bool, error)
- func GetCredentials(p *output.Printer) (username, password string, err error)
- func GetRegistryFromRef(ref string) (string, error)
- func IsTarGz(fileName string) error
- func Move(oldPath, newPath string) error
- func NameFromRef(ref string) (string, error)
- func ReplaceLineInFile(filePath, searchFor, newLine string, n int) error
- func ReplaceTextInFile(filePath, searchFor, newText string, n int) error
- func RepositoryFromRef(ref string) (string, error)
Constants ¶
const TmpDirPrefix = "diginfractl-registry-push-"
TmpDirPrefix prefix used for the temporary directory where the tar.gz archives live before pushing to the OCI registry.
Variables ¶
var ErrNotTarGz = errors.New("not a tar.gz archive")
ErrNotTarGz returned when the file is not a tar.gz archive.
Functions ¶
func CreateTarGzArchive ¶
CreateTarGzArchive compresses and saves in a tar archive the passed file.
func ExistsAndIsWritable ¶
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 ¶
FileExists checks if a file exists on disk.
func GetCredentials ¶
GetCredentials is used to retrieve username and password from standard input.
func GetRegistryFromRef ¶
GetRegistryFromRef extracts the registry from a ref string.
func Move ¶
Move moves oldPath file to to newPath file. It works also on different file system types.
func NameFromRef ¶
NameFromRef extracts the name of the artifact from a ref string.
func ReplaceLineInFile ¶
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 ¶
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 ¶
RepositoryFromRef extracts the registry+repository from a ref string.
Types ¶
This section is empty.