Skip to content

Commit

Permalink
Merge pull request #27722 from hashicorp/pselle/init-installed
Browse files Browse the repository at this point in the history
Emit ProviderAlreadyInstalled when provider installed
  • Loading branch information
Pam Selle authored Feb 10, 2021
2 parents f97f8c2 + aa24bfe commit 0a99757
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/providercache/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ NeedProvider:
if installed := i.targetDir.ProviderVersion(provider, version); installed != nil {
if len(preferredHashes) > 0 {
if matches, _ := installed.MatchesAnyHash(preferredHashes); matches {
if cb := evts.ProviderAlreadyInstalled; cb != nil {
cb(provider, version)
}
continue
}
}
Expand Down
6 changes: 6 additions & 0 deletions internal/providercache/installer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"
"testing"

"github.com/apparentlymart/go-versions/versions"
"github.com/apparentlymart/go-versions/versions/constraints"
"github.com/davecgh/go-spew/spew"
"github.com/google/go-cmp/cmp"
Expand Down Expand Up @@ -646,6 +647,11 @@ func TestEnsureProviderVersions(t *testing.T) {
Provider: beepProvider,
Args: "2.0.0",
},
{
Event: "ProviderAlreadyInstalled",
Provider: beepProvider,
Args: versions.Version{Major: 2, Minor: 0, Patch: 0},
},
},
}
},
Expand Down

0 comments on commit 0a99757

Please sign in to comment.