Skip to content

Inconsistency of the two "load existing" functions #455

@melkikh

Description

@melkikh

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:

func New(ctx context.Context, options ...Option) (*Client, error) {

->
plugin.NewManager
c.Manager, err = plugin.NewManager(c.Logger, c.PluginDirectory, c.RegistryURL, c.HubProgressUpdater)

->
registry.NewRegistryHub
hub: registry.NewRegistryHub(registryURL, func(h *registry.Hub) {

->
h.loadExisting()
h.loadExisting()

uses a provider's "short name":
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)

c.Manager.LoadExisting(c.Providers)

which uses provider name from *config.RequiredProvider, which uses the full name (org name + provider name) of the provider:
// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions