mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
Remove dead code (#373)
Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
parent
4cbec82edf
commit
c05b22f1dc
@ -33,7 +33,7 @@ func NewTerminator() *Terminator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Terminate deletes the could provider resources defined in the constellation state.
|
// Terminate deletes the could provider resources.
|
||||||
func (t *Terminator) Terminate(ctx context.Context, provider cloudprovider.Provider) (retErr error) {
|
func (t *Terminator) Terminate(ctx context.Context, provider cloudprovider.Provider) (retErr error) {
|
||||||
if provider == cloudprovider.Unknown {
|
if provider == cloudprovider.Unknown {
|
||||||
return errors.New("unknown cloud provider")
|
return errors.New("unknown cloud provider")
|
||||||
|
@ -168,7 +168,7 @@ func TestCreate(t *testing.T) {
|
|||||||
yesFlag: true,
|
yesFlag: true,
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"write state error": {
|
"write id file error": {
|
||||||
setupFs: func(require *require.Assertions, csp cloudprovider.Provider) afero.Fs {
|
setupFs: func(require *require.Assertions, csp cloudprovider.Provider) afero.Fs {
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
|
@ -64,10 +64,6 @@ func terminate(cmd *cobra.Command, terminator cloudTerminator, fileHandler file.
|
|||||||
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.AdminConfFilename))
|
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.AdminConfFilename))
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := fileHandler.Remove(constants.WGQuickConfigFilename); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
|
||||||
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.WGQuickConfigFilename))
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := fileHandler.Remove(constants.ClusterIDsFileName); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
if err := fileHandler.Remove(constants.ClusterIDsFileName); err != nil && !errors.Is(err, fs.ErrNotExist) {
|
||||||
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.ClusterIDsFileName))
|
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.ClusterIDsFileName))
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ func TestTerminate(t *testing.T) {
|
|||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
||||||
require.NoError(fileHandler.Write(constants.WGQuickConfigFilename, []byte{1, 2}, file.OptNone))
|
|
||||||
require.NoError(fileHandler.WriteJSON(constants.ClusterIDsFileName, idFile, file.OptNone))
|
require.NoError(fileHandler.WriteJSON(constants.ClusterIDsFileName, idFile, file.OptNone))
|
||||||
return fs
|
return fs
|
||||||
}
|
}
|
||||||
@ -84,13 +83,12 @@ func TestTerminate(t *testing.T) {
|
|||||||
terminator: &stubCloudTerminator{terminateErr: someErr},
|
terminator: &stubCloudTerminator{terminateErr: someErr},
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
},
|
},
|
||||||
"missing state file": {
|
"missing id file": {
|
||||||
idFile: clusterid.File{CloudProvider: cloudprovider.GCP},
|
idFile: clusterid.File{CloudProvider: cloudprovider.GCP},
|
||||||
setupFs: func(require *require.Assertions, idFile clusterid.File) afero.Fs {
|
setupFs: func(require *require.Assertions, idFile clusterid.File) afero.Fs {
|
||||||
fs := afero.NewMemMapFs()
|
fs := afero.NewMemMapFs()
|
||||||
fileHandler := file.NewHandler(fs)
|
fileHandler := file.NewHandler(fs)
|
||||||
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
|
||||||
require.NoError(fileHandler.Write(constants.WGQuickConfigFilename, []byte{1, 2}, file.OptNone))
|
|
||||||
return fs
|
return fs
|
||||||
},
|
},
|
||||||
terminator: &stubCloudTerminator{},
|
terminator: &stubCloudTerminator{},
|
||||||
@ -128,8 +126,6 @@ func TestTerminate(t *testing.T) {
|
|||||||
assert.True(tc.terminator.Called())
|
assert.True(tc.terminator.Called())
|
||||||
_, err = fileHandler.Stat(constants.AdminConfFilename)
|
_, err = fileHandler.Stat(constants.AdminConfFilename)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
_, err = fileHandler.Stat(constants.WGQuickConfigFilename)
|
|
||||||
assert.Error(err)
|
|
||||||
_, err = fileHandler.Stat(constants.ClusterIDsFileName)
|
_, err = fileHandler.Stat(constants.ClusterIDsFileName)
|
||||||
assert.Error(err)
|
assert.Error(err)
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,6 @@ const (
|
|||||||
DebugdConfigFilename = "cdbg-conf.yaml"
|
DebugdConfigFilename = "cdbg-conf.yaml"
|
||||||
AdminConfFilename = "constellation-admin.conf"
|
AdminConfFilename = "constellation-admin.conf"
|
||||||
MasterSecretFilename = "constellation-mastersecret.json"
|
MasterSecretFilename = "constellation-mastersecret.json"
|
||||||
WGQuickConfigFilename = "wg0.conf"
|
|
||||||
ControlPlaneAdminConfFilename = "/etc/kubernetes/admin.conf"
|
ControlPlaneAdminConfFilename = "/etc/kubernetes/admin.conf"
|
||||||
KubeadmCertificateDir = "/etc/kubernetes/pki"
|
KubeadmCertificateDir = "/etc/kubernetes/pki"
|
||||||
KubectlPath = "/run/state/bin/kubectl"
|
KubectlPath = "/run/state/bin/kubectl"
|
||||||
|
Loading…
Reference in New Issue
Block a user