fixed doc env vars + mongo v2 migration
This commit is contained in:
@@ -3,20 +3,20 @@ package helpers
|
||||
import (
|
||||
"context"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
)
|
||||
|
||||
// AccountManager defines the interface for account management operations
|
||||
type AccountManager interface {
|
||||
// DeleteOrganization deletes an organization and all its associated data
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
DeleteOrganization(ctx context.Context, orgRef primitive.ObjectID) error
|
||||
DeleteOrganization(ctx context.Context, orgRef bson.ObjectID) error
|
||||
|
||||
// DeleteAccount deletes an account and all its associated data
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
DeleteAccount(ctx context.Context, accountRef primitive.ObjectID) error
|
||||
DeleteAccount(ctx context.Context, accountRef bson.ObjectID) error
|
||||
|
||||
// DeleteAll deletes all data for a given account and organization
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
DeleteAll(ctx context.Context, accountRef, organizationRef primitive.ObjectID) error
|
||||
DeleteAll(ctx context.Context, accountRef, organizationRef bson.ObjectID) error
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/tech/sendico/pkg/db/policy"
|
||||
"github.com/tech/sendico/pkg/mlogger"
|
||||
"github.com/tech/sendico/pkg/mutil/mzap"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.mongodb.org/mongo-driver/v2/bson"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -45,7 +45,7 @@ func NewAccountManager(
|
||||
|
||||
// DeleteOrganization deletes an organization and all its associated data
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
func (m *AccountManager) DeleteOrganization(ctx context.Context, orgRef primitive.ObjectID) error {
|
||||
func (m *AccountManager) DeleteOrganization(ctx context.Context, orgRef bson.ObjectID) error {
|
||||
m.logger.Debug("Deleting organization", mzap.ObjRef("org_ref", orgRef))
|
||||
|
||||
// Delete organization roles
|
||||
@@ -61,7 +61,7 @@ func (m *AccountManager) DeleteOrganization(ctx context.Context, orgRef primitiv
|
||||
}
|
||||
|
||||
// Finally delete the organization itself
|
||||
if err := m.orgDB.Delete(ctx, primitive.NilObjectID, orgRef); err != nil {
|
||||
if err := m.orgDB.Delete(ctx, bson.NilObjectID, orgRef); err != nil {
|
||||
m.logger.Warn("Failed to delete organization", zap.Error(err), mzap.ObjRef("org_ref", orgRef))
|
||||
return err
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (m *AccountManager) DeleteOrganization(ctx context.Context, orgRef primitiv
|
||||
|
||||
// DeleteAccount deletes an account and all its associated data
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
func (m *AccountManager) DeleteAccount(ctx context.Context, accountRef primitive.ObjectID) error {
|
||||
func (m *AccountManager) DeleteAccount(ctx context.Context, accountRef bson.ObjectID) error {
|
||||
m.logger.Debug("Deleting account", mzap.ObjRef("account_ref", accountRef))
|
||||
|
||||
// Delete the account
|
||||
@@ -87,7 +87,7 @@ func (m *AccountManager) DeleteAccount(ctx context.Context, accountRef primitive
|
||||
|
||||
// DeleteAll deletes all data for a given account and organization
|
||||
// The caller is responsible for wrapping this in a transaction
|
||||
func (m *AccountManager) DeleteAll(ctx context.Context, accountRef, organizationRef primitive.ObjectID) error {
|
||||
func (m *AccountManager) DeleteAll(ctx context.Context, accountRef, organizationRef bson.ObjectID) error {
|
||||
m.logger.Debug("Deleting all data", mzap.ObjRef("account_ref", accountRef), mzap.ObjRef("organization_ref", organizationRef))
|
||||
|
||||
// Delete organization first (which will cascade delete all related data)
|
||||
@@ -107,7 +107,7 @@ func (m *AccountManager) DeleteAll(ctx context.Context, accountRef, organization
|
||||
}
|
||||
|
||||
// deleteOrganizationRoles deletes all roles for an organization
|
||||
func (m *AccountManager) deleteOrganizationRoles(ctx context.Context, orgRef primitive.ObjectID) error {
|
||||
func (m *AccountManager) deleteOrganizationRoles(ctx context.Context, orgRef bson.ObjectID) error {
|
||||
// Get all roles for the organization
|
||||
roles, err := m.authManager.Role().List(ctx, orgRef)
|
||||
if err != nil {
|
||||
@@ -128,7 +128,7 @@ func (m *AccountManager) deleteOrganizationRoles(ctx context.Context, orgRef pri
|
||||
}
|
||||
|
||||
// deleteOrganizationPolicies deletes all policies for an organization
|
||||
func (m *AccountManager) deleteOrganizationPolicies(_ context.Context, _ primitive.ObjectID) error {
|
||||
func (m *AccountManager) deleteOrganizationPolicies(_ context.Context, _ bson.ObjectID) error {
|
||||
// Note: PolicyDB is used for both roles and policies, but the interface is unclear
|
||||
// This would need to be implemented differently or skipped for now
|
||||
m.logger.Warn("Policy deletion not implemented - interface unclear")
|
||||
|
||||
Reference in New Issue
Block a user