Skip to content

Commit c22984c

Browse files
feat: support OLM Prefix/Suffix (#1847)
* feat: support OLM Prefix/Suffix * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * updated to camel case * fix merge * fixed compile error * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * refactored tests * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * refactored tests * refactored tests Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 594e7da commit c22984c

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export interface AddLifecycleRuleOptions {
105105

106106
export interface LifecycleRule {
107107
action: {type: string; storageClass?: string} | string;
108-
condition: {[key: string]: boolean | Date | number | string};
108+
condition: {[key: string]: boolean | Date | number | string | string[]};
109109
storageClass?: string;
110110
}
111111

system-test/storage.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,44 @@ describe('storage', () => {
13971397
);
13981398
});
13991399

1400+
it('should add a prefix rule', async () => {
1401+
await bucket.addLifecycleRule({
1402+
action: 'delete',
1403+
condition: {
1404+
matchesPrefix: [TESTS_PREFIX],
1405+
},
1406+
});
1407+
1408+
assert(
1409+
bucket.metadata.lifecycle.rule.some(
1410+
(rule: LifecycleRule) =>
1411+
typeof rule.action === 'object' &&
1412+
rule.action.type === 'Delete' &&
1413+
typeof rule.condition.matchesPrefix === 'object' &&
1414+
(rule.condition.matchesPrefix as string[]).length === 1 &&
1415+
Array.isArray(rule.condition.matchesPrefix)
1416+
)
1417+
);
1418+
});
1419+
1420+
it('should add a suffix rule', async () => {
1421+
await bucket.addLifecycleRule({
1422+
action: 'delete',
1423+
condition: {
1424+
matchesSuffix: [TESTS_PREFIX, 'test_suffix'],
1425+
},
1426+
});
1427+
1428+
assert(
1429+
bucket.metadata.lifecycle.rule.some(
1430+
(rule: LifecycleRule) =>
1431+
typeof rule.action === 'object' &&
1432+
rule.action.type === 'Delete' &&
1433+
Array.isArray(rule.condition.matchesPrefix)
1434+
)
1435+
);
1436+
});
1437+
14001438
it('should convert a rule with createdBefore to a date in string', done => {
14011439
bucket.addLifecycleRule(
14021440
{

0 commit comments

Comments
 (0)