diff --git a/idm/policy/defaults.go b/idm/policy/defaults.go index de7a7cc6d9..2f8f21c536 100644 --- a/idm/policy/defaults.go +++ b/idm/policy/defaults.go @@ -665,3 +665,24 @@ func Upgrade4199(ctx context.Context) error { } return nil } + +func Upgrade4399(ctx context.Context) error { + dao := servicecontext.GetDAO(ctx).(DAO) + if dao == nil { + return fmt.Errorf("cannot find DAO for policies initialization") + } + groups, e := dao.ListPolicyGroups(ctx, "") + if e != nil { + return e + } + for _, group := range groups { + if strings.HasPrefix(group.Name, "PolicyGroup.ACLSample") { + if er := dao.DeletePolicyGroup(ctx, group); er != nil { + log.Logger(ctx).Error("could not delete policy group "+group.Uuid, zap.Error(er)) + } else { + log.Logger(ctx).Info("Removed sample policy group replaced by the template picker " + group.Uuid) + } + } + } + return nil +} diff --git a/idm/policy/grpc/plugins.go b/idm/policy/grpc/plugins.go index f1ec59a03e..3e000b5248 100644 --- a/idm/policy/grpc/plugins.go +++ b/idm/policy/grpc/plugins.go @@ -92,6 +92,10 @@ func init() { TargetVersion: service.ValidVersion("4.1.99"), Up: policy.Upgrade4199, }, + { + TargetVersion: service.ValidVersion("4.3.99"), + Up: policy.Upgrade4399, + }, }), service.WithGRPC(func(ctx context.Context, server grpc.ServiceRegistrar) error { handler := NewHandler(ctx, servicecontext.GetDAO(ctx).(policy.DAO))