mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 08:51:02 -06:00
rename some Constraints methods per code review
This commit is contained in:
parent
211f5b5d6e
commit
044ad5ef59
@ -39,7 +39,7 @@ func (m mockGetProvider) GetProvider(dst, provider string, req discovery.Constra
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if req.Has(version) {
|
||||
if req.Allows(version) {
|
||||
// provider filename
|
||||
name := m.FileName(provider, v)
|
||||
path := filepath.Join(dst, name)
|
||||
|
@ -114,7 +114,7 @@ func (m *Module) PluginRequirements() discovery.PluginRequirements {
|
||||
// by using Intersection to merge the version sets.
|
||||
pty := inst.Type()
|
||||
if existing, exists := ret[pty]; exists {
|
||||
ret[pty] = existing.Intersection(dep.Constraints)
|
||||
ret[pty] = existing.Append(dep.Constraints)
|
||||
} else {
|
||||
ret[pty] = dep.Constraints
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ func newestVersion(available []Version, required Constraints) (Version, error) {
|
||||
found := false
|
||||
|
||||
for _, v := range available {
|
||||
if required.Has(v) {
|
||||
if required.Allows(v) {
|
||||
if !found {
|
||||
latest = v
|
||||
found = true
|
||||
|
@ -139,7 +139,7 @@ func (s PluginMetaSet) ConstrainVersions(reqd PluginRequirements) map[string]Plu
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if allowedVersions.Has(version) {
|
||||
if allowedVersions.Allows(version) {
|
||||
ret[p.Name].Add(p)
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ func (r PluginRequirements) Merge(other PluginRequirements) PluginRequirements {
|
||||
}
|
||||
for n, vs := range other {
|
||||
if existing, exists := ret[n]; exists {
|
||||
ret[n] = existing.Intersection(vs)
|
||||
ret[n] = existing.Append(vs)
|
||||
} else {
|
||||
ret[n] = vs
|
||||
}
|
||||
|
@ -43,15 +43,15 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
// Has returns true if the given version is in the receiving set.
|
||||
func (s Constraints) Has(v Version) bool {
|
||||
// Allows returns true if the given version is in the receiving set.
|
||||
func (s Constraints) Allows(v Version) bool {
|
||||
return s.raw.Check(v.raw)
|
||||
}
|
||||
|
||||
// Intersection combines the receiving set with the given other set to produce
|
||||
// Append combines the receiving set with the given other set to produce
|
||||
// a set that is the intersection of both sets, which is to say that resulting
|
||||
// constraints contain only the versions that are members of both.
|
||||
func (s Constraints) Intersection(other Constraints) Constraints {
|
||||
func (s Constraints) Append(other Constraints) Constraints {
|
||||
raw := make(version.Constraints, 0, len(s.raw)+len(other.raw))
|
||||
|
||||
// Since "raw" is a list of constraints that remove versions from the set,
|
||||
|
@ -56,7 +56,7 @@ func TestVersionSet(t *testing.T) {
|
||||
t.Fatalf("unwanted error parsing version string %q: %s", test.VersionStr, err)
|
||||
}
|
||||
|
||||
if got, want := accepted.Has(version), test.ShouldHave; got != want {
|
||||
if got, want := accepted.Allows(version), test.ShouldHave; got != want {
|
||||
t.Errorf("Has returned %#v; want %#v", got, want)
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user