Documentation ¶
Overview ¶
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Copyright 2020 New Relic Corporation. All rights reserved. SPDX-License-Identifier: Apache-2.0
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrGetFileStats is returned when it fails to get file stat. ErrGetFileStats = errors.New("can't get stat for file") // ErrNotYAMLFile is returned in case the path doesn't have a valid yaml extension. ErrNotYAMLFile = errors.New("file is a directory or is not an accepted YAML extension") )
View Source
var ( ErrFolderNotFound = errors.New("folder not found") ErrFilesNotFound = errors.New("files not found") )
Errors
View Source
var ( // OSFilesInFolderFn returns the list of hopefully readable files for a folder. // This is a best effort guessing readability as official Go authors say: // > only reliable strategy is to just try to open it for read and see if it fails // https://golang-dev.narkive.com/FJOvNshy/isreadable-iswriteable-isfile-touch OSFilesInFolderFn = func(folderPath string) (filePaths []string, err error) { files, err := ioutil.ReadDir(folderPath) if err != nil { if _, ok := err.(*os.PathError); ok { err = ErrFolderNotFound } return } for _, file := range files { if !file.IsDir() { perm := file.Mode().Perm() if perm&readableMask == 0 { continue } filePaths = append(filePaths, filepath.Join(folderPath, file.Name())) } } if len(filePaths) == 0 { err = ErrFilesNotFound } return } )
Functions ¶
func ValidateYAMLFile ¶
ValidateYAMLFile checks if the file exists(excepting if it has been marked for deletion) and if its it has a YAML extension.
Types ¶
type FilesInFolderFn ¶
FilesInFolderFn returns the files (paths) within a folder (path).
Click to show internal directories.
Click to hide internal directories.