Skip to content

Commit

Permalink
remove supportedLifecycleRules from constants
Browse files Browse the repository at this point in the history
supportedLifecycleRules' value is different between the 7.x and 8.x
branches. We should define the rules directly in the config of the
Zenko components.

Issue: ARSN-435
  • Loading branch information
Kerkesni committed Dec 11, 2024
1 parent fed5807 commit 6b86467
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 15 deletions.
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
5 changes: 2 additions & 3 deletions lib/s3middleware/lifecycleHelpers/LifecycleUtils.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
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) {
constructor(supportedRules: string[], datetime?: LifecycleDateTime) {
if (supportedRules) {
assert(Array.isArray(supportedRules));
}
Expand All @@ -16,7 +15,7 @@ export default class LifecycleUtils {
assert(datetime instanceof LifecycleDateTime);
}

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

Expand Down
40 changes: 35 additions & 5 deletions tests/unit/s3middleware/LifecycleUtils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,13 @@ describe('LifecycleUtils::filterRules', () => {
let lutils;

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

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

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

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

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

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

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

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

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

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

0 comments on commit 6b86467

Please sign in to comment.