Skip to content

Commit

Permalink
Add Repository Validation for local backend mountPath (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
suaas21 authored and tamalsaha committed Dec 26, 2019
1 parent f28abce commit 35e8db6
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions apis/stash/v1alpha1/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,15 @@ func (r Repository) IsValid() error {
return fmt.Errorf("wipe out operation is not supported for B2 backend")
}
}

if r.Spec.Backend.Local != nil && r.Spec.Backend.Local.MountPath != "" {
parts := strings.Split(r.Spec.Backend.Local.MountPath, "/")
if len(parts) >= 2 && parts[1] == "stash" {
return fmt.Errorf("\n\t" +
"Error: Invalid `mountPath` specification for local backend.\n\t" +
"Reason: We have put `stash` binary in the root directory. Hence, you can not use `/stash` or `/stash/*` as `mountPath` \n\t" +
"Hints: Use `/stash-backup` or anything else except the forbidden ones as `mountPath`.")
}
}
return nil
}

0 comments on commit 35e8db6

Please sign in to comment.