From 11a3d46fe4d6fbf714af39f2600fb0cb67a41311 Mon Sep 17 00:00:00 2001 From: Pierangelo Di Pilato Date: Wed, 15 May 2024 09:30:57 +0200 Subject: [PATCH] Add composite ConfigStore to combine multiple ConfigStore (#3027) In some repositories, we used multiple ConfigStores to store feature flags, for example, in eventing kafka broker, we use the Eventing core feature flags store and the EKB feature flags store Signed-off-by: Pierangelo Di Pilato --- reconciler/configstore.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/reconciler/configstore.go b/reconciler/configstore.go index c5c9c319fe..6b61856d56 100644 --- a/reconciler/configstore.go +++ b/reconciler/configstore.go @@ -20,6 +20,20 @@ import "context" // ConfigStore is used to attach the frozen configuration to the context. type ConfigStore interface { - // ConfigStore is used to attach the frozen configuration to the context. + // ToContext is used to attach the frozen configuration to the context. ToContext(ctx context.Context) context.Context } + +// ConfigStores is used to combine multiple ConfigStore and attach multiple frozen configurations +// to the context. +type ConfigStores []ConfigStore + +// ConfigStores implements ConfigStore interface. +var _ ConfigStore = ConfigStores{} + +func (stores ConfigStores) ToContext(ctx context.Context) context.Context { + for _, s := range stores { + ctx = s.ToContext(ctx) + } + return ctx +}