Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only overwrite created_at in case the account was deleted #643

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions fixbackend/cloud_accounts/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,16 +874,19 @@ async def create_gcp_account(
if existing:

def set_state(acc: CloudAccount) -> CloudAccount:
return evolve(
evolved = evolve(
acc,
state=CloudAccountStates.Configured(
access=GcpCloudAccess(key_id), enabled=should_be_enabled, scan=should_be_enabled
),
account_name=account_name,
state_updated_at=utc(),
created_at=created_at,
updated_at=created_at,
)
if isinstance(existing.state, CloudAccountStates.Deleted):
evolved = evolve(evolved, created_at=created_at)

return evolved

result = await self.cloud_account_repository.update(existing.id, set_state)
log.info(f"GCP cloud Account {account_id} updated from deleted to configured")
Expand Down Expand Up @@ -957,17 +960,20 @@ async def create_azure_account(
if existing:

def set_state(acc: CloudAccount) -> CloudAccount:
return evolve(
evolved = evolve(
acc,
state=CloudAccountStates.Configured(
access=AzureCloudAccess(subscription_credentials_id),
enabled=should_be_enabled,
scan=should_be_enabled,
),
state_updated_at=utc(),
created_at=created_at,
updated_at=created_at,
)
if isinstance(existing.state, CloudAccountStates.Deleted):
evolved = evolve(evolved, created_at=created_at)

return evolved

result = await self.cloud_account_repository.update(existing.id, set_state)
log.info(f"Azure cloud Account {account_id} updated from deleted to configured")
Expand Down