904 missing provider module message (#981)

Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This commit is contained in:
Christian Mesh 2023-12-07 10:34:50 -05:00 committed by GitHub
parent 1f9f0bd2af
commit 47071c2696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -380,6 +380,9 @@ func TestInitProviderNotFound(t *testing.T) {
modules are currently depending on hashicorp/nonexist, run the following
command:
tofu providers
If you believe this provider is missing from the registry, please submit a
issue on the OpenTofu Registry https://github.com/opentofu/registry/issues/
`

View File

@ -658,6 +658,10 @@ func (c *InitCommand) getProviders(ctx context.Context, config *configs.Config,
)
}
if provider.Hostname == addrs.DefaultProviderRegistryHost {
suggestion += "\n\nIf you believe this provider is missing from the registry, please submit a issue on the OpenTofu Registry https://github.com/opentofu/registry/issues/"
}
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Failed to query available provider packages",

View File

@ -436,10 +436,15 @@ func (i *ModuleInstaller) installRegistryModule(ctx context.Context, req *config
resp, err = reg.ModuleVersions(ctx, regsrcAddr)
if err != nil {
if registry.IsModuleNotFound(err) {
suggestion := ""
if hostname == addrs.DefaultModuleRegistryHost {
suggestion = "\n\nIf you believe this module is missing from the registry, please submit a issue on the OpenTofu Registry https://github.com/opentofu/registry/issues/"
}
diags = diags.Append(&hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Module not found",
Detail: fmt.Sprintf("Module %q (from %s:%d) cannot be found in the module registry at %s.", req.Name, req.CallRange.Filename, req.CallRange.Start.Line, hostname),
Detail: fmt.Sprintf("Module %s (%q from %s:%d) cannot be found in the module registry at %s.%s", addr.Package.ForRegistryProtocol(), req.Name, req.CallRange.Filename, req.CallRange.Start.Line, hostname, suggestion),
Subject: req.CallRange.Ptr(),
})
} else if errors.Is(err, context.Canceled) {