forked from goharbor/harbor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the registry and replication rule related to the Chartmuseum
Update replication_policy and registry 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
Yang Jiao
committed
Mar 1, 2023
1 parent
320c64e
commit ef74b9c
Showing
1 changed file
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,31 @@ | ||
/* remove the redundant data from table artifact_blob */ | ||
delete from artifact_blob afb where not exists (select digest from blob b where b.digest = afb.digest_af); | ||
delete from artifact_blob afb where not exists (select digest from blob b where b.digest = afb.digest_af); | ||
/* Update the registry and replication policy associated with the chartmuseum */ | ||
UPDATE registry | ||
SET description = 'Chartmuseum has been deprecated in Harbor v2.8.0, please update this registry.' | ||
WHERE type in ('artifact-hub', 'helm-hub'); | ||
WITH filter_objects AS ( | ||
SELECT id, jsonb_array_elements(filters::jsonb) AS filter | ||
FROM replication_policy | ||
WHERE filters IS NOT NULL AND filters != '' | ||
AND jsonb_typeof(CAST(filters AS jsonb)) = 'array' | ||
), | ||
registry_ids AS ( | ||
SELECT rp.id | ||
FROM registry r | ||
INNER JOIN replication_policy rp ON (rp.dest_registry_id = r.id OR rp.src_registry_id = r.id) | ||
WHERE r.type IN ('artifact-hub', 'helm-hub') | ||
) | ||
UPDATE replication_policy AS rp | ||
SET enabled = false, | ||
filters = ( | ||
SELECT COALESCE(jsonb_agg(fo.filter)::text, '') | ||
FROM filter_objects AS fo | ||
WHERE fo.id = rp.id AND NOT(filter ->> 'type' = 'resource' AND filter ->> 'value' = 'chart') | ||
), | ||
description = 'Chartmuseum is deprecated in Harbor v2.8.0, because the Source resource filter of this rule is chart(chartmuseum), so please update this rule.' | ||
WHERE id IN ( | ||
SELECT id FROM filter_objects WHERE (filter ->> 'type' = 'resource' AND filter ->> 'value' = 'chart') | ||
UNION | ||
SELECT id FROM registry_ids | ||
); |