From 087c3f7d08e00934555e34ee4424ea33fa2672c9 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Thu, 16 May 2019 14:10:57 +0100 Subject: [PATCH] Support dynamic registration of context store endpoint types This is a yet unused and the default set remains the same, no expected functional change. Signed-off-by: Ian Campbell --- cli/command/cli.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 9bd9ebc2af..776688691f 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -526,10 +526,22 @@ func resolveContextName(opts *cliflags.CommonOptions, config *configfile.ConfigF return DefaultContextName, nil } +var defaultStoreEndpoints = []store.NamedTypeGetter{ + store.EndpointTypeGetter(docker.DockerEndpoint, func() interface{} { return &docker.EndpointMeta{} }), + store.EndpointTypeGetter(kubecontext.KubernetesEndpoint, func() interface{} { return &kubecontext.EndpointMeta{} }), +} + +// RegisterDefaultStoreEndpoints registers a new named endpoint +// metadata type with the default context store config, so that +// endpoint will be supported by stores using the config returned by +// DefaultContextStoreConfig. +func RegisterDefaultStoreEndpoints(ep ...store.NamedTypeGetter) { + defaultStoreEndpoints = append(defaultStoreEndpoints, ep...) +} + func defaultContextStoreConfig() store.Config { return store.NewConfig( func() interface{} { return &DockerContext{} }, - store.EndpointTypeGetter(docker.DockerEndpoint, func() interface{} { return &docker.EndpointMeta{} }), - store.EndpointTypeGetter(kubecontext.KubernetesEndpoint, func() interface{} { return &kubecontext.EndpointMeta{} }), + defaultStoreEndpoints..., ) }