wisski-cloud-distillery/internal/config/validators/files.go
Tom Wiesing 945329a080
Move to yaml-based configuration
This commit updates the configuration to be yaml-based and updates the
configuration to read in a yaml file.
2023-02-25 09:14:56 +01:00

27 lines
643 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(env, *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(env, *path) {
return errors.Errorf("%q does not exist or is not a directory", *path)
}
return nil
}