Skip to content

Commit

Permalink
terraform init: add link to documentation when a checksum is missing …
Browse files Browse the repository at this point in the history
…from the lock file (#31408)

* terraform init: add suggested fix for when a checksum is missing from the lock file

* improve error message

* add link to the documentation

* cleanup leftovers from previous attempt

* fix tests

* s/,/;

* fix imports
  • Loading branch information
liamcervante committed Jul 20, 2022
1 parent 83e84e5 commit 9f0d1d0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion internal/getproviders/errors.go
Expand Up @@ -5,6 +5,7 @@ import (
"net/url"

svchost "github.com/hashicorp/terraform-svchost"

"github.com/hashicorp/terraform/internal/addrs"
)

Expand Down Expand Up @@ -210,7 +211,7 @@ func (err ErrQueryFailed) Unwrap() error {
return err.Wrapped
}

// ErrRequestCancelled is an error type used to indicate that an operation
// ErrRequestCanceled is an error type used to indicate that an operation
// failed due to being cancelled via the given context.Context object.
//
// This error type doesn't include information about what was cancelled,
Expand Down
5 changes: 3 additions & 2 deletions internal/providercache/installer_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -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`,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/providercache/package_install.go
Expand Up @@ -117,7 +117,7 @@ func installFromLocalArchive(ctx context.Context, meta getproviders.PackageMeta,
)
} else if !matches {
return authResult, fmt.Errorf(
"the current package for %s %s doesn't match any of the checksums previously recorded in the dependency lock file",
"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,
)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func installFromLocalDir(ctx context.Context, meta getproviders.PackageMeta, tar
)
} else if !matches {
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)",
"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,
)
}
Expand Down

0 comments on commit 9f0d1d0

Please sign in to comment.