29 lines
564 B
Go
29 lines
564 B
Go
package spec
|
|
|
|
import (
|
|
"github.com/mitchellh/hashstructure/v2"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
func Equals(a Spec, b Spec) (bool, error) {
|
|
if a.SpecName() != b.SpecName() {
|
|
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
|
|
}
|