Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.

Commit

Permalink
cli/cmd/cluster: don't use backend.GetBackend for getting backend config
Browse files Browse the repository at this point in the history
Import all available backends locally instead, to avoid using globals.

Refs #992

Signed-off-by: Mateusz Gozdek <mateusz@kinvolk.io>
  • Loading branch information
invidian committed Dec 3, 2020
1 parent 7c2c0dc commit 1a039f6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions cli/cmd/cluster/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
log "github.com/sirupsen/logrus"

"github.com/kinvolk/lokomotive/pkg/backend"
"github.com/kinvolk/lokomotive/pkg/backend/local"
"github.com/kinvolk/lokomotive/pkg/backend/s3"
"github.com/kinvolk/lokomotive/pkg/config"
"github.com/kinvolk/lokomotive/pkg/platform"
"github.com/kinvolk/lokomotive/pkg/platform/aks"
Expand All @@ -47,11 +49,16 @@ func getConfiguredBackend(lokoConfig *config.Config) (backend.Backend, hcl.Diagn
return nil, hcl.Diagnostics{}
}

backend, err := backend.GetBackend(lokoConfig.RootConfig.Backend.Name)
if err != nil {
backends := map[string]backend.Backend{
s3.Name: s3.NewConfig(),
local.Name: local.NewConfig(),
}

backend, ok := backends[lokoConfig.RootConfig.Backend.Name]
if !ok {
diag := &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: err.Error(),
Summary: fmt.Sprintf("no backend with name %q found", lokoConfig.RootConfig.Backend.Name),
}
return nil, hcl.Diagnostics{diag}
}
Expand Down

0 comments on commit 1a039f6

Please sign in to comment.