feat(aa): add initial profile validation structure.

This commit is contained in:
Alexandre Pujol 2024-05-25 22:36:39 +01:00
parent 2dd6046697
commit 92641e7e28
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
20 changed files with 222 additions and 2 deletions

View file

@ -42,6 +42,10 @@ func newMountConditionsFromLog(log map[string]string) MountConditions {
return MountConditions{FsType: log["fstype"]}
}
func (m MountConditions) Validate() error {
return validateValues(tokMOUNT, "flags", m.Options)
}
func (m MountConditions) Less(other MountConditions) bool {
if m.FsType != other.FsType {
return m.FsType < other.FsType
@ -71,6 +75,13 @@ func newMountFromLog(log map[string]string) Rule {
}
}
func (r *Mount) Validate() error {
if err := r.MountConditions.Validate(); err != nil {
return fmt.Errorf("%s: %w", r, err)
}
return nil
}
func (r *Mount) Less(other any) bool {
o, _ := other.(*Mount)
if r.Source != o.Source {
@ -120,6 +131,13 @@ func newUmountFromLog(log map[string]string) Rule {
}
}
func (r *Umount) Validate() error {
if err := r.MountConditions.Validate(); err != nil {
return fmt.Errorf("%s: %w", r, err)
}
return nil
}
func (r *Umount) Less(other any) bool {
o, _ := other.(*Umount)
if r.MountPoint != o.MountPoint {
@ -166,6 +184,13 @@ func newRemountFromLog(log map[string]string) Rule {
}
}
func (r *Remount) Validate() error {
if err := r.MountConditions.Validate(); err != nil {
return fmt.Errorf("%s: %w", r, err)
}
return nil
}
func (r *Remount) Less(other any) bool {
o, _ := other.(*Remount)
if r.MountPoint != o.MountPoint {