wisski-cloud-distillery/internal/config/validators/files.go
Tom Wiesing 473040a69f
Remove environment.Environment struct
This commit completely removes the environment struct as it is no longer
used.
2023-03-02 12:52:51 +01:00

26 lines
519 B
Go

package validators
import (
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/pkg/errors"
)
func ValidateFile(path *string, dflt string) error {
if *path == "" {
*path = dflt
}
if !fsx.IsFile(*path) {
return errors.Errorf("%q does not exist or is not a file", *path)
}
return nil
}
func ValidateDirectory(path *string, dflt string) error {
if *path == "" {
*path = dflt
}
if !fsx.IsDirectory(*path) {
return errors.Errorf("%q does not exist or is not a directory", *path)
}
return nil
}