-
Notifications
You must be signed in to change notification settings - Fork 550
Inconsistency of the two "load existing" functions #455
Description
Hi!
I can't init an organizational provider (eg. yandex-cloud/yandex) because cloudquery requires the provider full name (org name + provider name) in config.hcl (config.RequiredProvider) and uses only the provider name in LoadExisting:
During the initialization of a new client, two "load existing" functions are called, but the behavior is different.
The first:
client.New:
cloudquery/pkg/client/client.go
Line 254 in 20144ac
| func New(ctx context.Context, options ...Option) (*Client, error) { |
->
plugin.NewManager
cloudquery/pkg/client/client.go
Line 270 in 20144ac
| c.Manager, err = plugin.NewManager(c.Logger, c.PluginDirectory, c.RegistryURL, c.HubProgressUpdater) |
->
registry.NewRegistryHub
cloudquery/pkg/plugin/manager.go
Line 47 in 4421bed
| hub: registry.NewRegistryHub(registryURL, func(h *registry.Hub) { |
->
h.loadExisting()
cloudquery/pkg/plugin/registry/hub.go
Line 63 in 4421bed
| h.loadExisting() |
uses a provider's "short name":
cloudquery/pkg/plugin/registry/hub.go
Lines 342 to 347 in 20144ac
| h.providers[fmt.Sprintf("%s-%s", provider, pVersion)] = ProviderDetails{ | |
| Name: provider, | |
| Version: pVersion, | |
| Organization: organization, | |
| FilePath: path, | |
| } |
In addition, there is the second function "loading existing" in client.New
->
c.Manager.LoadExisting(c.Providers)
cloudquery/pkg/client/client.go
Line 274 in 4421bed
| c.Manager.LoadExisting(c.Providers) |
which uses provider name from
*config.RequiredProvider, which uses the full name (org name + provider name) of the provider:cloudquery/pkg/plugin/manager.go
Lines 54 to 63 in 9ce0ac6
| // LoadExisting loads existing providers that are found by the hub in ProviderDirectory | |
| func (m *Manager) LoadExisting(providers []*config.RequiredProvider) { | |
| for _, p := range providers { | |
| pd, err := m.hub.GetProvider(p.Name, p.Version) | |
| if err != nil { | |
| continue | |
| } | |
| m.providers[pd.Name] = pd | |
| } | |
| } |
I think both "load existing" functions should use the full name of provider.