mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-29 11:16:34 -04:00
AB#2532 Dont clean up workspace if rollback fails (#360)
* Dont clean up workspace if rollback fails * Remove dependency on CSP from terminate Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
1f8eba37c8
commit
e66cb84d6e
16 changed files with 190 additions and 111 deletions
|
@ -25,5 +25,5 @@ type cloudCreator interface {
|
|||
}
|
||||
|
||||
type cloudTerminator interface {
|
||||
Terminate(context.Context, cloudprovider.Provider) error
|
||||
Terminate(context.Context) error
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ type stubCloudTerminator struct {
|
|||
terminateErr error
|
||||
}
|
||||
|
||||
func (c *stubCloudTerminator) Terminate(context.Context, cloudprovider.Provider) error {
|
||||
func (c *stubCloudTerminator) Terminate(context.Context) error {
|
||||
c.called = true
|
||||
return c.terminateErr
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import (
|
|||
"go.uber.org/multierr"
|
||||
|
||||
"github.com/edgelesssys/constellation/v2/cli/internal/cloudcmd"
|
||||
"github.com/edgelesssys/constellation/v2/cli/internal/clusterid"
|
||||
"github.com/edgelesssys/constellation/v2/internal/constants"
|
||||
"github.com/edgelesssys/constellation/v2/internal/file"
|
||||
)
|
||||
|
@ -45,13 +44,8 @@ func runTerminate(cmd *cobra.Command, args []string) error {
|
|||
|
||||
func terminate(cmd *cobra.Command, terminator cloudTerminator, fileHandler file.Handler, spinner spinnerInterf,
|
||||
) error {
|
||||
var idFile clusterid.File
|
||||
if err := fileHandler.ReadJSON(constants.ClusterIDsFileName, &idFile); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
spinner.Start("Terminating", false)
|
||||
err := terminator.Terminate(cmd.Context(), idFile.CloudProvider)
|
||||
err := terminator.Terminate(cmd.Context())
|
||||
spinner.Stop()
|
||||
if err != nil {
|
||||
return fmt.Errorf("terminating Constellation cluster: %w", err)
|
||||
|
|
|
@ -83,7 +83,7 @@ func TestTerminate(t *testing.T) {
|
|||
terminator: &stubCloudTerminator{terminateErr: someErr},
|
||||
wantErr: true,
|
||||
},
|
||||
"missing id file": {
|
||||
"missing id file does not error": {
|
||||
idFile: clusterid.File{CloudProvider: cloudprovider.GCP},
|
||||
setupFs: func(require *require.Assertions, idFile clusterid.File) afero.Fs {
|
||||
fs := afero.NewMemMapFs()
|
||||
|
@ -92,7 +92,6 @@ func TestTerminate(t *testing.T) {
|
|||
return fs
|
||||
},
|
||||
terminator: &stubCloudTerminator{},
|
||||
wantErr: true,
|
||||
},
|
||||
"remove file fails": {
|
||||
idFile: clusterid.File{CloudProvider: cloudprovider.GCP},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue