mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
* improvement: added --output flag for preflight and support bundle * improvement: added datetime to preflight default file name
20 lines
495 B
Go
20 lines
495 B
Go
package convert
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// ValidateOutputPath takes an output file path and returns it as an absolute path.
|
|
// It returns an error if the absolute path cannot be determined or if the parent directory does not exist.
|
|
func ValidateOutputPath(outputPath string) (string, error) {
|
|
outputPath, err := filepath.Abs(outputPath)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if _, err := os.Stat(filepath.Dir(outputPath)); err != nil {
|
|
return "", err
|
|
}
|
|
return outputPath, nil
|
|
}
|