mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-04 01:30: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() {
|
if !CheckIfResticIsCallable() {
|
||||||
return fmt.Errorf(`%s was not found. Install either with "autorestic install" or manually`, flags.RESTIC_BIN)
|
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
|
cwd, _ := GetPathRelativeToConfig(".")
|
||||||
if err := backend.validate(); err != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for name, location := range c.Locations {
|
|
||||||
location.name = name
|
for name, backend := range c.Backends {
|
||||||
if err := location.validate(); err != nil {
|
backend.name = name
|
||||||
|
if err := backend.validate(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user