From a4aac63b726e39e7232963a1fa044e79ae0371a3 Mon Sep 17 00:00:00 2001 From: Michal Kralik Date: Tue, 12 Sep 2023 15:08:17 +0200 Subject: [PATCH] EVEREST-386: backup name is required --- pkg/install/operators.go | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/pkg/install/operators.go b/pkg/install/operators.go index 70ab4c3d..2ae6f1f4 100644 --- a/pkg/install/operators.go +++ b/pkg/install/operators.go @@ -186,14 +186,8 @@ func NewOperators(c OperatorsConfig, l *zap.SugaredLogger) (*Operators, error) { // Run runs the operators installation process. func (o *Operators) Run(ctx context.Context) error { - if !o.config.SkipWizard { - if err := o.runWizard(ctx); err != nil { - return err - } - } - - if o.config.Name == "" { - o.config.Name = o.kubeClient.ClusterName() + if err := o.populateConfig(ctx); err != nil { + return err } if o.everestClient == nil { @@ -224,6 +218,26 @@ func (o *Operators) Run(ctx context.Context) error { return o.performProvisioning(ctx) } +func (o *Operators) populateConfig(ctx context.Context) error { + if !o.config.SkipWizard { + if err := o.runWizard(ctx); err != nil { + return err + } + } + + if o.config.Name == "" { + o.config.Name = o.kubeClient.ClusterName() + } + + if o.config.Backup.Enable && o.config.Backup.Name == "" { + l := o.l.WithOptions(zap.AddStacktrace(zap.DPanicLevel)) + l.Error("Backup name cannot be empty if backup is enabled") + return common.ErrExitWithError + } + + return nil +} + func (o *Operators) checkEverestConnection(ctx context.Context) error { o.l.Info("Checking connection to Everest") _, err := o.everestClient.ListMonitoringInstances(ctx)