diff --git a/internal/action/file.go b/internal/action/file.go index 4240ecb..d99ba6b 100644 --- a/internal/action/file.go +++ b/internal/action/file.go @@ -92,12 +92,12 @@ func (a *ChangeOwnerAction) Success() string { type ChangePermissionsAction struct { path string - perms model.Permissions + perms model.FilePermissions mode config.Mode fileService service.FileService } -func NewChangePermissions(p string, perms model.Permissions, fs service.FileService) *ChangePermissionsAction { +func NewChangePermissions(p string, perms model.FilePermissions, fs service.FileService) *ChangePermissionsAction { return &ChangePermissionsAction{ path: p, perms: perms, diff --git a/internal/backend/file.go b/internal/backend/file.go index 32f5e23..b41a49e 100644 --- a/internal/backend/file.go +++ b/internal/backend/file.go @@ -14,7 +14,7 @@ import ( type FileBackend interface { CreateDirectory(p string) action.Action ChangeOwner(p string, uid int, gid int) action.Action - ChangePermissions(p string, perms model.Permissions) action.Action + ChangePermissions(p string, perms model.FilePermissions) action.Action GetDirectory(p string) (*model.File, error) IsMount(p string) bool From(config *config.Config) error @@ -40,7 +40,7 @@ func (lfb *LinuxFileBackend) ChangeOwner(p string, uid int, gid int) action.Acti return action.NewChangeOwnerAction(p, uid, gid, lfb.fileService) } -func (lfb *LinuxFileBackend) ChangePermissions(p string, perms model.Permissions) action.Action { +func (lfb *LinuxFileBackend) ChangePermissions(p string, perms model.FilePermissions) action.Action { return action.NewChangePermissions(p, perms, lfb.fileService) } diff --git a/internal/config/config.go b/internal/config/config.go index 8a7a56f..1fe63e0 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -52,17 +52,17 @@ type Flag struct { } type Device struct { - Fs model.FileSystem `yaml:"fs"` - MountPoint string `yaml:"mountPoint"` - MountOptions model.MountOptions `yaml:"mountOptions"` - User string `yaml:"user"` - Group string `yaml:"group"` - Label string `yaml:"label"` - Permissions model.Permissions `yaml:"permissions"` - Mode Mode `yaml:"mode"` - Remount bool `yaml:"remount"` - ResizeFs bool `yaml:"resizeFs"` - ResizeThreshold float64 `yaml:"resizeThreshold"` + Fs model.FileSystem `yaml:"fs"` + MountPoint string `yaml:"mountPoint"` + MountOptions model.MountOptions `yaml:"mountOptions"` + User string `yaml:"user"` + Group string `yaml:"group"` + Label string `yaml:"label"` + Permissions model.FilePermissions `yaml:"permissions"` + Mode Mode `yaml:"mode"` + Remount bool `yaml:"remount"` + ResizeFs bool `yaml:"resizeFs"` + ResizeThreshold float64 `yaml:"resizeThreshold"` } type Defaults struct { diff --git a/internal/model/file.go b/internal/model/file.go index 1cf7d8c..7400466 100644 --- a/internal/model/file.go +++ b/internal/model/file.go @@ -21,22 +21,22 @@ type File struct { InodeNo int Uid int // User ID Gid int // Group ID - Permissions Permissions + Permissions FilePermissions } -type Permissions uint32 +type FilePermissions uint32 -func (p Permissions) Perm() fs.FileMode { +func (p FilePermissions) Perm() fs.FileMode { return fs.FileMode(p) } -func (p *Permissions) UnmarshalYAML(unmarshal func(interface{}) error) error { - var ps string; +func (p *FilePermissions) UnmarshalYAML(unmarshal func(interface{}) error) error { + var ps string if err := unmarshal(&ps); err != nil { return err } if ps == "" { - *p = Permissions(0) + *p = FilePermissions(0) return nil } // Base: 8, Bit Length: 32 @@ -47,6 +47,6 @@ func (p *Permissions) UnmarshalYAML(unmarshal func(interface{}) error) error { if mode > 0777 { return fmt.Errorf("🔴 invalid permission value. '%#o' exceeds the maximum allowed value (0777)", mode) } - *p = Permissions(mode) + *p = FilePermissions(mode) return nil -} \ No newline at end of file +} diff --git a/internal/service/file.go b/internal/service/file.go index ba4e448..e7f184a 100644 --- a/internal/service/file.go +++ b/internal/service/file.go @@ -18,7 +18,7 @@ type FileService interface { GetFile(file string) (*model.File, error) CreateDirectory(path string) error ChangeOwner(file string, uid int, gid int) error - ChangePermissions(file string, perms model.Permissions) error + ChangePermissions(file string, perms model.FilePermissions) error } // File Service Interface [END] @@ -50,7 +50,7 @@ func (ufs *UnixFileService) GetFile(file string) (*model.File, error) { InodeNo: int(stat.Ino), Uid: int(stat.Uid), Gid: int(stat.Gid), - Permissions: model.Permissions(info.Mode().Perm()), + Permissions: model.FilePermissions(info.Mode().Perm()), Type: ft, }, nil } @@ -65,6 +65,6 @@ func (ufs *UnixFileService) ChangeOwner(file string, uid int, gid int) error { return os.Chown(file, uid, gid) } -func (ufs *UnixFileService) ChangePermissions(file string, perms model.Permissions) error { +func (ufs *UnixFileService) ChangePermissions(file string, perms model.FilePermissions) error { return os.Chmod(file, perms.Perm()) }