Skip to content

Commit

Permalink
fix: better fix for mount options Merge with mutually excluding optio…
Browse files Browse the repository at this point in the history
…ns (#54)
  • Loading branch information
sergeyberezansky authored May 7, 2023
1 parent bb81211 commit 6a9abcb
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pkg/wekafs/mountoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ type MountOptions struct {
func (opts MountOptions) Merge(other MountOptions, exclusives []mutuallyExclusiveMountOptionSet) {
for _, otherOpt := range other.customOptions {
opts.customOptions[otherOpt.option] = otherOpt
for _, exclusiveOpts := range exclusives {
for _, opt := range exclusiveOpts {
// iterate on all sets of mutually exclusive options
for _, exclusiveOptsSet := range exclusives {
// iterate on all options in one exclusive set
for _, opt := range exclusiveOptsSet {
if otherOpt.option == opt {
for _, optionToDrop := range exclusiveOpts {
delete(opts.customOptions, optionToDrop)
// if the option exists in exclusiveOptsSet, we need to drop all its alternatives from original options
for _, optionToDrop := range exclusiveOptsSet {
if optionToDrop != opt {
delete(opts.customOptions, optionToDrop)
}
}
break // stop iterating on the rest
}
}
}
Expand Down

0 comments on commit 6a9abcb

Please sign in to comment.