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

Add retention rules #13

Merged
merged 4 commits into from
Jul 10, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
reformatted client calls to keep within maxiumum line length
  • Loading branch information
peters-david committed May 2, 2024
commit 046d860c8d00d214f1cf643a794bb990f5510d8a
17 changes: 13 additions & 4 deletions src/harbor.py
Original file line number Diff line number Diff line change
@@ -108,8 +108,12 @@ async def main() -> None:

# Sync retention policies
print('SYNCING RETENTION POLICIES')
retention_policies_config = json.load(open(config_folder_path + "/retention-policies.json"))
await sync_retention_policies(retention_policies=retention_policies_config)
retention_policies_config = json.load(
open(config_folder_path + "/retention-policies.json")
)
await sync_retention_policies(
retention_policies=retention_policies_config
)


async def sync_retention_policies(retention_policies: [RetentionPolicy]):
@@ -119,15 +123,20 @@ async def sync_retention_policies(retention_policies: [RetentionPolicy]):
for retention_policy in retention_policies:
retention_id = retention_policy.id
try:
current_retention_policy = await client.get_retention_policy(retention_id)
current_retention_policy = await client.get_retention_policy(
retention_id
)
if retention_policy != current_retention_policy:
retention_policies_to_update.append(retention_policy)
except NotFound e:
retention_policies_to_create.append(retention_policy)
# Update retention policies
for retention_policy_to_update in retention_policies_to_update:
retention_id = retention_policy_to_update.id
await client.update_retention_policy(retention_id, retention_policies_to_update)
await client.update_retention_policy(
retention_id,
retention_policies_to_update
)
# Create retention policies
for retention_policy_to_create in retention_policies_to_create:
await client.update_retention_policy(retention_policies_to_update)
Loading