Cleanup provisioning
Remove programatic role provisioning and compl. rely on yaml files
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func apps(ctx context.Context, s store.Storer) error {
|
||||
func migrateApplications(ctx context.Context, s store.Storer) error {
|
||||
rd := releaseDate(2021, time.March)
|
||||
|
||||
set, _, err := store.SearchApplications(ctx, s, types.ApplicationFilter{})
|
||||
|
||||
@@ -17,11 +17,8 @@ import (
|
||||
|
||||
func Run(ctx context.Context, log *zap.Logger, s store.Storer, provisionOpt options.ProvisionOpt, authOpt options.AuthOpt) error {
|
||||
ffn := []func() error{
|
||||
// Old relics
|
||||
func() error { return roles(ctx, s) },
|
||||
|
||||
// Migrations:
|
||||
func() error { return apps(ctx, s) },
|
||||
func() error { return migrateApplications(ctx, s) },
|
||||
func() error { return migrateEmailTemplates(ctx, log, s) },
|
||||
|
||||
// Config (full & partial)
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package provision
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/cortezaproject/corteza-server/pkg/rbac"
|
||||
"github.com/cortezaproject/corteza-server/store"
|
||||
"github.com/cortezaproject/corteza-server/system/types"
|
||||
)
|
||||
|
||||
func roles(ctx context.Context, s store.Storer) error {
|
||||
if set, _, err := store.SearchRoles(ctx, s, types.RoleFilter{}); err != nil {
|
||||
return err
|
||||
} else if len(set) > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
now := time.Now().Round(time.Second)
|
||||
|
||||
rr := types.RoleSet{
|
||||
&types.Role{ID: rbac.AdminsRoleID, Name: "Administrators", Handle: "admins"},
|
||||
&types.Role{ID: rbac.EveryoneRoleID, Name: "Everyone", Handle: "everyone"},
|
||||
}
|
||||
|
||||
err := rr.Walk(func(r *types.Role) error {
|
||||
r.CreatedAt = now
|
||||
return store.CreateRole(ctx, s, r)
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user