restructure and process additions and deleteions of relationships, roles and memberships
This commit is contained in:
@@ -13,20 +13,39 @@ import (
|
||||
|
||||
const (
|
||||
// TypeOrganization defines the organization type.
|
||||
TypeOrganization = "organization"
|
||||
TypeOrganization ObjectType = "organization"
|
||||
|
||||
// TypeProject defines the project type.
|
||||
TypeProject = "project"
|
||||
TypeProject ObjectType = "project"
|
||||
|
||||
// TypeUser defines the user type.
|
||||
TypeUser = "user"
|
||||
TypeUser ObjectType = "user"
|
||||
)
|
||||
|
||||
// DefaultPrefixMap is the default id prefix to type relationship.
|
||||
var DefaultPrefixMap = map[string]string{
|
||||
"metlorg": TypeOrganization,
|
||||
"metlprj": TypeProject,
|
||||
"metlusr": TypeUser,
|
||||
var DefaultPrefixMap = map[string]ObjectType{
|
||||
TypeOrganization.Prefix(): TypeOrganization,
|
||||
TypeProject.Prefix(): TypeProject,
|
||||
TypeUser.Prefix(): TypeUser,
|
||||
}
|
||||
|
||||
type ObjectType string
|
||||
|
||||
func (t ObjectType) Prefix() string {
|
||||
switch t {
|
||||
case TypeOrganization:
|
||||
return "metlorg"
|
||||
case TypeProject:
|
||||
return "metlprj"
|
||||
case TypeUser:
|
||||
return "metlusr"
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
func (t ObjectType) String() string {
|
||||
return string(t)
|
||||
}
|
||||
|
||||
// Service defines a bridge service methods
|
||||
@@ -63,7 +82,7 @@ type service struct {
|
||||
publisher *events.Publisher
|
||||
metal *metal.Client
|
||||
perms *permissions.Client
|
||||
idPrefixMap map[string]string
|
||||
idPrefixMap map[string]ObjectType
|
||||
|
||||
rootResource prefixedID
|
||||
roles map[string][]string
|
||||
@@ -82,7 +101,7 @@ func New(publisher *events.Publisher, metal *metal.Client, perms *permissions.Cl
|
||||
publisher: publisher,
|
||||
metal: metal,
|
||||
perms: perms,
|
||||
idPrefixMap: make(map[string]string),
|
||||
idPrefixMap: make(map[string]ObjectType),
|
||||
}
|
||||
|
||||
for _, opt := range options {
|
||||
|
||||
Reference in New Issue
Block a user