2023-03-13 10:44:58 +01:00
|
|
|
package spec
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mitchellh/hashstructure/v2"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Equals(a Spec, b Spec) (bool, error) {
|
2024-03-12 16:22:35 +01:00
|
|
|
if a.SpecDefinitionName() != b.SpecDefinitionName() {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.SpecDefinitionVersion() != b.SpecDefinitionVersion() {
|
2023-03-13 10:44:58 +01:00
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
if a.SpecRevision() != b.SpecRevision() {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
hashA, err := hashstructure.Hash(a.SpecData(), hashstructure.FormatV2, nil)
|
|
|
|
if err != nil {
|
|
|
|
return false, errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
hashB, err := hashstructure.Hash(b.SpecData(), hashstructure.FormatV2, nil)
|
|
|
|
if err != nil {
|
|
|
|
return false, errors.WithStack(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return hashA == hashB, nil
|
|
|
|
}
|