mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-06 05:54:28 -04:00
Improve code sequences with multiple errs
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
12c866bcb9
commit
deea806d9c
9 changed files with 53 additions and 44 deletions
|
@ -38,12 +38,10 @@ type rollbackerTerraform struct {
|
|||
}
|
||||
|
||||
func (r *rollbackerTerraform) rollback(ctx context.Context) error {
|
||||
var err error
|
||||
err = errors.Join(err, r.client.Destroy(ctx))
|
||||
if err == nil {
|
||||
err = errors.Join(err, r.client.CleanUpWorkspace())
|
||||
if err := r.client.Destroy(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
return r.client.CleanUpWorkspace()
|
||||
}
|
||||
|
||||
type rollbackerQEMU struct {
|
||||
|
@ -52,14 +50,12 @@ type rollbackerQEMU struct {
|
|||
createdWorkspace bool
|
||||
}
|
||||
|
||||
func (r *rollbackerQEMU) rollback(ctx context.Context) error {
|
||||
var err error
|
||||
func (r *rollbackerQEMU) rollback(ctx context.Context) (retErr error) {
|
||||
if r.createdWorkspace {
|
||||
err = errors.Join(err, r.client.Destroy(ctx))
|
||||
retErr = r.client.Destroy(ctx)
|
||||
}
|
||||
err = errors.Join(err, r.libvirt.Stop(ctx))
|
||||
if err == nil {
|
||||
err = r.client.CleanUpWorkspace()
|
||||
if retErr := errors.Join(retErr, r.libvirt.Stop(ctx)); retErr != nil {
|
||||
return retErr
|
||||
}
|
||||
return err
|
||||
return r.client.CleanUpWorkspace()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue