feat: basic authorization model

This commit is contained in:
2023-03-13 10:44:58 +01:00
parent 55db21ad23
commit fa36d55163
28 changed files with 589 additions and 114 deletions

View File

@ -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
View 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
}

View File

@ -32,6 +32,7 @@ func (s *Spec) SpecData() map[string]any {
func NewSpec() *Spec {
return &Spec{
Revision: -1,
Gateways: make(map[ID]GatewayEntry),
}
}

View File

@ -35,6 +35,7 @@ func (s *Spec) SpecData() map[string]any {
func NewSpec() *Spec {
return &Spec{
Revision: -1,
PostImportCommands: make([]*UCIPostImportCommand, 0),
}
}