Remove dead code (#373)

Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com>
This commit is contained in:
Paul Meyer 2022-10-26 10:29:28 +02:00 committed by GitHub
parent 4cbec82edf
commit c05b22f1dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 3 additions and 12 deletions

View File

@ -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) {
if provider == cloudprovider.Unknown {
return errors.New("unknown cloud provider")

View File

@ -168,7 +168,7 @@ func TestCreate(t *testing.T) {
yesFlag: true,
wantErr: true,
},
"write state error": {
"write id file error": {
setupFs: func(require *require.Assertions, csp cloudprovider.Provider) afero.Fs {
fs := afero.NewMemMapFs()
fileHandler := file.NewHandler(fs)

View File

@ -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))
}
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) {
retErr = multierr.Append(err, fmt.Errorf("failed to remove file: '%s', please remove it manually", constants.ClusterIDsFileName))
}

View File

@ -51,7 +51,6 @@ func TestTerminate(t *testing.T) {
fs := afero.NewMemMapFs()
fileHandler := file.NewHandler(fs)
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))
return fs
}
@ -84,13 +83,12 @@ func TestTerminate(t *testing.T) {
terminator: &stubCloudTerminator{terminateErr: someErr},
wantErr: true,
},
"missing state file": {
"missing id file": {
idFile: clusterid.File{CloudProvider: cloudprovider.GCP},
setupFs: func(require *require.Assertions, idFile clusterid.File) afero.Fs {
fs := afero.NewMemMapFs()
fileHandler := file.NewHandler(fs)
require.NoError(fileHandler.Write(constants.AdminConfFilename, []byte{1, 2}, file.OptNone))
require.NoError(fileHandler.Write(constants.WGQuickConfigFilename, []byte{1, 2}, file.OptNone))
return fs
},
terminator: &stubCloudTerminator{},
@ -128,8 +126,6 @@ func TestTerminate(t *testing.T) {
assert.True(tc.terminator.Called())
_, err = fileHandler.Stat(constants.AdminConfFilename)
assert.Error(err)
_, err = fileHandler.Stat(constants.WGQuickConfigFilename)
assert.Error(err)
_, err = fileHandler.Stat(constants.ClusterIDsFileName)
assert.Error(err)
}

View File

@ -64,7 +64,6 @@ const (
DebugdConfigFilename = "cdbg-conf.yaml"
AdminConfFilename = "constellation-admin.conf"
MasterSecretFilename = "constellation-mastersecret.json"
WGQuickConfigFilename = "wg0.conf"
ControlPlaneAdminConfFilename = "/etc/kubernetes/admin.conf"
KubeadmCertificateDir = "/etc/kubernetes/pki"
KubectlPath = "/run/state/bin/kubectl"