Skip to content

Commit

Permalink
(feat): Remove file system service cache
Browse files Browse the repository at this point in the history
  • Loading branch information
lasith-kg committed Nov 26, 2023
1 parent 40979df commit 351f315
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 3 additions & 1 deletion configs/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ devices:
mountOptions: defaults
group: ubuntu
user: ubuntu
permissions: 644
permissions: 644
remount: true
resizeFs: true
8 changes: 1 addition & 7 deletions internal/service/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@ type FileSystemServiceFactory interface {
}

type LinuxFileSystemServiceFactory struct {
services map[model.FileSystem]FileSystemService
RunnerFactory utils.RunnerFactory
}

func NewLinuxFileSystemServiceFactory(rc utils.RunnerFactory) *LinuxFileSystemServiceFactory {
return &LinuxFileSystemServiceFactory{
services: map[model.FileSystem]FileSystemService{},
RunnerFactory: rc,
}
}

func (fsf *LinuxFileSystemServiceFactory) Select(fs model.FileSystem) (FileSystemService, error) {
fss, exists := fsf.services[fs]
if exists {
return fss, nil
}
var fss FileSystemService
switch fs {
case model.Ext4:
fss = NewExt4Service(fsf.RunnerFactory)
Expand All @@ -47,7 +42,6 @@ func (fsf *LinuxFileSystemServiceFactory) Select(fs model.FileSystem) (FileSyste
case model.Unformatted:
return nil, fmt.Errorf("🔴 An unsupported filesystem was encountered")
}
fsf.services[fs] = fss
return fss, nil
}

Expand Down

0 comments on commit 351f315

Please sign in to comment.