Implement review comments
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package environment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/openHPI/poseidon/internal/runner"
|
||||
"github.com/openHPI/poseidon/pkg/dto"
|
||||
)
|
||||
@@ -8,7 +9,8 @@ import (
|
||||
// AbstractManager is used to have a fallback environment manager in the chain of responsibility
|
||||
// following the null object pattern.
|
||||
type AbstractManager struct {
|
||||
nextHandler ManagerHandler
|
||||
nextHandler ManagerHandler
|
||||
runnerManager runner.Manager
|
||||
}
|
||||
|
||||
func (n *AbstractManager) SetNextHandler(next ManagerHandler) {
|
||||
@@ -35,8 +37,25 @@ func (n *AbstractManager) CreateOrUpdate(_ dto.EnvironmentID, _ dto.ExecutionEnv
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (n *AbstractManager) Delete(_ dto.EnvironmentID) (bool, error) {
|
||||
return false, nil
|
||||
func (n *AbstractManager) Delete(id dto.EnvironmentID) (bool, error) {
|
||||
e, ok := n.runnerManager.GetEnvironment(id)
|
||||
if !ok {
|
||||
if n.nextHandler != nil {
|
||||
isFound, err := n.NextHandler().Delete(id)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("aws wrapped: %w", err)
|
||||
}
|
||||
return isFound, nil
|
||||
} else {
|
||||
return false, nil
|
||||
}
|
||||
}
|
||||
|
||||
n.runnerManager.DeleteEnvironment(id)
|
||||
if err := e.Delete(); err != nil {
|
||||
return true, fmt.Errorf("could not delete environment: %w", err)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (n *AbstractManager) Statistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
|
Reference in New Issue
Block a user