From 5f990e85b35e98b6639fc48f37c13642b48aea47 Mon Sep 17 00:00:00 2001 From: Rene Kaufmann Date: Sun, 27 Aug 2017 09:25:03 +0200 Subject: [PATCH] removed unnecessary type --- cmd/remco/config.go | 4 ++-- pkg/template/backend.go | 8 ++------ pkg/template/resource.go | 6 +++--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cmd/remco/config.go b/cmd/remco/config.go index 0c1030d0..c347e688 100644 --- a/cmd/remco/config.go +++ b/cmd/remco/config.go @@ -38,8 +38,8 @@ type BackendConfigs struct { } // GetBackends returns a slice with all BackendConfigs for easy iteration. -func (c *BackendConfigs) GetBackends() template.BackendConnectors { - return template.BackendConnectors{ +func (c *BackendConfigs) GetBackends() []template.BackendConnector { + return []template.BackendConnector{ c.Etcd, c.File, c.Env, diff --git a/pkg/template/backend.go b/pkg/template/backend.go index d60ea628..dd5ce697 100644 --- a/pkg/template/backend.go +++ b/pkg/template/backend.go @@ -29,10 +29,6 @@ type BackendConnector interface { Connect() (Backend, error) } -// BackendConnectors is a list of BackendConnectors. -// This is just a helper Type to simplify operations on many BackendConnectors. -type BackendConnectors []BackendConnector - // Backend is the representation of a template backend like etcd or consul type Backend struct { easykv.ReadWatcher @@ -59,9 +55,9 @@ type Backend struct { store *memkv.Store } -// ConnectAll connects to all configured backends. +// connectAllBackends connects to all configured backends. // This method blocks until a connection to every backend has been established or the context is canceled. -func (bc BackendConnectors) ConnectAll(ctx context.Context) ([]Backend, error) { +func connectAllBackends(ctx context.Context, bc []BackendConnector) ([]Backend, error) { var backendList []Backend for _, config := range bc { retryloop: diff --git a/pkg/template/resource.go b/pkg/template/resource.go index ba3498a6..7a3132fc 100644 --- a/pkg/template/resource.go +++ b/pkg/template/resource.go @@ -72,7 +72,7 @@ type ResourceConfig struct { // Connectors is a list of BackendConnectors. // The Resource will establish a connection to all of these. - Connectors BackendConnectors + Connectors []BackendConnector } // ErrEmptySrc is returned if an emty src template is passed to NewResource @@ -80,9 +80,9 @@ var ErrEmptySrc = fmt.Errorf("empty src template") // NewResourceFromResourceConfig creates a new resource from the given ResourceConfig. func NewResourceFromResourceConfig(ctx context.Context, reapLock *sync.RWMutex, r ResourceConfig) (*Resource, error) { - backendList, err := r.Connectors.ConnectAll(ctx) + backendList, err := connectAllBackends(ctx, r.Connectors) if err != nil { - return nil, errors.Wrap(err, "connectAll failed") + return nil, errors.Wrap(err, "connectAllBackends failed") } for _, p := range r.Template {