Update discovery unsigned_long mapping type to long
It fixes issue with open search container, since it does not support unsigned_long type yet. Also, fixes mapping list and excludes all disabled resource mappings.
This commit is contained in:
@@ -44,7 +44,7 @@ func (m composeMapping) Namespaces(ctx context.Context) ([]*Mapping, error) {
|
||||
Mapping: map[string]*property{
|
||||
"resourceType": {Type: "keyword"},
|
||||
|
||||
"namespaceID": {Type: "unsigned_long"},
|
||||
"namespaceID": {Type: "long"},
|
||||
|
||||
"name": {Type: "keyword", Boost: 2},
|
||||
"handle": {Type: "keyword", Boost: 2},
|
||||
@@ -63,12 +63,12 @@ func (m composeMapping) Namespaces(ctx context.Context) ([]*Mapping, error) {
|
||||
|
||||
"security": security(),
|
||||
|
||||
"namespace": &property{
|
||||
"namespace": {
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"namespaceID": &property{Type: "unsigned_long"},
|
||||
"name": &property{Type: "text"},
|
||||
"handle": &property{Type: "keyword"},
|
||||
"namespaceID": {Type: "long"},
|
||||
"name": {Type: "text"},
|
||||
"handle": {Type: "keyword"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -81,7 +81,7 @@ func (m composeMapping) Modules(ctx context.Context) ([]*Mapping, error) {
|
||||
Mapping: map[string]*property{
|
||||
"resourceType": {Type: "keyword"},
|
||||
|
||||
"moduleID": &property{Type: "unsigned_long"},
|
||||
"moduleID": {Type: "long"},
|
||||
"created": change(),
|
||||
"updated": change(),
|
||||
"deleted": change(),
|
||||
@@ -102,20 +102,20 @@ func (m composeMapping) Modules(ctx context.Context) ([]*Mapping, error) {
|
||||
},
|
||||
},
|
||||
|
||||
"namespace": &property{
|
||||
"namespace": {
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"namespaceID": &property{Type: "unsigned_long"},
|
||||
"name": &property{Type: "text"},
|
||||
"handle": &property{Type: "keyword"},
|
||||
"namespaceID": {Type: "long"},
|
||||
"name": {Type: "text"},
|
||||
"handle": {Type: "keyword"},
|
||||
},
|
||||
},
|
||||
"module": &property{
|
||||
"module": {
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"moduleID": &property{Type: "unsigned_long"},
|
||||
"name": &property{Type: "text"},
|
||||
"handle": &property{Type: "keyword"},
|
||||
"moduleID": {Type: "long"},
|
||||
"name": {Type: "text"},
|
||||
"handle": {Type: "keyword"},
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -174,7 +174,7 @@ func (m composeMapping) records(ctx context.Context, mod *types.Module, mm types
|
||||
}
|
||||
mapping.Mapping["resourceType"] = &property{Type: "keyword"}
|
||||
|
||||
mapping.Mapping["recordID"] = &property{Type: "unsigned_long"}
|
||||
mapping.Mapping["recordID"] = &property{Type: "long"}
|
||||
mapping.Mapping["url"] = &property{Type: "text"}
|
||||
mapping.Mapping["created"] = change()
|
||||
mapping.Mapping["updated"] = change()
|
||||
@@ -193,17 +193,17 @@ func (m composeMapping) records(ctx context.Context, mod *types.Module, mm types
|
||||
mapping.Mapping["module"] = &property{
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"moduleID": &property{Type: "unsigned_long"},
|
||||
"name": &property{Type: "text"},
|
||||
"handle": &property{Type: "keyword"},
|
||||
"moduleID": {Type: "long"},
|
||||
"name": {Type: "text"},
|
||||
"handle": {Type: "keyword"},
|
||||
},
|
||||
}
|
||||
mapping.Mapping["namespace"] = &property{
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"namespaceID": &property{Type: "unsigned_long"},
|
||||
"name": &property{Type: "text"},
|
||||
"handle": &property{Type: "keyword"},
|
||||
"namespaceID": {Type: "long"},
|
||||
"name": {Type: "text"},
|
||||
"handle": {Type: "keyword"},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func change() *property {
|
||||
Properties: map[string]*property{
|
||||
"at": {Type: "date"},
|
||||
"by": {Type: "nested", Properties: map[string]*property{
|
||||
"id": {Type: "unsigned_long"},
|
||||
"id": {Type: "long"},
|
||||
"email": {Type: "keyword"},
|
||||
"name": {Type: "keyword"},
|
||||
"handle": {Type: "keyword"},
|
||||
@@ -41,8 +41,8 @@ func security() *property {
|
||||
return &property{
|
||||
Type: "nested",
|
||||
Properties: map[string]*property{
|
||||
"allowedRoles": {Type: "unsigned_long"},
|
||||
"deniedRoles": {Type: "unsigned_long"},
|
||||
"allowedRoles": {Type: "long"},
|
||||
"deniedRoles": {Type: "long"},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func (svc systemMapping) Users(_ context.Context) ([]*Mapping, error) {
|
||||
Mapping: map[string]*property{
|
||||
"resourceType": {Type: "keyword"},
|
||||
|
||||
"userID": {Type: "unsigned_long"},
|
||||
"userID": {Type: "long"},
|
||||
|
||||
"email": {Type: "keyword", Boost: 2},
|
||||
"name": {Type: "keyword", Boost: 10},
|
||||
|
||||
@@ -4,10 +4,14 @@ import (
|
||||
"context"
|
||||
"github.com/cortezaproject/corteza-server/discovery/rest/internal/mapping"
|
||||
"github.com/cortezaproject/corteza-server/discovery/rest/request"
|
||||
"github.com/cortezaproject/corteza-server/system/service"
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
type (
|
||||
mappings struct {
|
||||
settings *types.AppSettings
|
||||
|
||||
sys interface {
|
||||
Users(context.Context) ([]*mapping.Mapping, error)
|
||||
}
|
||||
@@ -22,8 +26,9 @@ type (
|
||||
|
||||
func Mappings() *mappings {
|
||||
return &mappings{
|
||||
sys: mapping.SystemMapping(),
|
||||
cmp: mapping.ComposeMapping(),
|
||||
settings: service.CurrentSettings,
|
||||
sys: mapping.SystemMapping(),
|
||||
cmp: mapping.ComposeMapping(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +41,18 @@ func (ctrl mappings) List(ctx context.Context, r *request.MappingsList) (interfa
|
||||
mappingFn = make([]func(ctx context.Context) ([]*mapping.Mapping, error), 4)
|
||||
)
|
||||
|
||||
mappingFn = append(mappingFn, ctrl.sys.Users)
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Namespaces)
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Modules)
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Records)
|
||||
if ctrl.settings.Discovery.SystemUsers.Enabled {
|
||||
mappingFn = append(mappingFn, ctrl.sys.Users)
|
||||
}
|
||||
if ctrl.settings.Discovery.ComposeNamespaces.Enabled {
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Namespaces)
|
||||
}
|
||||
if ctrl.settings.Discovery.ComposeModules.Enabled {
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Modules)
|
||||
}
|
||||
if ctrl.settings.Discovery.ComposeRecords.Enabled {
|
||||
mappingFn = append(mappingFn, ctrl.cmp.Records)
|
||||
}
|
||||
|
||||
return out, func() error {
|
||||
for _, fn := range mappingFn {
|
||||
|
||||
Reference in New Issue
Block a user