Skip to content

Commit

Permalink
Emit ProviderAlreadyInstalled when provider installed
Browse files Browse the repository at this point in the history
Emit the ProviderAlreadyInstalled event when we successfully verify
that we've already installed this provider and are skipping
installation
  • Loading branch information
pselle committed Feb 9, 2021
1 parent 96be094 commit aa24bfe
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 aa24bfe

Please sign in to comment.