Rename migration functions (6->9)

This commit is contained in:
Denis Arh
2021-07-22 07:32:57 +02:00
parent 55cb5f7a19
commit ef28b1a4af
4 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -14,7 +14,7 @@ import (
)
// MigrateOperations creates system roles
func migratePre202106RbacRules(ctx context.Context, log *zap.Logger, s store.Storer) error {
func migratePre202109RbacRules(ctx context.Context, log *zap.Logger, s store.Storer) error {
return store.Tx(ctx, s, func(ctx context.Context, s store.Storer) error {
rr, _, err := store.SearchRbacRules(ctx, s, rbac.RuleFilter{})
if err != nil {
@@ -25,7 +25,7 @@ func migratePre202106RbacRules(ctx context.Context, log *zap.Logger, s store.Sto
for _, r := range rr {
var (
cr = *r
action = migratePre202106RbacRule(r)
action = migratePre202109RbacRule(r)
)
if action != 0 {
@@ -50,7 +50,7 @@ func migratePre202106RbacRules(ctx context.Context, log *zap.Logger, s store.Sto
// 0 - no action
// -1 - remove
// 1 - update
func migratePre202106RbacRule(r *rbac.Rule) (op int) {
func migratePre202109RbacRule(r *rbac.Rule) (op int) {
const (
nsSep = "::"
nsDef = "corteza"
+2 -2
View File
@@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require"
)
func Test_migratePre202106RbacRule(t *testing.T) {
func Test_migratePre202109RbacRule(t *testing.T) {
tcc := []struct {
wantOp int
rule *rbac.Rule
@@ -23,7 +23,7 @@ func Test_migratePre202106RbacRule(t *testing.T) {
}
for _, tc := range tcc {
t.Run(tc.rule.String(), func(t *testing.T) {
require.Equal(t, tc.wantOp, migratePre202106RbacRule(tc.rule))
require.Equal(t, tc.wantOp, migratePre202109RbacRule(tc.rule))
if tc.wantRule != nil {
require.Equal(t, tc.wantRule.String(), tc.rule.String())
}
+1 -1
View File
@@ -8,7 +8,7 @@ import (
"go.uber.org/zap"
)
func migratePre202106Roles(ctx context.Context, log *zap.Logger, s store.Storer) (err error) {
func migratePre202109Roles(ctx context.Context, log *zap.Logger, s store.Storer) (err error) {
const (
obsoleteEveryoneID uint64 = 1
obsoleteAdminsID uint64 = 2
+3 -3
View File
@@ -28,9 +28,9 @@ func Run(ctx context.Context, log *zap.Logger, s store.Storer, provisionOpt opti
// Migrations:
func() error { return migrateApplications(ctx, s) },
func() error { return migrateEmailTemplates(ctx, log.Named("email-templates"), s) },
func() error { return migratePre202106Roles(ctx, log.Named("pre-202106-roles"), s) },
func() error { return migratePre202106RbacRules(ctx, log.Named("pre-202106-rbac-rules"), s) },
func() error { return cleanupPre202109Settings(ctx, log.Named("pre-202106-rbac-rules"), s) },
func() error { return migratePre202109Roles(ctx, log.Named("pre-202109-roles"), s) },
func() error { return migratePre202109RbacRules(ctx, log.Named("pre-202109-rbac-rules"), s) },
func() error { return cleanupPre202109Settings(ctx, log.Named("pre-202109-settings"), s) },
// Config (full & partial)
func() error { return importConfig(ctx, log.Named("config"), s, provisionOpt.Path) },