Files
troubleshoot/pkg/convert/output.go
Craig O'Donnell 0a2ed01a46 improvement: added --output flag for preflight and support bundle (#538)
* improvement: added --output flag for preflight and support bundle

* improvement: added datetime to preflight default file name
2022-02-17 17:28:28 -05:00

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
}