Refactoring the what-changed again

I cannot pull these models apart, they are too inter-connected and imports will cycle.
This commit is contained in:
Dave Shanley
2022-10-23 12:14:31 -04:00
parent 1197562438
commit fcd4a0f57d
36 changed files with 407 additions and 372 deletions

View File

@@ -7,12 +7,11 @@ import (
"github.com/pb33f/libopenapi/datamodel/low"
"github.com/pb33f/libopenapi/datamodel/low/v2"
v3 "github.com/pb33f/libopenapi/datamodel/low/v3"
"github.com/pb33f/libopenapi/what-changed/core"
"gopkg.in/yaml.v3"
)
type SecurityRequirementChanges struct {
core.PropertyChanges
PropertyChanges
}
func (s *SecurityRequirementChanges) TotalChanges() int {
@@ -27,7 +26,7 @@ func CompareSecurityRequirement(l, r *v2.SecurityRequirement) *SecurityRequireme
if low.AreEqual(l, r) {
return nil
}
var changes []*core.Change
var changes []*Change
lKeys := make([]string, len(l.Values.Value))
rKeys := make([]string, len(r.Values.Value))
lValues := make(map[string]low.ValueReference[[]low.ValueReference[string]])
@@ -44,12 +43,12 @@ func CompareSecurityRequirement(l, r *v2.SecurityRequirement) *SecurityRequireme
z++
}
removed := func(z int, vn *yaml.Node, name string) {
core.CreateChange(&changes, core.ObjectRemoved, v3.SecurityDefinitionLabel,
CreateChange(&changes, ObjectRemoved, v3.SecurityDefinitionLabel,
vn, nil, true, name, nil)
}
added := func(z int, vn *yaml.Node, name string) {
core.CreateChange(&changes, core.ObjectAdded, v3.SecurityDefinitionLabel,
CreateChange(&changes, ObjectAdded, v3.SecurityDefinitionLabel,
nil, vn, false, nil, name)
}