Commit 0ce239ac authored by Steve Abrams's avatar Steve Abrams Committed by Toon Claes

Container expiration policies enabled by default

Container expiration policies will be enabled by default
on new projects. This also updates the default older_than
value to 90d from 30d.
parent 8a384e0b
...@@ -20,7 +20,7 @@ module ContainerExpirationPoliciesHelper ...@@ -20,7 +20,7 @@ module ContainerExpirationPoliciesHelper
def older_than_options def older_than_options
ContainerExpirationPolicy.older_than_options.map do |key, val| ContainerExpirationPolicy.older_than_options.map do |key, val|
{ key: key.to_s, label: val }.tap do |base| { key: key.to_s, label: val }.tap do |base|
base[:default] = true if key.to_s == '30d' base[:default] = true if key.to_s == '90d'
end end
end end
end end
......
---
title: Enable container expiration policies by default for new projects
merge_request: 28480
author:
type: changed
# frozen_string_literal: true
class EnableContainerExpirationPoliciesByDefault < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
with_lock_retries do
change_column_default :container_expiration_policies, :enabled, true
end
end
def down
with_lock_retries do
change_column_default :container_expiration_policies, :enabled, false
end
end
end
...@@ -1842,7 +1842,7 @@ CREATE TABLE public.container_expiration_policies ( ...@@ -1842,7 +1842,7 @@ CREATE TABLE public.container_expiration_policies (
cadence character varying(12) DEFAULT '7d'::character varying NOT NULL, cadence character varying(12) DEFAULT '7d'::character varying NOT NULL,
older_than character varying(12), older_than character varying(12),
keep_n integer, keep_n integer,
enabled boolean DEFAULT false NOT NULL enabled boolean DEFAULT true NOT NULL
); );
CREATE TABLE public.container_repositories ( CREATE TABLE public.container_repositories (
...@@ -12926,5 +12926,6 @@ COPY "schema_migrations" (version) FROM STDIN; ...@@ -12926,5 +12926,6 @@ COPY "schema_migrations" (version) FROM STDIN;
20200326145443 20200326145443
20200330074719 20200330074719
20200330132913 20200330132913
20200331220930
\. \.
...@@ -26,7 +26,6 @@ describe 'Project > Settings > CI/CD > Container registry tag expiration policy' ...@@ -26,7 +26,6 @@ describe 'Project > Settings > CI/CD > Container registry tag expiration policy'
it 'saves expiration policy submit the form' do it 'saves expiration policy submit the form' do
within '#js-registry-policies' do within '#js-registry-policies' do
within '.card-body' do within '.card-body' do
find('.gl-toggle-wrapper button:not(.is-disabled)').click
select('7 days until tags are automatically removed', from: 'Expiration interval:') select('7 days until tags are automatically removed', from: 'Expiration interval:')
select('Every day', from: 'Expiration schedule:') select('Every day', from: 'Expiration schedule:')
select('50 tags per image name', from: 'Number of tags to retain:') select('50 tags per image name', from: 'Number of tags to retain:')
......
...@@ -37,8 +37,8 @@ describe ContainerExpirationPoliciesHelper do ...@@ -37,8 +37,8 @@ describe ContainerExpirationPoliciesHelper do
expected_result = [ expected_result = [
{ key: '7d', label: '7 days until tags are automatically removed' }, { key: '7d', label: '7 days until tags are automatically removed' },
{ key: '14d', label: '14 days until tags are automatically removed' }, { key: '14d', label: '14 days until tags are automatically removed' },
{ key: '30d', label: '30 days until tags are automatically removed', default: true }, { key: '30d', label: '30 days until tags are automatically removed' },
{ key: '90d', label: '90 days until tags are automatically removed' } { key: '90d', label: '90 days until tags are automatically removed', default: true }
] ]
expect(helper.older_than_options).to eq(expected_result) expect(helper.older_than_options).to eq(expected_result)
......
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