utils

package
v0.0.0-...-b21b196 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLiteralBlockScalarToTags

func AddLiteralBlockScalarToTags(yamlStr string) string

func AddQuotesToDescription

func AddQuotesToDescription(yamlData string) string

Some descriptions might contain brackets which blows up the yaml parser if not properly quoted. For example:

[DRAFT] DISA STIG for Red Hat Virtualization Host (RHVH)

func CheckoutBranch

func CheckoutBranch(path, branchName string) error

func CheckoutTag

func CheckoutTag(path, tagName string) error

func CloneRepo

func CloneRepo(url, path string) error

CloneRepo clones a Git repository and ensures it's fully cloned

func CompareSemVersions

func CompareSemVersions(op string, v1 *semver.Version, v2 *semver.Version) (bool, error)

func CopyFile

func CopyFile(src string, dst string) error
func CreateSymlink(srcFile string, linkName string) error

func CreateTempDirectory

func CreateTempDirectory() (string, error)

func DownloadBinaryFileToPath

func DownloadBinaryFileToPath(urlStr string, filePath string) (string, error)

func DownloadBinaryFileToPathWithBearerToken

func DownloadBinaryFileToPathWithBearerToken(urlStr string, token string, filePath string) (string, error)

func DownloadBinaryFilesConcurrently

func DownloadBinaryFilesConcurrently(items []DownloadItem, maxWorkers int)

func DownloadFile

func DownloadFile(urlStr string) (string, error)

func DownloadJSONFilesConcurrently

func DownloadJSONFilesConcurrently(items []DownloadItem, maxWorkers int)

func EndsWithMetaMainYAML

func EndsWithMetaMainYAML(filename string) bool

func ExpandUser

func ExpandUser(path string) string

func ExtractFilesFromTarGz

func ExtractFilesFromTarGz(filepath string, filenamesToExtract []string) (map[string][]byte, error)

func ExtractJSONFilesFromTarGz

func ExtractJSONFilesFromTarGz(tarGzPath string, jsonFileNames []string) (map[string][]byte, error)

func ExtractRoleTarGz

func ExtractRoleTarGz(tarGzPath, dest string) error

ExtractTarGz extracts a tar.gz file to the specified destination

func ExtractTarGz

func ExtractTarGz(tarGzPath, dest string) error

func FileExists

func FileExists(filePath string) bool

func FilterAndSortSemver

func FilterAndSortSemver(versions []string) ([]string, error)

func FindMatchingFiles

func FindMatchingFiles(directory string, pattern string) ([]string, error)

func FixGalaxyIndentation

func FixGalaxyIndentation(yamlData string) (string, error)

Some meta/main.yml files have improperly independented "dependencies" keys.

func FixPlatformVersion

func FixPlatformVersion(yamlStr string) string

func FixRoleMetaMainYaml

func FixRoleMetaMainYaml(yamlStr string) string

AGGREGATE FIX IT ALL ...

func GetAbsPath

func GetAbsPath(path string) (string, error)

func GetCommitDate

func GetCommitDate(repoPath string, commitHash string) (string, error)

func GetGoroutineID

func GetGoroutineID() uint64

GetGoroutineID gets the ID of the current goroutine.

func GetHighestSemver

func GetHighestSemver(versions []string) (string, error)

func GetLatestCommitHash

func GetLatestCommitHash(repoPath string) (string, error)

func IsDir

func IsDir(path string) bool

func IsDirEmpty

func IsDirEmpty(dirPath string) (bool, error)

func IsFile

func IsFile(path string) bool
func IsLink(path string) bool

func IsURL

func IsURL(str string) bool

isURL checks if a given string is a valid URL

func IsURLGood

func IsURLGood(url string) bool

func IsValidGitRepo

func IsValidGitRepo(repoPath string) (bool, error)

func ListFilenamesInTarGz

func ListFilenamesInTarGz(filepath string) ([]string, error)

func ListTags

func ListTags(path string) ([]string, error)

listTags lists the tags in the given repository path

func ListTarGzFiles

func ListTarGzFiles(dir string) ([]string, error)

func MakeDirs

func MakeDirs(path string) error

func ParseISODate

func ParseISODate(dateStr string) (string, error)

Helper function to parse and format date strings to ISO format

func PrettyPrint

func PrettyPrint(v interface{}) (string, error)

func RemoveComments

func RemoveComments(yamlStr string) string

func RemoveDependenciesLiteralIfNoDeps

func RemoveDependenciesLiteralIfNoDeps(yamlStr string) string

func RemoveFirstPathElement

func RemoveFirstPathElement(path string) string

func ReplaceDependencyRoleWithName

func ReplaceDependencyRoleWithName(yamlStr string) string

func SplitSpec

func SplitSpec(input string) []string

Types

type DownloadItem

type DownloadItem struct {
	URL      string
	FilePath string
}

type FileInfo

type FileInfo struct {
	Path string
	Type string
}

FileInfo holds information about the file type

func GetFileInfo

func GetFileInfo(path string) (*FileInfo, error)

type FileStore

type FileStore struct {
	Files []FileInfo
}

cache known files on disk

func (*FileStore) AddFile

func (fs *FileStore) AddFile(file FileInfo)

func (*FileStore) FindByGlob

func (fs *FileStore) FindByGlob(pattern string) []string

FindByGlob finds and returns all FileInfo objects with paths matching the given glob pattern

type GoroutineIDHook

type GoroutineIDHook struct{}

GoroutineIDHook is a logrus hook that adds the goroutine ID to log entries.

func (*GoroutineIDHook) Fire

func (hook *GoroutineIDHook) Fire(entry *logrus.Entry) error

func (*GoroutineIDHook) Levels

func (hook *GoroutineIDHook) Levels() []logrus.Level

type InstallSpec

type InstallSpec struct {
	Namespace    string
	Name         string
	Version      string
	Dependencies []InstallSpec
}

func (InstallSpec) Equals

func (spec InstallSpec) Equals(other InstallSpec) bool

Jump to

Keyboard shortcuts

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