diff --git a/internal/command/init.go b/internal/command/init.go index 3d326f1bcdfc..625f5d39fdb8 100644 --- a/internal/command/init.go +++ b/internal/command/init.go @@ -763,20 +763,6 @@ func (c *InitCommand) getProviders(config *configs.Config, state *states.State, // but rather just emit a single general message about it at // the end, by checking ctx.Err(). - case providercache.ErrProviderChecksumMiss: - // This is a special kind of error that can often be fixed using - // the `terraform providers lock` command. We're just going to - // amend the actual error message with some extra information - // about how to fix this. - - diags = diags.Append(tfdiags.Sourceless( - tfdiags.Error, - "Failed to install provider", - fmt.Sprintf("Error while installing %s v%s: %s\n\nYou can ensure the current platform, %s, is included in the dependency lock file by running: `terraform providers lock -provider=%s`.\n\nIf this does not fix the problem you may need to reset any provider caching present in your setup or make sure you are connecting to valid provider distributions.", - provider.ForDisplay(), version, err.Msg, err.Meta.TargetPlatform.String(), err.Meta.TargetPlatform.String(), - ), - )) - default: // We can potentially end up in here under cancellation too, // in spite of our getproviders.ErrRequestCanceled case above, diff --git a/internal/getproviders/errors.go b/internal/getproviders/errors.go index cd110a2b1f33..7d2720c0f8cf 100644 --- a/internal/getproviders/errors.go +++ b/internal/getproviders/errors.go @@ -5,6 +5,7 @@ import ( "net/url" svchost "github.com/hashicorp/terraform-svchost" + "github.com/hashicorp/terraform/internal/addrs" ) diff --git a/internal/providercache/errors.go b/internal/providercache/errors.go deleted file mode 100644 index 75550d008921..000000000000 --- a/internal/providercache/errors.go +++ /dev/null @@ -1,14 +0,0 @@ -package providercache - -import "github.com/hashicorp/terraform/internal/getproviders" - -// ErrProviderChecksumMiss is an error type used to indicate a provider -// installation failed due to a mismatch in the terraform provider lock file. -type ErrProviderChecksumMiss struct { - Meta getproviders.PackageMeta - Msg string -} - -func (err ErrProviderChecksumMiss) Error() string { - return err.Msg -} diff --git a/internal/providercache/installer_test.go b/internal/providercache/installer_test.go index 0a3677872c05..bb71f1db2493 100644 --- a/internal/providercache/installer_test.go +++ b/internal/providercache/installer_test.go @@ -16,6 +16,7 @@ import ( "github.com/google/go-cmp/cmp" svchost "github.com/hashicorp/terraform-svchost" "github.com/hashicorp/terraform-svchost/disco" + "github.com/hashicorp/terraform/internal/addrs" "github.com/hashicorp/terraform/internal/depsfile" "github.com/hashicorp/terraform/internal/getproviders" @@ -1401,7 +1402,7 @@ func TestEnsureProviderVersions(t *testing.T) { beepProvider: getproviders.MustParseVersionConstraints(">= 1.0.0"), }, WantErr: `some providers could not be installed: -- example.com/foo/beep: the local package for example.com/foo/beep 1.0.0 doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms)`, +- example.com/foo/beep: the local package for example.com/foo/beep 1.0.0 doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms); for more information: https://www.terraform.io/language/provider-checksum-verification`, WantEvents: func(inst *Installer, dir *Dir) map[addrs.Provider][]*testInstallerEventLogItem { return map[addrs.Provider][]*testInstallerEventLogItem{ noProvider: { @@ -1447,7 +1448,7 @@ func TestEnsureProviderVersions(t *testing.T) { Error string }{ "1.0.0", - `the local package for example.com/foo/beep 1.0.0 doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms)`, + `the local package for example.com/foo/beep 1.0.0 doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms); for more information: https://www.terraform.io/language/provider-checksum-verification`, }, }, }, diff --git a/internal/providercache/package_install.go b/internal/providercache/package_install.go index e07564b61bd6..c3111606647b 100644 --- a/internal/providercache/package_install.go +++ b/internal/providercache/package_install.go @@ -116,13 +116,10 @@ func installFromLocalArchive(ctx context.Context, meta getproviders.PackageMeta, meta.Provider, meta.Version, meta.Location, err, ) } else if !matches { - return authResult, ErrProviderChecksumMiss{ - Meta: meta, - Msg: fmt.Sprintf( - "the current package for %s %s doesn't match any of the checksums previously recorded in the dependency lock file", - meta.Provider, meta.Version, - ), - } + return authResult, fmt.Errorf( + "the current package for %s %s doesn't match any of the checksums previously recorded in the dependency lock file; for more information: https://www.terraform.io/language/provider-checksum-verification", + meta.Provider, meta.Version, + ) } } @@ -201,13 +198,10 @@ func installFromLocalDir(ctx context.Context, meta getproviders.PackageMeta, tar meta.Provider, meta.Version, meta.Location, err, ) } else if !matches { - return authResult, ErrProviderChecksumMiss{ - Meta: meta, - Msg: fmt.Sprintf( - "the local package for %s %s doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms)", - meta.Provider, meta.Version, - ), - } + return authResult, fmt.Errorf( + "the local package for %s %s doesn't match any of the checksums previously recorded in the dependency lock file (this might be because the available checksums are for packages targeting different platforms); for more information: https://www.terraform.io/language/provider-checksum-verification", + meta.Provider, meta.Version, + ) } }