Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/development/8.2' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
benzekrimaha committed Nov 19, 2024
2 parents c175969 + fed5807 commit 9b1ec5d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
41 changes: 22 additions & 19 deletions lib/models/ObjectMD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ export type ReplicationInfo = {
role: string;
storageType: string;
dataStoreVersionId: string;
isNFS: boolean | null;
isNFS?: boolean;
};

export type ObjectMDData = {
'owner-display-name': string;
'owner-id': string;
'cache-control': string;
'content-disposition': string;
'content-language': string;
'content-language'?: string;
'content-encoding': string;
'creation-time'?: string;
'last-modified'?: string;
Expand Down Expand Up @@ -84,12 +84,12 @@ export type ObjectMDData = {
// Used for keeping object metadata in the oplog event
// In case of a deletion the flag is first updated before
// deleting the object
deleted: boolean;
deleted?: boolean;
// PHD flag indicates whether the object is a temporary placeholder.
// This is the case when the latest version of an object gets deleted
// the master is set as a placeholder and gets updated with the new latest
// version data after a certain amount of time.
isPHD: boolean;
isPHD?: boolean;
};

/**
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class ObjectMD {
'content-length': 0,
'content-type': '',
'content-md5': '',
'content-language': '',
'content-language': undefined,
'creation-time': undefined,
// simple/no version. will expand once object versioning is
// introduced
Expand All @@ -197,8 +197,8 @@ export default class ObjectMD {
'x-amz-server-side-encryption-aws-kms-key-id': '',
'x-amz-server-side-encryption-customer-algorithm': '',
'x-amz-website-redirect-location': '',
'x-amz-scal-transition-in-progress': false,
'acl': {
'x-amz-scal-transition-in-progress': undefined,
acl: {

Check failure on line 201 in lib/models/ObjectMD.ts

View workflow job for this annotation

GitHub Actions / test

Inconsistently quoted property 'acl' found
Canned: 'private',
FULL_CONTROL: [],
WRITE_ACP: [],
Expand Down Expand Up @@ -227,12 +227,12 @@ export default class ObjectMD {
role: '',
storageType: '',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
},
'dataStoreName': '',
'originOp': '',
'deleted': false,
'isPHD': false,
dataStoreName: '',

Check failure on line 232 in lib/models/ObjectMD.ts

View workflow job for this annotation

GitHub Actions / test

Inconsistently quoted property 'dataStoreName' found
originOp: '',

Check failure on line 233 in lib/models/ObjectMD.ts

View workflow job for this annotation

GitHub Actions / test

Inconsistently quoted property 'originOp' found
deleted: undefined,

Check failure on line 234 in lib/models/ObjectMD.ts

View workflow job for this annotation

GitHub Actions / test

Inconsistently quoted property 'deleted' found
isPHD: undefined,

Check failure on line 235 in lib/models/ObjectMD.ts

View workflow job for this annotation

GitHub Actions / test

Inconsistently quoted property 'isPHD' found
};
}

Expand All @@ -250,7 +250,10 @@ export default class ObjectMD {
// objMd is a new JS object created for the purpose, it's safe
// to just assign its top-level properties.

Object.assign(this._data, objMd);
const { replicationInfo, ...md } = objMd as ObjectMDData;
Object.assign(this._data, md);
// keep default values inside replicationInfo
Object.assign(this._data.replicationInfo, replicationInfo);
this._convertToLatestModel();
}

Expand Down Expand Up @@ -479,7 +482,7 @@ export default class ObjectMD {
* @return content-language
*/
getContentLanguage() {
return this._data['content-language'];
return this._data['content-language'] || '';
}

/**
Expand Down Expand Up @@ -677,7 +680,7 @@ export default class ObjectMD {
* @return True if transition is in progress, false otherwise
*/
getTransitionInProgress() {
return this._data['x-amz-scal-transition-in-progress'];
return !!this._data['x-amz-scal-transition-in-progress'];
}

/**
Expand Down Expand Up @@ -1065,7 +1068,7 @@ export default class ObjectMD {
role,
storageType: storageType || '',
dataStoreVersionId: dataStoreVersionId || '',
isNFS: isNFS || null,
isNFS,
};
return this;
}
Expand Down Expand Up @@ -1099,7 +1102,7 @@ export default class ObjectMD {
* @return Whether replication from an NFS bucket
*/
getReplicationIsNFS() {
return this._data.replicationInfo.isNFS;
return !!this._data.replicationInfo.isNFS;
}

setReplicationSiteStatus(site: string, status: string) {
Expand Down Expand Up @@ -1461,7 +1464,7 @@ export default class ObjectMD {
* @return {Boolean}
*/
getDeleted() {
return this._data.deleted;
return !!this._data.deleted;
}

/**
Expand All @@ -1479,6 +1482,6 @@ export default class ObjectMD {
* @return {Boolean}
*/
getIsPHD() {
return this._data.isPHD;
return !!this._data.isPHD;
}
}
5 changes: 4 additions & 1 deletion lib/policyEvaluator/utils/actionMaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const actionMonitoringMapS3 = {
serviceGet: 'ListBuckets',
bucketGetQuota: 'GetBucketQuota',
bucketUpdateQuota: 'UpdateBucketQuota',
bucketDeleteQuota: 'DeleteBucketQuota',
bucketDeleteQuota: 'DeleteBucketQuota',
};

const actionMapAccountQuotas = {
Expand Down Expand Up @@ -233,6 +233,9 @@ const actionMapScuba = {
AdminStopIngest: 'scuba:AdminStopIngest',
AdminReadRaftCseq: 'scuba:AdminReadRaftCseq',
AdminTriggerRepair: 'scuba:AdminTriggerRepair',
AdminStartDownsample: 'scuba:AdminStartDownsample',
AdminStopDownsample: 'scuba:AdminStopDownsample',
AdminTriggerDownsample: 'scuba:AdminTriggerDownsample',
};

export {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/models/ObjectMD.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('ObjectMD class setters/getters', () => {
role: '',
storageType: '',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
}],
['ReplicationInfo', {
status: 'PENDING',
Expand All @@ -114,10 +114,10 @@ describe('ObjectMD class setters/getters', () => {
'arn:aws:iam::account-id:role/dest-resource',
storageType: 'aws_s3',
dataStoreVersionId: '',
isNFS: null,
isNFS: undefined,
}],
['DataStoreName', null, ''],
['ReplicationIsNFS', null, null],
['ReplicationIsNFS', null, false],
['ReplicationIsNFS', true],
['AzureInfo', {
containerPublicAccess: 'container',
Expand Down

0 comments on commit 9b1ec5d

Please sign in to comment.