Skip to content

Commit

Permalink
Migrate robot account and notification policy related to Chartmuseum (#…
Browse files Browse the repository at this point in the history
…18316)

Migrate robot permission and notification policy related to Chartmuseum

Update robot permission and notification policy as Harbor v2.8.0 deprecates chartmuseum.
Harbor deprecates chartmuseum as of v2.8.0
Epic: goharbor#17958
Discussion: goharbor#15057

Signed-off-by: Yang Jiao <[email protected]>
  • Loading branch information
YangJiao0817 authored Mar 10, 2023
1 parent e8e56fd commit 1e38565
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions make/migrations/postgresql/0110_2.8.0_schema.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,33 @@ WHERE id IN (
UNION
SELECT id FROM replication_policy_ids
);
/* Update the role permission and permission policy associated with the chartmuseum */
DELETE FROM role_permission
WHERE permission_policy_id IN (
SELECT id FROM permission_policy WHERE resource IN ('helm-chart', 'helm-chart-version' ,'helm-chart-version-label')
);

DELETE FROM permission_policy
WHERE resource IN ('helm-chart', 'helm-chart-version' ,'helm-chart-version-label');
/* Update the notification policy associated with the chartmuseum */
WITH event_type_objects AS (
SELECT id, jsonb_array_elements(event_types::jsonb) as event_type
FROM notification_policy
WHERE event_types IS NOT NULL AND event_types != ''
AND jsonb_typeof(CAST(event_types AS jsonb)) = 'array'
)
UPDATE notification_policy AS np
SET event_types = (
SELECT COALESCE(jsonb_agg(eto.event_type), '[]')
FROM event_type_objects AS eto
WHERE eto.id = np.id
AND NOT(event_type @> '"UPLOAD_CHART"'::jsonb OR event_type @> '"DOWNLOAD_CHART"'::jsonb OR event_type @> '"DELETE_CHART"'::jsonb)
)
WHERE id IN (
SELECT id FROM event_type_objects WHERE (event_type @> '"UPLOAD_CHART"'::jsonb OR event_type @> '"DOWNLOAD_CHART"'::jsonb OR event_type @> '"DELETE_CHART"'::jsonb)
);

UPDATE notification_policy
SET enabled = false,
description = 'Chartmuseum is deprecated in Harbor v2.8.0, because this notification policy only has event type about Chartmuseum, so please update or delete this notification policy.'
WHERE event_types = '[]';

0 comments on commit 1e38565

Please sign in to comment.