44 "errors"
55 "fmt"
66
7+ "github.com/wundergraph/cosmo/router/pkg/config"
78 "github.com/wundergraph/cosmo/router/pkg/controlplane/configpoller"
89 "github.com/wundergraph/cosmo/router/pkg/execution_config"
910 "github.com/wundergraph/cosmo/router/pkg/routerconfig"
@@ -12,9 +13,9 @@ import (
1213 "go.uber.org/zap"
1314)
1415
15- func getConfigClient (r * Router , registry * ProviderRegistry , providerID string , isFallbackClient bool ) (client * routerconfig.Client , err error ) {
16+ func getConfigClient (r * Router , cdnProviders map [ string ]config. CDNStorageProvider , s3Providers map [ string ]config. S3StorageProvider , providerID string , isFallbackClient bool ) (client * routerconfig.Client , err error ) {
1617 // CDN Providers
17- if provider , ok := registry . CDN ( providerID ) ; ok {
18+ if provider , ok := cdnProviders [ providerID ] ; ok {
1819 if r .graphApiToken == "" {
1920 return nil , errors .New (
2021 "graph token is required to fetch execution config from CDN. " +
@@ -49,7 +50,7 @@ func getConfigClient(r *Router, registry *ProviderRegistry, providerID string, i
4950 }
5051
5152 // S3 Providers
52- if provider , ok := registry . S3 ( providerID ) ; ok {
53+ if provider , ok := s3Providers [ providerID ] ; ok {
5354 clientOptions := & configs3Provider.ClientOptions {
5455 AccessKeyID : provider .AccessKey ,
5556 SecretAccessKey : provider .SecretKey ,
@@ -120,12 +121,12 @@ func getConfigClient(r *Router, registry *ProviderRegistry, providerID string, i
120121}
121122
122123// InitializeConfigPoller creates a poller to fetch execution config. It is only initialized when a config poller is configured and the router is not started with a static config
123- func InitializeConfigPoller (r * Router , registry * ProviderRegistry ) (* configpoller.ConfigPoller , error ) {
124+ func InitializeConfigPoller (r * Router , cdnProviders map [ string ]config. CDNStorageProvider , s3Providers map [ string ]config. S3StorageProvider ) (* configpoller.ConfigPoller , error ) {
124125 if r .staticExecutionConfig != nil || r .routerConfigPollerConfig == nil || r .configPoller != nil {
125126 return nil , nil
126127 }
127128
128- primaryClient , err := getConfigClient (r , registry , r .routerConfigPollerConfig .Storage .ProviderID , false )
129+ primaryClient , err := getConfigClient (r , cdnProviders , s3Providers , r .routerConfigPollerConfig .Storage .ProviderID , false )
129130 if err != nil {
130131 return nil , err
131132 }
@@ -140,7 +141,7 @@ func InitializeConfigPoller(r *Router, registry *ProviderRegistry) (*configpolle
140141 return nil , errors .New ("cannot use the same storage as both primary and fallback provider for execution config" )
141142 }
142143
143- fallbackClient , err = getConfigClient (r , registry , r .routerConfigPollerConfig .FallbackStorage .ProviderID , true )
144+ fallbackClient , err = getConfigClient (r , cdnProviders , s3Providers , r .routerConfigPollerConfig .FallbackStorage .ProviderID , true )
144145 if err != nil {
145146 return nil , err
146147 }
0 commit comments