feat: basic authorization model
This commit is contained in:
@ -33,7 +33,9 @@ func (s *Spec) SpecData() map[string]any {
|
||||
}
|
||||
|
||||
func NewSpec() *Spec {
|
||||
return &Spec{}
|
||||
return &Spec{
|
||||
Revision: -1,
|
||||
}
|
||||
}
|
||||
|
||||
var _ spec.Spec = &Spec{}
|
||||
|
28
internal/spec/compare.go
Normal file
28
internal/spec/compare.go
Normal file
@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
@ -32,6 +32,7 @@ func (s *Spec) SpecData() map[string]any {
|
||||
|
||||
func NewSpec() *Spec {
|
||||
return &Spec{
|
||||
Revision: -1,
|
||||
Gateways: make(map[ID]GatewayEntry),
|
||||
}
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ func (s *Spec) SpecData() map[string]any {
|
||||
|
||||
func NewSpec() *Spec {
|
||||
return &Spec{
|
||||
Revision: -1,
|
||||
PostImportCommands: make([]*UCIPostImportCommand, 0),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user