Commit 567911fd authored by Steve Abrams's avatar Steve Abrams Committed by Mayra Cabrera

Add name_regex_keep to ContainerExpirationPolicy

Add new column to container_expiration_policies to
specify tags to retain within a policy.
parent 6fe41e77
---
title: Add name_regex_keep to container_expiration_policies
merge_request: 29618
author:
type: added
# frozen_string_literal: true
class AddNameRegexKeepToContainerExpirationPolicies < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
CONSTRAINT_NAME = 'container_expiration_policies_name_regex_keep'
def up
add_column(:container_expiration_policies, :name_regex_keep, :text)
add_text_limit(:container_expiration_policies, :name_regex_keep, 255, constraint_name: CONSTRAINT_NAME)
end
def down
remove_check_constraint(:container_expiration_policies, CONSTRAINT_NAME)
remove_column(:container_expiration_policies, :name_regex_keep)
end
end
......@@ -1867,7 +1867,9 @@ CREATE TABLE public.container_expiration_policies (
cadence character varying(12) DEFAULT '7d'::character varying NOT NULL,
older_than character varying(12),
keep_n integer,
enabled boolean DEFAULT true NOT NULL
enabled boolean DEFAULT true NOT NULL,
name_regex_keep text,
CONSTRAINT container_expiration_policies_name_regex_keep CHECK ((char_length(name_regex_keep) <= 255))
);
CREATE TABLE public.container_repositories (
......@@ -13188,5 +13190,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200415160722
20200415161021
20200415161206
20200415192656
\.
......@@ -8,6 +8,7 @@ module API
expose :keep_n
expose :older_than
expose :name_regex
expose :name_regex_keep
expose :next_run_at
end
end
......
......@@ -85,6 +85,7 @@ module API
optional :keep_n, type: String, desc: 'Container expiration policy number of images to keep'
optional :older_than, type: String, desc: 'Container expiration policy remove images older than value'
optional :name_regex, type: String, desc: 'Container expiration policy regex for image removal'
optional :name_regex_keep, type: String, desc: 'Container expiration policy regex for image retention'
optional :enabled, type: Boolean, desc: 'Flag indication if container expiration policy is enabled'
end
......
......@@ -812,6 +812,7 @@ ContainerExpirationPolicy:
- next_run_at
- project_id
- name_regex
- name_regex_keep
- cadence
- older_than
- keep_n
......
......@@ -2414,7 +2414,8 @@ describe API::Projects do
project_param = {
container_expiration_policy_attributes: {
cadence: '1month',
keep_n: 1
keep_n: 1,
name_regex_keep: 'foo.*'
}
}
......@@ -2424,6 +2425,7 @@ describe API::Projects do
expect(json_response['container_expiration_policy']['cadence']).to eq('1month')
expect(json_response['container_expiration_policy']['keep_n']).to eq(1)
expect(json_response['container_expiration_policy']['name_regex_keep']).to eq('foo.*')
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment