From 4f14c4995ea5d96d91caeb03bb2e700572c97660 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 16 May 2019 14:11:50 +0100 Subject: [PATCH] Add a helper to iterate over all endpoint types in a context store Unused for now. Signed-off-by: Ian Campbell --- cli/context/store/storeconfig.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cli/context/store/storeconfig.go b/cli/context/store/storeconfig.go index b282a9d10e..2a4bc57c1c 100644 --- a/cli/context/store/storeconfig.go +++ b/cli/context/store/storeconfig.go @@ -30,6 +30,16 @@ func (c Config) SetEndpoint(name string, getter TypeGetter) { c.endpointTypes[name] = getter } +// ForeachEndpointType calls cb on every endpoint type registered with the Config +func (c Config) ForeachEndpointType(cb func(string, TypeGetter) error) error { + for n, ep := range c.endpointTypes { + if err := cb(n, ep); err != nil { + return err + } + } + return nil +} + // NewConfig creates a config object func NewConfig(contextType TypeGetter, endpoints ...NamedTypeGetter) Config { res := Config{