Emit ProviderAlreadyInstalled when provider installed

Emit the ProviderAlreadyInstalled event when we successfully verify
that we've already installed this provider and are skipping
installation
This commit is contained in:
Pam Selle 2021-02-09 11:08:49 -05:00
parent 96be094ecd
commit aa24bfec47
2 changed files with 9 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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"
@ -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},
},
},
}
},