Documentation
¶
Index ¶
- Constants
- Variables
- func EnsureYAMLExtension(filename string) string
- func FileExists(file string) bool
- func IsDir(path string) bool
- func IsFileWithExtension(filename string, validExtensions []string) bool
- func IsYAMLFile(filename string) bool
- func MustGetUserHomeDir() string
- func MustGetwd() string
- func MustTempDir(pattern string) string
- func OpenOrCreateFile(file string) (*os.File, error)
- func SafeName(str string) string
- func TruncString(val string, max int) string
- type FileNotFoundError
- type FileResolver
Constants ¶
const (
// MaxSafeNameLength is the maximum length of a safe filename
MaxSafeNameLength = 100
)
Variables ¶
var ( ErrUnexpectedEOF = errors.New("unexpected end of input after escape character") ErrUnknownEscapeSequence = errors.New("unknown escape sequence") )
var ValidYAMLExtensions = []string{yamlExtension, ymlExtension}
ValidYAMLExtensions contains valid YAML extensions.
Functions ¶
func EnsureYAMLExtension ¶
EnsureYAMLExtension adds .yaml extension if not present if it has .yml extension, replace it with .yaml
func IsFileWithExtension ¶
IsFileWithExtension is a more generic function that checks if a file has any of the provided extensions.
func IsYAMLFile ¶
IsYAMLFile checks if a file has a valid YAML extension (.yaml or .yml). Returns false for empty strings or files without extensions.
func MustGetUserHomeDir ¶
func MustGetUserHomeDir() string
MustGetUserHomeDir returns current working directory. Panics is os.UserHomeDir() returns error
func MustGetwd ¶
func MustGetwd() string
MustGetwd returns current working directory. Panics is os.Getwd() returns error
func MustTempDir ¶
MustTempDir returns temporary directory. This function is used only for testing.
func OpenOrCreateFile ¶
OpenOrCreateFile opens file or creates it if it doesn't exist.
func TruncString ¶
TruncString TurnString returns truncated string.
Types ¶
type FileNotFoundError ¶
FileNotFoundError provides detailed information about file search failure
func (*FileNotFoundError) Error ¶
func (e *FileNotFoundError) Error() string
type FileResolver ¶
type FileResolver struct {
// contains filtered or unexported fields
}
FileResolver handles file path resolution across multiple locations
func NewFileResolver ¶
func NewFileResolver(relativeTos []string) *FileResolver
NewFileResolver creates a new FileResolver instance
func (*FileResolver) ResolveFilePath ¶
func (r *FileResolver) ResolveFilePath(file string) (string, error)
ResolveFilePath attempts to find a file in multiple locations in the following order: 1. As an absolute path 2. Relative to the DAG directory 3. Relative to the base config directory 4. Relative to the user's home directory