Skip to content

Commit

Permalink
Move ignore-interrupts to new config.
Browse files Browse the repository at this point in the history
  • Loading branch information
kislaykishore committed Jul 6, 2024
1 parent 820cab8 commit cd225a6
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 53 deletions.
1 change: 0 additions & 1 deletion cmd/legacy_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func runCLIApp(c *cli.Context) (err error) {
return fmt.Errorf("error resolving flags and configs: %w", err)
}

config.OverrideWithIgnoreInterruptsFlag(c, mountConfig, flags.IgnoreInterrupts)
config.OverrideWithAnonymousAccessFlag(c, mountConfig, flags.AnonymousAccess)
config.OverrideWithKernelListCacheTtlFlag(c, mountConfig, flags.KernelListCacheTtlSeconds)

Expand Down
9 changes: 0 additions & 9 deletions internal/config/config_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ type cliContext interface {
IsSet(string) bool
}

// OverrideWithIgnoreInterruptsFlag overwrites the ignore-interrupts config with
// the ignore-interrupts flag value if the flag is set.
func OverrideWithIgnoreInterruptsFlag(c cliContext, mountConfig *MountConfig, ignoreInterruptsFlag bool) {
// If the ignore-interrupts flag is set, give it priority over the value in config file.
if c.IsSet(IgnoreInterruptsFlagName) {
mountConfig.FileSystemConfig.IgnoreInterrupts = ignoreInterruptsFlag
}
}

// OverrideWithAnonymousAccessFlag overwrites the anonymous-access config with
// the anonymous-access flag value if the flag is set.
func OverrideWithAnonymousAccessFlag(c cliContext, mountConfig *MountConfig, anonymousAccess bool) {
Expand Down
28 changes: 0 additions & 28 deletions internal/config/config_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,34 +85,6 @@ func (s *TestCliContext) IsSet(flag string) bool {
return s.isSet
}

func TestOverrideWithIgnoreInterruptsFlag(t *testing.T) {
var overrideWithIgnoreInterruptsFlagTests = []struct {
testName string
ignoreInterruptConfigValue bool
isFlagSet bool
ignoreInterruptFlagValue bool
expectedIgnoreInterrupt bool
}{
{"ignore-interrupts config true and flag not set", true, false, false, true},
{"ignore-interrupts config false and flag not set", false, false, false, false},
{"ignore-interrupts config false and ignore-interrupts flag false", false, true, false, false},
{"ignore-interrupts config false and ignore-interrupts flag true", false, true, true, true},
{"ignore-interrupts config true and ignore-interrupts flag false", true, true, false, false},
{"ignore-interrupts config true and ignore-interrupts flag true", true, true, true, true},
}

for _, tt := range overrideWithIgnoreInterruptsFlagTests {
t.Run(tt.testName, func(t *testing.T) {
testContext := &TestCliContext{isSet: tt.isFlagSet}
mountConfig := &MountConfig{FileSystemConfig: FileSystemConfig{IgnoreInterrupts: tt.ignoreInterruptConfigValue}}

OverrideWithIgnoreInterruptsFlag(testContext, mountConfig, tt.ignoreInterruptFlagValue)

assert.Equal(t, tt.expectedIgnoreInterrupt, mountConfig.FileSystemConfig.IgnoreInterrupts)
})
}
}

func TestOverrideWithAnonymousAccessFlag(t *testing.T) {
var overrideWithAnonymousAccessFlagTests = []struct {
testName string
Expand Down
30 changes: 15 additions & 15 deletions internal/fs/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1335,7 +1335,7 @@ func (fs *fileSystem) StatFS(
func (fs *fileSystem) LookUpInode(
ctx context.Context,
op *fuseops.LookUpInodeOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1371,7 +1371,7 @@ func (fs *fileSystem) LookUpInode(
func (fs *fileSystem) GetInodeAttributes(
ctx context.Context,
op *fuseops.GetInodeAttributesOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1399,7 +1399,7 @@ func (fs *fileSystem) GetInodeAttributes(
func (fs *fileSystem) SetInodeAttributes(
ctx context.Context,
op *fuseops.SetInodeAttributesOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1465,7 +1465,7 @@ func (fs *fileSystem) ForgetInode(
func (fs *fileSystem) MkDir(
ctx context.Context,
op *fuseops.MkDirOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1524,7 +1524,7 @@ func (fs *fileSystem) MkDir(
func (fs *fileSystem) MkNode(
ctx context.Context,
op *fuseops.MkNodeOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1654,7 +1654,7 @@ func (fs *fileSystem) createLocalFile(
func (fs *fileSystem) CreateFile(
ctx context.Context,
op *fuseops.CreateFileOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1703,7 +1703,7 @@ func (fs *fileSystem) CreateFile(
func (fs *fileSystem) CreateSymlink(
ctx context.Context,
op *fuseops.CreateSymlinkOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1773,7 +1773,7 @@ func (fs *fileSystem) RmDir(

ctx context.Context,
op *fuseops.RmDirOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -1875,7 +1875,7 @@ func (fs *fileSystem) RmDir(
func (fs *fileSystem) Rename(
ctx context.Context,
op *fuseops.RenameOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -2094,7 +2094,7 @@ func (fs *fileSystem) renameDir(
func (fs *fileSystem) Unlink(
ctx context.Context,
op *fuseops.UnlinkOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -2182,7 +2182,7 @@ func (fs *fileSystem) OpenDir(
func (fs *fileSystem) ReadDir(
ctx context.Context,
op *fuseops.ReadDirOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -2254,7 +2254,7 @@ func (fs *fileSystem) OpenFile(
func (fs *fileSystem) ReadFile(
ctx context.Context,
op *fuseops.ReadFileOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -2305,7 +2305,7 @@ func (fs *fileSystem) ReadSymlink(
func (fs *fileSystem) WriteFile(
ctx context.Context,
op *fuseops.WriteFileOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand All @@ -2332,7 +2332,7 @@ func (fs *fileSystem) WriteFile(
func (fs *fileSystem) SyncFile(
ctx context.Context,
op *fuseops.SyncFileOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down Expand Up @@ -2365,7 +2365,7 @@ func (fs *fileSystem) SyncFile(
func (fs *fileSystem) FlushFile(
ctx context.Context,
op *fuseops.FlushFileOp) (err error) {
if fs.mountConfig.FileSystemConfig.IgnoreInterrupts {
if fs.newConfig.FileSystem.IgnoreInterrupts {
// When ignore interrupts config is set, we are creating a new context not
// cancellable by parent context.
var cancel context.CancelFunc
Expand Down

0 comments on commit cd225a6

Please sign in to comment.