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

remove supportedLifecycleRules from constants #2275

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 0 additions & 7 deletions lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,6 @@ export const notificationArnPrefix = 'arn:scality:bucketnotif';
// http.Agent.
export const httpServerKeepAliveTimeout = 60000;
export const httpClientFreeSocketTimeout = 55000;
export const supportedLifecycleRules = [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition',
];
// Maximum number of buckets to cache (bucket metadata)
export const maxCachedBuckets = process.env.METADATA_MAX_CACHED_BUCKETS ?
Number(process.env.METADATA_MAX_CACHED_BUCKETS) : 1000;
Expand Down
9 changes: 3 additions & 6 deletions lib/s3middleware/lifecycleHelpers/LifecycleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import assert from 'assert';

import LifecycleDateTime from './LifecycleDateTime';
import { supportedLifecycleRules } from '../../constants';

export default class LifecycleUtils {
_supportedRules: string[];
_datetime: LifecycleDateTime;

constructor(supportedRules?: string[], datetime?: LifecycleDateTime) {
if (supportedRules) {
assert(Array.isArray(supportedRules));
}
constructor(supportedRules: string[], datetime?: LifecycleDateTime) {
assert(Array.isArray(supportedRules));

if (datetime) {
assert(datetime instanceof LifecycleDateTime);
}

this._supportedRules = supportedRules || supportedLifecycleRules;
this._supportedRules = supportedRules;
this._datetime = datetime || new LifecycleDateTime();
}

Expand Down
37 changes: 24 additions & 13 deletions tests/unit/s3middleware/LifecycleUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,29 @@ function getRuleIDs(rules) {
return rules.map(rule => rule.ID).sort();
}

const supportedLifecycleRules = [
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition',
];

describe('LifecycleUtils::constructor', () => {
it('should throw when not given supported lifecycle rules', () => {
assert.throws(() => new LifecycleUtils());
});

it('should throw when supported lifecycle rules is not an array', () => {
assert.throws(() => new LifecycleUtils('rules'));
});
});

describe('LifecycleUtils::getApplicableRules', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils([
'expiration',
'noncurrentVersionExpiration',
'abortIncompleteMultipartUpload',
'transitions',
'noncurrentVersionTransition',
]);
lutils = new LifecycleUtils(supportedLifecycleRules);
});

it('should return earliest applicable expirations', () => {
Expand Down Expand Up @@ -708,12 +720,11 @@ describe('LifecycleUtils::getApplicableRules', () => {
});
});


describe('LifecycleUtils::filterRules', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils();
lutils = new LifecycleUtils(supportedLifecycleRules);
});

it('should filter out Status disabled rules', () => {
Expand Down Expand Up @@ -898,7 +909,7 @@ describe('LifecycleUtils::getApplicableTransition', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils();
lutils = new LifecycleUtils(supportedLifecycleRules);
});

describe('using Days time type', () => {
Expand Down Expand Up @@ -1071,7 +1082,7 @@ describe('LifecycleUtils::getApplicableNCVTransition', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils();
lutils = new LifecycleUtils(supportedLifecycleRules);
});

describe('using NoncurrentDays time type', () => {
Expand Down Expand Up @@ -1175,7 +1186,7 @@ describe('LifecycleUtils::compareTransitions', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils();
lutils = new LifecycleUtils(supportedLifecycleRules);
});

it('should return undefined if no rules given', () => {
Expand Down Expand Up @@ -1274,7 +1285,7 @@ describe('LifecycleUtils::getApplicableNCVTransition', () => {
let lutils;

beforeAll(() => {
lutils = new LifecycleUtils();
lutils = new LifecycleUtils(supportedLifecycleRules);
});

describe('using NoncurrentDays time type', () => {
Expand Down
Loading