2023-04-20 12:40:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2023-04-11 18:23:14 +00:00
|
|
|
package resource
|
|
|
|
|
|
|
|
import (
|
|
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/proto-public/pbresource"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EqualStatus compares two status maps for equality.
|
|
|
|
func EqualStatus(a, b map[string]*pbresource.Status) bool {
|
|
|
|
if len(a) != len(b) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
compared := make(map[string]struct{})
|
|
|
|
for k, av := range a {
|
|
|
|
bv, ok := b[k]
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if !proto.Equal(av, bv) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
compared[k] = struct{}{}
|
|
|
|
}
|
|
|
|
|
|
|
|
for k, bv := range b {
|
|
|
|
if _, skip := compared[k]; skip {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
av, ok := a[k]
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
if !proto.Equal(av, bv) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true
|
|
|
|
}
|