wisski-cloud-distillery/internal/config/validators/files.go
Tom Wiesing 3263920d6b
fsx: Remove environment references
This commit removes the reference to the environment from the fsx
package.
2023-03-02 11:51:51 +01:00

27 lines
633 B
Go

package validators
import (
"github.com/FAU-CDI/wisski-distillery/pkg/environment"
"github.com/FAU-CDI/wisski-distillery/pkg/fsx"
"github.com/pkg/errors"
)
func ValidateFile(env environment.Environment, 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(env environment.Environment, 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
}