Fix provisioning over new store
This commit is contained in:
@@ -228,11 +228,11 @@ func (app *CortezaApp) Provision(ctx context.Context) (err error) {
|
|||||||
ctx = auth.SetSuperUserContext(ctx)
|
ctx = auth.SetSuperUserContext(ctx)
|
||||||
|
|
||||||
if err = system.Provision(ctx, app.Log, app.Store); err != nil {
|
if err = system.Provision(ctx, app.Log, app.Store); err != nil {
|
||||||
return fmt.Errorf("could not provision messaging: %w", err)
|
return fmt.Errorf("could not provision system: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = compose.Provision(ctx, app.Log); err != nil {
|
if err = compose.Provision(ctx, app.Log); err != nil {
|
||||||
return fmt.Errorf("could not provision messaging: %w", err)
|
return fmt.Errorf("could not provision compose: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = messaging.Provision(ctx, app.Log); err != nil {
|
if err = messaging.Provision(ctx, app.Log); err != nil {
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package importer
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
|
||||||
|
|
||||||
"github.com/cortezaproject/corteza-server/compose/types"
|
"github.com/cortezaproject/corteza-server/compose/types"
|
||||||
"github.com/cortezaproject/corteza-server/pkg/deinterfacer"
|
"github.com/cortezaproject/corteza-server/pkg/deinterfacer"
|
||||||
"github.com/cortezaproject/corteza-server/pkg/importer"
|
"github.com/cortezaproject/corteza-server/pkg/importer"
|
||||||
@@ -87,6 +85,7 @@ func (imp *Importer) Cast(def interface{}) (err error) {
|
|||||||
var nsHandle string
|
var nsHandle string
|
||||||
// Solving a special case where namespace is defined as string
|
// Solving a special case where namespace is defined as string
|
||||||
// and we're treating value as namespace's handle
|
// and we're treating value as namespace's handle
|
||||||
|
println("provisioning namespaces")
|
||||||
deinterfacer.KVsetString(&nsHandle, "namespace", def)
|
deinterfacer.KVsetString(&nsHandle, "namespace", def)
|
||||||
if nsHandle != "" {
|
if nsHandle != "" {
|
||||||
delete(def.(map[interface{}]interface{}), "namespace")
|
delete(def.(map[interface{}]interface{}), "namespace")
|
||||||
@@ -140,7 +139,7 @@ func (imp *Importer) Store(
|
|||||||
if imp.namespaces != nil {
|
if imp.namespaces != nil {
|
||||||
err = imp.namespaces.Store(ctx, nsStore, mStore, cStore, pStore, rStore)
|
err = imp.namespaces.Store(ctx, nsStore, mStore, cStore, pStore, rStore)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not import namespaces")
|
return fmt.Errorf("could not import namespaces: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -154,7 +153,7 @@ func (imp *Importer) Store(
|
|||||||
|
|
||||||
err = imp.permissions.Store(ctx, pk)
|
err = imp.permissions.Store(ctx, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "could not import permissions")
|
return fmt.Errorf("could not import permissions: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,14 +80,14 @@ func (imp *Importer) Store(ctx context.Context, rk channelKeeper, pk permissions
|
|||||||
|
|
||||||
err = imp.permissions.Store(ctx, pk)
|
err = imp.permissions.Store(ctx, pk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return fmt.Errorf("could not provision permissions: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if imp.settings != nil {
|
if imp.settings != nil {
|
||||||
err = imp.settings.Store(ctx, sk)
|
err = imp.settings.Store(ctx, sk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return fmt.Errorf("could not provision settings: %w", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,20 @@ func (s Store) convertMessagingChannelFilter(f types.ChannelFilter) (query squir
|
|||||||
|
|
||||||
if f.CurrentUserID > 0 {
|
if f.CurrentUserID > 0 {
|
||||||
qcm := s.SelectBuilder(s.messagingChannelMemberTable("mcm"), "mcm.rel_channel").
|
qcm := s.SelectBuilder(s.messagingChannelMemberTable("mcm"), "mcm.rel_channel").
|
||||||
Where(squirrel.Eq{"cmc.rel_user:": f.CurrentUserID})
|
// minor squirrel quirk: change placeholder format to question
|
||||||
|
// on sub-queries. This will be reset to the right format internally
|
||||||
|
// when merged with main query
|
||||||
|
PlaceholderFormat(squirrel.Question).
|
||||||
|
Where(squirrel.Eq{"mcm.rel_user": f.CurrentUserID})
|
||||||
|
|
||||||
|
qcmSql, qcmArgs, err := qcm.ToSql()
|
||||||
|
if err != nil {
|
||||||
|
return query, err
|
||||||
|
}
|
||||||
|
|
||||||
query = query.Where(squirrel.Or{
|
query = query.Where(squirrel.Or{
|
||||||
squirrel.Eq{"c.type": types.ChannelTypePublic},
|
squirrel.Eq{"mch.type": types.ChannelTypePublic},
|
||||||
squirrel.Eq{"c.id": qcm},
|
squirrel.Expr("mch.id IN ("+qcmSql+")", qcmArgs...),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ func (imp *Importer) Store(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return fmt.Errorf("could not provision permissions: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user