From 5edd882ff114e71e9ee5297291ce55a571920c42 Mon Sep 17 00:00:00 2001 From: Diogo Recharte Date: Wed, 14 Feb 2024 14:24:22 +0000 Subject: [PATCH] EVEREST-838 fix linter --- pkg/kubernetes/monitoring_config.go | 4 --- pkg/uninstall/uninstall.go | 39 ++++++++++++++++++----------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/pkg/kubernetes/monitoring_config.go b/pkg/kubernetes/monitoring_config.go index 90ca3fc0..dd91a237 100644 --- a/pkg/kubernetes/monitoring_config.go +++ b/pkg/kubernetes/monitoring_config.go @@ -22,10 +22,6 @@ import ( everestv1alpha1 "github.com/percona/everest-operator/api/v1alpha1" ) -const ( - monitoringConfigNameLabel = "monitoringConfigName" -) - // ListMonitoringConfigs returns list of managed monitoring configs. func (k *Kubernetes) ListMonitoringConfigs(ctx context.Context, namespace string) (*everestv1alpha1.MonitoringConfigList, error) { return k.client.ListMonitoringConfigs(ctx, namespace) diff --git a/pkg/uninstall/uninstall.go b/pkg/uninstall/uninstall.go index 09113219..b21b058d 100644 --- a/pkg/uninstall/uninstall.go +++ b/pkg/uninstall/uninstall.go @@ -90,19 +90,14 @@ This will uninstall Everest and all its components from the cluster.` return err } if dbsExist { - if !u.config.Force { - confirm := &survey.Confirm{ - Message: "There are still database clusters managed by Everest. Do you want to delete them?", - } - prompt := false - if err := survey.AskOne(confirm, &prompt); err != nil { - return err - } + force, err := u.config.Force() + if err != nil { + return err + } - if !prompt { - u.l.Info("Can't proceed without deleting database clusters") - return nil - } + if !force { + u.l.Info("Can't proceed without deleting database clusters") + return nil } if err := u.deleteDBs(ctx); err != nil { @@ -147,6 +142,22 @@ This will uninstall Everest and all its components from the cluster.` return nil } +func (u *Uninstall) confirmForce() (bool, error) { + if u.config.Force { + return true, nil + } + + confirm := &survey.Confirm{ + Message: "There are still database clusters managed by Everest. Do you want to delete them?", + } + prompt := false + if err := survey.AskOne(confirm, &prompt); err != nil { + return false, err + } + + return prompt, nil +} + func (u *Uninstall) getDBs(ctx context.Context) (map[string]*everestv1alpha1.DatabaseClusterList, error) { namespaces, err := u.kubeClient.GetDBNamespaces(ctx, install.SystemNamespace) if err != nil { @@ -259,7 +270,7 @@ func (u *Uninstall) deleteDBNamespaces(ctx context.Context) error { return u.deleteNamespaces(ctx, namespaces) } -func (u *Uninstall) deleteBackupStorages(ctx context.Context) error { +func (u *Uninstall) deleteBackupStorages(ctx context.Context) error { //nolint:dupl storages, err := u.kubeClient.ListBackupStorages(ctx, install.SystemNamespace) if err != nil { return err @@ -294,7 +305,7 @@ func (u *Uninstall) deleteBackupStorages(ctx context.Context) error { }) } -func (u *Uninstall) deleteMonitoringConfigs(ctx context.Context) error { +func (u *Uninstall) deleteMonitoringConfigs(ctx context.Context) error { //nolint:dupl monitoringConfigs, err := u.kubeClient.ListMonitoringConfigs(ctx, install.MonitoringNamespace) if err != nil { return err