diff --git a/pkg/backend/backend.go b/pkg/backend/backend.go index 8df9df010..9c06fc9f0 100644 --- a/pkg/backend/backend.go +++ b/pkg/backend/backend.go @@ -15,8 +15,6 @@ package backend import ( - "fmt" - "github.com/hashicorp/hcl/v2" ) @@ -29,28 +27,3 @@ type Backend interface { // Validate validates backend configuration. Validate() error } - -// backends is a collection in which all Backends get automatically registered. -var backends map[string]Backend - -// Initialize package's global variable on import. -func init() { - backends = make(map[string]Backend) -} - -// Register registers Backend b in the internal backends map. -func Register(name string, b Backend) { - if _, exists := backends[name]; exists { - panic(fmt.Sprintf("backend with name %q registered already", name)) - } - backends[name] = b -} - -// GetBackend returns the Backend referred to by name. -func GetBackend(name string) (Backend, error) { - backend, exists := backends[name] - if !exists { - return nil, fmt.Errorf("no backend with name %q found", name) - } - return backend, nil -} diff --git a/pkg/backend/local/local.go b/pkg/backend/local/local.go index ee56f0825..ab86df339 100644 --- a/pkg/backend/local/local.go +++ b/pkg/backend/local/local.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/hcl/v2/gohcl" "github.com/kinvolk/lokomotive/internal/template" - "github.com/kinvolk/lokomotive/pkg/backend" ) type local struct { @@ -32,11 +31,6 @@ const ( Name = "local" ) -// init registers local as a backend. -func init() { - backend.Register(Name, NewConfig()) -} - // LoadConfig loads the configuration for the local backend. func (l *local) LoadConfig(configBody *hcl.Body, evalContext *hcl.EvalContext) hcl.Diagnostics { if configBody == nil { diff --git a/pkg/backend/s3/s3.go b/pkg/backend/s3/s3.go index 65306726e..2e948ed38 100644 --- a/pkg/backend/s3/s3.go +++ b/pkg/backend/s3/s3.go @@ -22,7 +22,6 @@ import ( "github.com/hashicorp/hcl/v2/gohcl" "github.com/kinvolk/lokomotive/internal/template" - "github.com/kinvolk/lokomotive/pkg/backend" ) type s3 struct { @@ -39,11 +38,6 @@ const ( Name = "s3" ) -// init registers s3 as a backend. -func init() { - backend.Register(Name, NewConfig()) -} - // LoadConfig loads the configuration for the s3 backend. func (s *s3) LoadConfig(configBody *hcl.Body, evalContext *hcl.EvalContext) hcl.Diagnostics { if configBody == nil {