Documentation
¶
Overview ¶
Package utils provides utility fns for UDS-CLI
Package utils provides utility fns for UDS-CLI
Index ¶
- func ByteFormat(in float64, precision int) string
- func CanWriteToDir(dir string) error
- func CheckYAMLSourcePath(source string) error
- func ConfigureLogs(cmd *cobra.Command) error
- func ExtractAllFiles(outDirPath string) archives.FileHandler
- func ExtractBytes(b *[]byte, expectedFilepath string) archives.FileHandler
- func ExtractFile(expectedFilepath, outDirPath string) archives.FileHandler
- func ExtractJSON(j any, expectedFilepath string) archives.FileHandler
- func GetPackageVerificationStrategy(skipSignatureValidation bool) layout.VerificationStrategy
- func GetPkgPath(pkg types.Package, arch string, manifestPath string) (string, error)
- func GetPkgSource(pkg types.Package, arch string, srcDir string) (string, error)
- func HandleSBOM(extractSBOM bool, SBOMArtifactPathMap map[string]string, ...) ([]string, error)
- func IncludeComponent(componentToCheck string, filteredComponents []v1alpha1.ZarfComponent) bool
- func IsRegistryURL(s string) bool
- func IsRemotePkg(pkg types.Package) bool
- func IsValidTarballPath(path string) bool
- func JSONValue(value any) (string, error)
- func LoadPackage(ctx context.Context, source string, opts packager.LoadOptions) (_ *layout.PackageLayout, err error)
- func LoadPackageFromDir(ctx context.Context, dirPath string, opts layout.PackageLayoutOptions) (*layout.PackageLayout, error)
- func NormalizeDir(path string) (string, error)
- func ReadYAMLStrict(path string, destConfig any) error
- func RenderProgressBarForLocalDirWrite(filepath string, expectedTotal int64, completeChan chan error, ...)
- func RoundUp(input float64, places int) float64
- func SBOMExtractor(dst string, SBOMArtifactPathMap map[string]string) archives.FileHandler
- func ToLocalFile(t any, filePath string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteFormat ¶ added in v0.28.3
ByteFormat formats a number of bytes into a human-readable string.
func CanWriteToDir ¶ added in v0.26.16
CanWriteToDir verifies the process can write to the provided directory
func CheckYAMLSourcePath ¶ added in v0.11.1
CheckYAMLSourcePath checks if the provided YAML source path is valid
func ConfigureLogs ¶ added in v0.10.0
ConfigureLogs sets up the log file, log cache and output for the CLI
func ExtractAllFiles ¶ added in v0.23.0
func ExtractAllFiles(outDirPath string) archives.FileHandler
ExtractAllFiles returns a archives.FileHandler that extracts all the contents of the archive into the provided outDirPath
func ExtractBytes ¶ added in v0.23.0
func ExtractBytes(b *[]byte, expectedFilepath string) archives.FileHandler
ExtractBytes returns an archives.FileHandler that extracts a byte contents of a file from an archive
func ExtractFile ¶ added in v0.23.0
func ExtractFile(expectedFilepath, outDirPath string) archives.FileHandler
ExtractFile returns an archives.FileHandler that extracts a file from an archive
func ExtractJSON ¶
func ExtractJSON(j any, expectedFilepath string) archives.FileHandler
ExtractJSON extracts and unmarshals a tarballed JSON file into a type
func GetPackageVerificationStrategy ¶ added in v0.28.0
func GetPackageVerificationStrategy(skipSignatureValidation bool) layout.VerificationStrategy
GetPackageVerificationStrategy determines the package verification strategy in which to pass to the Zarf SDK based on the skipSignatureValidation flag
func GetPkgPath ¶ added in v0.28.0
GetPkgPath returns the normalized path for a local package
func GetPkgSource ¶ added in v0.28.0
GetPkgSource returns the normalized remote or local source path for a package
func HandleSBOM ¶ added in v0.16.0
func HandleSBOM(extractSBOM bool, SBOMArtifactPathMap map[string]string, bundleName, dstPath string) ([]string, error)
HandleSBOM handles the extraction and creation of bundle SBOMs after populating SBOMArtifactPathMap
func IncludeComponent ¶ added in v0.11.0
func IncludeComponent(componentToCheck string, filteredComponents []v1alpha1.ZarfComponent) bool
IncludeComponent checks if a component has been specified in a a list of components (used for filtering optional components)
func IsRegistryURL ¶ added in v0.10.4
IsRegistryURL checks if a string is a URL
func IsRemotePkg ¶
IsRemotePkg returns true if the Zarf package is remote
func IsValidTarballPath ¶
IsValidTarballPath returns true if the path is a valid tarball path to a bundle tarball
func LoadPackage ¶ added in v0.28.0
func LoadPackage(ctx context.Context, source string, opts packager.LoadOptions) (_ *layout.PackageLayout, err error)
LoadPackage fetches, verifies (only if signed), and loads a Zarf package from the specified source.
func LoadPackageFromDir ¶ added in v0.28.0
func LoadPackageFromDir(ctx context.Context, dirPath string, opts layout.PackageLayoutOptions) (*layout.PackageLayout, error)
LoadFromDir loads and verifies a package (only if signed), from the given directory path.
func NormalizeDir ¶ added in v0.28.0
NormalizeDir returns the directory path for the file/dir path specified
func ReadYAMLStrict ¶ added in v0.11.0
ReadYAMLStrict reads a YAML file into a struct, with strict parsing
func RenderProgressBarForLocalDirWrite ¶ added in v0.28.3
func RenderProgressBarForLocalDirWrite(filepath string, expectedTotal int64, completeChan chan error, updateText string, successText string)
RenderProgressBarForLocalDirWrite creates a progress bar that continuously tracks the progress of writing files to a local directory and all of its subdirectories. NOTE: This function runs infinitely until either completeChan or errChan is triggered, this function should be run in a goroutine while a different thread/process is writing to the directory.
func SBOMExtractor ¶
func SBOMExtractor(dst string, SBOMArtifactPathMap map[string]string) archives.FileHandler
SBOMExtractor is the extraction fn for extracting HTML and JSON files from an sboms.tar archive
func ToLocalFile ¶
ToLocalFile takes an arbitrary type, typically a struct, marshals it into JSON and stores it as a local file
Types ¶
This section is empty.