mirror of
https://github.com/speatzle/nfsense.git
synced 2025-05-11 02:48:21 +00:00
Use ConfigManager
This commit is contained in:
parent
75e981545a
commit
2716507c86
2 changed files with 30 additions and 12 deletions
|
@ -28,8 +28,11 @@ func (f *Object) CreateAddress(ctx context.Context, params CreateAddressParamete
|
|||
return struct{}{}, fmt.Errorf("Address already Exists")
|
||||
}
|
||||
|
||||
f.ConfigManager.GetPendingConfig().Object.Addresses[params.Name] = params.Address
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
conf.Object.Addresses[params.Name] = params.Address
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
||||
type UpdateAddressParameters struct {
|
||||
|
@ -43,8 +46,11 @@ func (f *Object) UpdateAddress(ctx context.Context, params CreateAddressParamete
|
|||
return struct{}{}, fmt.Errorf("Address does not Exist")
|
||||
}
|
||||
|
||||
f.ConfigManager.GetPendingConfig().Object.Addresses[params.Name] = params.Address
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
conf.Object.Addresses[params.Name] = params.Address
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
||||
type DeleteAddressParameters struct {
|
||||
|
@ -57,6 +63,9 @@ func (f *Object) DeleteAddress(ctx context.Context, params DeleteAddressParamete
|
|||
return struct{}{}, fmt.Errorf("Interface does not Exist")
|
||||
}
|
||||
|
||||
delete(f.ConfigManager.GetPendingConfig().Object.Addresses, params.Name)
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
delete(conf.Object.Addresses, params.Name)
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
|
|
@ -28,8 +28,11 @@ func (f *Object) CreateService(ctx context.Context, params CreateServiceParamete
|
|||
return struct{}{}, fmt.Errorf("Service already Exists")
|
||||
}
|
||||
|
||||
f.ConfigManager.GetPendingConfig().Object.Services[params.Name] = params.Service
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
conf.Object.Services[params.Name] = params.Service
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
||||
type UpdateServiceParameters struct {
|
||||
|
@ -43,8 +46,11 @@ func (f *Object) UpdateService(ctx context.Context, params CreateServiceParamete
|
|||
return struct{}{}, fmt.Errorf("Service does not Exist")
|
||||
}
|
||||
|
||||
f.ConfigManager.GetPendingConfig().Object.Services[params.Name] = params.Service
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
conf.Object.Services[params.Name] = params.Service
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
||||
type DeleteServiceParameters struct {
|
||||
|
@ -57,6 +63,9 @@ func (f *Object) DeleteService(ctx context.Context, params DeleteServiceParamete
|
|||
return struct{}{}, fmt.Errorf("Interface does not Exist")
|
||||
}
|
||||
|
||||
delete(f.ConfigManager.GetPendingConfig().Object.Services, params.Name)
|
||||
return struct{}{}, nil
|
||||
t, conf := f.ConfigManager.StartTransaction()
|
||||
defer t.Discard()
|
||||
|
||||
delete(conf.Object.Services, params.Name)
|
||||
return struct{}{}, t.Commit()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue