mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-01 08:10:39 +00:00
feat: Run PreValidate hooks for check cmd (#437)
PreValidate can be used to mount remote directories (e.g. via NFS) so
they must executed first before running any restic commands.
This was done for the backup command in 13aa560
, but not for check. This
commit fixes that.
This commit is contained in:
@@ -188,15 +188,31 @@ func CheckConfig() error {
|
||||
if !CheckIfResticIsCallable() {
|
||||
return fmt.Errorf(`%s was not found. Install either with "autorestic install" or manually`, flags.RESTIC_BIN)
|
||||
}
|
||||
for name, backend := range c.Backends {
|
||||
backend.name = name
|
||||
if err := backend.validate(); err != nil {
|
||||
|
||||
cwd, _ := GetPathRelativeToConfig(".")
|
||||
for name, location := range c.Locations {
|
||||
location.name = name
|
||||
|
||||
// Hooks before location validation
|
||||
options := ExecuteOptions{
|
||||
Command: "bash",
|
||||
Dir: cwd,
|
||||
Envs: map[string]string{
|
||||
"AUTORESTIC_LOCATION": location.name,
|
||||
},
|
||||
}
|
||||
if err := location.ExecuteHooks(location.Hooks.PreValidate, options); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := location.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
for name, location := range c.Locations {
|
||||
location.name = name
|
||||
if err := location.validate(); err != nil {
|
||||
|
||||
for name, backend := range c.Backends {
|
||||
backend.name = name
|
||||
if err := backend.validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user