Refactor instance status management: replace Running boolean with InstanceStatus enum and update related methods

This commit is contained in:
2025-08-27 19:44:38 +02:00
parent 615c2ac54e
commit 1443746add
10 changed files with 111 additions and 45 deletions

View File

@@ -109,7 +109,7 @@ func (im *instanceManager) UpdateInstance(name string, options *instance.CreateI
}
// Check if instance is running before updating options
wasRunning := instance.Running
wasRunning := instance.IsRunning()
// If the instance is running, stop it first
if wasRunning {
@@ -147,7 +147,7 @@ func (im *instanceManager) DeleteInstance(name string) error {
return fmt.Errorf("instance with name %s not found", name)
}
if instance.Running {
if instance.IsRunning() {
return fmt.Errorf("instance with name %s is still running, stop it before deleting", name)
}
@@ -173,7 +173,7 @@ func (im *instanceManager) StartInstance(name string) (*instance.Process, error)
if !exists {
return nil, fmt.Errorf("instance with name %s not found", name)
}
if instance.Running {
if instance.IsRunning() {
return instance, fmt.Errorf("instance with name %s is already running", name)
}
@@ -200,7 +200,7 @@ func (im *instanceManager) StopInstance(name string) (*instance.Process, error)
if !exists {
return nil, fmt.Errorf("instance with name %s not found", name)
}
if !instance.Running {
if !instance.IsRunning() {
return instance, fmt.Errorf("instance with name %s is already stopped", name)
}