Fix deleting non existent environments
that is an error caused by throwing a panic when an environment is not found and a nonexistent runner manager at the end of the chain is asked for it.
This commit is contained in:

committed by
Sebastian Serth

parent
689493047d
commit
795c83f7b2
@@ -18,13 +18,17 @@ func (n *AbstractManager) SetNextHandler(next ManagerHandler) {
|
||||
}
|
||||
|
||||
func (n *AbstractManager) NextHandler() ManagerHandler {
|
||||
if n.nextHandler != nil {
|
||||
if n.HasNextHandler() {
|
||||
return n.nextHandler
|
||||
} else {
|
||||
return &AbstractManager{}
|
||||
}
|
||||
}
|
||||
|
||||
func (n *AbstractManager) HasNextHandler() bool {
|
||||
return n.nextHandler != nil
|
||||
}
|
||||
|
||||
func (n *AbstractManager) List(_ bool) ([]runner.ExecutionEnvironment, error) {
|
||||
return []runner.ExecutionEnvironment{}, nil
|
||||
}
|
||||
@@ -38,17 +42,17 @@ func (n *AbstractManager) CreateOrUpdate(_ dto.EnvironmentID, _ dto.ExecutionEnv
|
||||
}
|
||||
|
||||
func (n *AbstractManager) Delete(id dto.EnvironmentID) (bool, error) {
|
||||
if n.runnerManager == nil {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
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
|
||||
isFound, err := n.NextHandler().Delete(id)
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("abstract wrapped: %w", err)
|
||||
}
|
||||
return isFound, nil
|
||||
}
|
||||
|
||||
n.runnerManager.DeleteEnvironment(id)
|
||||
|
Reference in New Issue
Block a user