feat(aa): add merge methods to the rule interface.
This commit is contained in:
parent
a91e2ddf56
commit
6791dcde28
14 changed files with 192 additions and 11 deletions
|
|
@ -65,6 +65,14 @@ func (m MountConditions) Compare(other MountConditions) int {
|
|||
return compare(m.Options, other.Options)
|
||||
}
|
||||
|
||||
func (m MountConditions) Merge(other MountConditions) bool {
|
||||
if m.FsType == other.FsType {
|
||||
m.Options = merge(MOUNT, "flags", m.Options, other.Options)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type Mount struct {
|
||||
RuleBase
|
||||
Qualifier
|
||||
|
|
@ -133,6 +141,19 @@ func (r *Mount) Compare(other Rule) int {
|
|||
return r.Qualifier.Compare(o.Qualifier)
|
||||
}
|
||||
|
||||
func (r *Mount) Merge(other Rule) bool {
|
||||
o, _ := other.(*Mount)
|
||||
|
||||
if !r.Qualifier.Equal(o.Qualifier) {
|
||||
return false
|
||||
}
|
||||
if r.Source == o.Source && r.MountPoint == o.MountPoint &&
|
||||
r.MountConditions.Merge(o.MountConditions) {
|
||||
return r.RuleBase.merge(o.RuleBase)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Mount) String() string {
|
||||
return renderTemplate(r.Kind(), r)
|
||||
}
|
||||
|
|
@ -197,6 +218,18 @@ func (r *Umount) Compare(other Rule) int {
|
|||
return r.Qualifier.Compare(o.Qualifier)
|
||||
}
|
||||
|
||||
func (r *Umount) Merge(other Rule) bool {
|
||||
o, _ := other.(*Umount)
|
||||
|
||||
if !r.Qualifier.Equal(o.Qualifier) {
|
||||
return false
|
||||
}
|
||||
if r.MountPoint == o.MountPoint && r.MountConditions.Merge(o.MountConditions) {
|
||||
return r.RuleBase.merge(o.RuleBase)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Umount) String() string {
|
||||
return renderTemplate(r.Kind(), r)
|
||||
}
|
||||
|
|
@ -262,6 +295,18 @@ func (r *Remount) Compare(other Rule) int {
|
|||
return r.Qualifier.Compare(o.Qualifier)
|
||||
}
|
||||
|
||||
func (r *Remount) Merge(other Rule) bool {
|
||||
o, _ := other.(*Remount)
|
||||
|
||||
if !r.Qualifier.Equal(o.Qualifier) {
|
||||
return false
|
||||
}
|
||||
if r.MountPoint == o.MountPoint && r.MountConditions.Merge(o.MountConditions) {
|
||||
return r.RuleBase.merge(o.RuleBase)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (r *Remount) String() string {
|
||||
return renderTemplate(r.Kind(), r)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue