filesystem

package
v1.7.7 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: Apache-2.0 Imports: 22 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArchiveDir added in v0.2.3

func ArchiveDir(ctx context.Context, fs billy.Filesystem, srcPath, destTgzPath string) error

ArchiveDir archives a directory or a file into a tgz file and put it at destTgzPath which should end with .tgz

func CompareDirs

func CompareDirs(ctx context.Context, fs billy.Filesystem, leftDirpath, rightDirpath string, leftOnlyFunc, rightOnlyFunc RelativePathFunc, bothFunc RelativePathPairFunc) error

CompareDirs compares the contents of the directory at fromDirpath against that of the directory at toDirpath within a given filesystem It execute leftOnlyFunc on paths that only exist on the leftDirpath and rightOnlyFunc on paths that only exist on rightDirpath It executes bothFunc on paths that exist on both the left and the right. Order will be preserved in the function arguments

func CompareTgzs added in v0.3.0

func CompareTgzs(ctx context.Context, fs billy.Filesystem, leftTgzPath string, rightTgzPath string) (bool, error)

CompareTgzs checks to see if the file contents of the archive found at leftTgzPath matches that of the archive found at rightTgzPath It does this by comparing the sha256sum of the file contents, ignoring any other information (e.g. file modes, timestamps, etc.)

func CopyDir

func CopyDir(ctx context.Context, fs billy.Filesystem, srcDir string, dstDir string) error

CopyDir copies all files from srcDir to dstDir

func CopyFile

func CopyFile(ctx context.Context, fs billy.Filesystem, srcPath string, dstPath string) error

CopyFile copies a file from srcPath to dstPath within a filesystem. It creates any relevant directories along the way

func CreateAndOpenYamlFile added in v1.6.5

func CreateAndOpenYamlFile(ctx context.Context, filePath string, truncate bool) (*os.File, error)

CreateAndOpenYamlFile creates a new yaml file or opens an existing one. The behavior is controlled by the truncate flag.

Parameters:

  • ctx: The context for logging.
  • filePath: The full path to the yaml file.
  • truncate: If true, the file is created or truncated. If false, it's opened for read/write, or created if it doesn't exist.

func CreateFileAndDirs

func CreateFileAndDirs(fs billy.Filesystem, path string) (billy.File, error)

CreateFileAndDirs creates a file on the filesystem and all relevant directories along the way if they do not exist. The file that is created must be closed by the caller

func DecodeTgzValuesYamlMap added in v1.6.5

func DecodeTgzValuesYamlMap(ctx context.Context, assetsTgzs []string) (map[string][]map[string]interface{}, error)

DecodeTgzValuesYamlMap will untar into memory the given .tgz file paths.

func DecodeValueYamlInTgz added in v1.6.5

func DecodeValueYamlInTgz(ctx context.Context, tgzPath string, fileNames []string) ([]map[string]interface{}, error)

DecodeValueYamlInTgz will untar into-memory a given .tgz file and map it, normalizing the fields as strings enabling O(1) operations when searching for a target key which corresponds to a yaml field.

func GetAbsPath

func GetAbsPath(fs billy.Filesystem, path string) string

GetAbsPath returns the absolute path given the relative path within a filesystem

func GetChartArchive

func GetChartArchive(fs billy.Filesystem, url string, path string) error

GetChartArchive gets a chart tgz file from a url and drops it into the path specified on the filesystem

func GetFilesystem

func GetFilesystem(path string) billy.Filesystem

GetFilesystem returns a filesystem rooted at the provided path

func GetRelativePath

func GetRelativePath(fs billy.Filesystem, abspath string) (string, error)

GetRelativePath returns the relative path given the absolute path within a filesystem

func GetRootPath

func GetRootPath(ctx context.Context, path string) (string, error)

GetRootPath returns the first directory in a given path

func IsEmptyDir

func IsEmptyDir(ctx context.Context, fs billy.Filesystem, path string) (bool, error)

IsEmptyDir returns whether the path provided is an empty directory or an error

func LoadYamlFile added in v1.6.5

func LoadYamlFile[YamlFields any](ctx context.Context, filepath string, ignoreFormat bool) (*YamlFields, error)

LoadYamlFile is a generic function that loads a YAML file and decodes it efficiently (especially for large files) using a streaming approach into a struct of type YamlFields, specified by the caller. YamlFields is expected to be a struct suitable for YAML unmarshalling.

  • filepath: entire file path to the .yaml file
  • ignoreFormat: ignore legacy yaml format errors

func MakeSubdirectoryRoot

func MakeSubdirectoryRoot(ctx context.Context, fs billy.Filesystem, path, subdirectory string) error

MakeSubdirectoryRoot makes a particular subdirectory of a path its main directory

func MovePath

func MovePath(ctx context.Context, path string, fromDir string, toDir string) (string, error)

MovePath takes a path that is contained within fromDir and returns the same path contained within toDir

func PathExists

func PathExists(ctx context.Context, fs billy.Filesystem, path string) (bool, error)

PathExists checks if a path exists on the filesystem or returns an error

func PruneEmptyDirsInPath

func PruneEmptyDirsInPath(ctx context.Context, fs billy.Filesystem, path string) error

PruneEmptyDirsInPath removes all empty directories located within the path

func RemoveAll

func RemoveAll(fs billy.Filesystem, path string) error

RemoveAll removes all files and directories located at the path

func UnarchiveTgz

func UnarchiveTgz(ctx context.Context, fs billy.Filesystem, tgzPath, tgzSubdirectory, destPath string, overwrite bool) error

UnarchiveTgz attempts to unarchive the tgz file found at tgzPath in the filesystem

func UpdatePermissions

func UpdatePermissions(fs billy.Filesystem, path string, mode int64) error

UpdatePermissions updates the permissions for a given path to the mode provided

func UpdateYamlFile added in v1.6.5

func UpdateYamlFile(file *os.File, imageTagMap map[string][]string) error

UpdateYamlFile receives a map and updates a yaml file

func WalkAssetsFolderTgzFiles added in v1.6.5

func WalkAssetsFolderTgzFiles(ctx context.Context) ([]string, error)

WalkAssetsFolderTgzFiles will walk and retrieve all .tgz files on the assets folder.

func WalkDir

func WalkDir(ctx context.Context, fs billy.Filesystem, dirPath string, doFunc RelativePathFunc) error

WalkDir walks through a directory given by dirPath rooted in the filesystem and performs doFunc at the path The path on each call will be relative to the filesystem provided.

func WalkFilteredAssetsFolder added in v1.6.5

func WalkFilteredAssetsFolder(ctx context.Context, imageTagMap, filter map[string][]string, chartsToIgnoreTags map[string]string) error

WalkAssetsFolder walks over the assets folder, untars files if their name matches one of the filter values, stores the values.yaml content into a map and then iterates over the map to collect the image repo and tag values into another map.

Types

type RelativePathFunc

type RelativePathFunc func(ctx context.Context, fs billy.Filesystem, path string, isDir bool) error

RelativePathFunc is a function that is applied on a relative path within the given filesystem

type RelativePathPairFunc

type RelativePathPairFunc func(ctx context.Context, fs billy.Filesystem, leftPath, rightPath string, isDir bool) error

RelativePathPairFunc is a function that is applied on a pair of relative paths in a filesystem

type StreamReader added in v1.6.5

type StreamReader func() (io.ReadCloser, error)

StreamReader func() type is callback function for custom filesystem file loading behavior

Jump to

Keyboard shortcuts

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