Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support of mutually exclusive mount options #54

Merged
merged 1 commit into from
May 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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