github.com/minio/minio@v0.0.0-20240328213742-3f72439b8a27/cmd/batch-expire_test.go (about) 1 // Copyright (c) 2015-2023 MinIO, Inc. 2 // 3 // This file is part of MinIO Object Storage stack 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU Affero General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // This program is distributed in the hope that it will be useful 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU Affero General Public License for more details. 14 // 15 // You should have received a copy of the GNU Affero General Public License 16 // along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 package cmd 19 20 import ( 21 "testing" 22 23 "gopkg.in/yaml.v2" 24 ) 25 26 func TestParseBatchJobExpire(t *testing.T) { 27 expireYaml := ` 28 expire: # Expire objects that match a condition 29 apiVersion: v1 30 bucket: mybucket # Bucket where this batch job will expire matching objects from 31 prefix: myprefix # (Optional) Prefix under which this job will expire objects matching the rules below. 32 rules: 33 - type: object # regular objects with zero or more older versions 34 name: NAME # match object names that satisfy the wildcard expression. 35 olderThan: 70h # match objects older than this value 36 createdBefore: "2006-01-02T15:04:05.00Z" # match objects created before "date" 37 tags: 38 - key: name 39 value: pick* # match objects with tag 'name', all values starting with 'pick' 40 metadata: 41 - key: content-type 42 value: image/* # match objects with 'content-type', all values starting with 'image/' 43 size: 44 lessThan: "10MiB" # match objects with size less than this value (e.g. 10MiB) 45 greaterThan: 1MiB # match objects with size greater than this value (e.g. 1MiB) 46 purge: 47 # retainVersions: 0 # (default) delete all versions of the object. This option is the fastest. 48 # retainVersions: 5 # keep the latest 5 versions of the object. 49 50 - type: deleted # objects with delete marker as their latest version 51 name: NAME # match object names that satisfy the wildcard expression. 52 olderThan: 10h # match objects older than this value (e.g. 7d10h31s) 53 createdBefore: "2006-01-02T15:04:05.00Z" # match objects created before "date" 54 purge: 55 # retainVersions: 0 # (default) delete all versions of the object. This option is the fastest. 56 # retainVersions: 5 # keep the latest 5 versions of the object including delete markers. 57 58 notify: 59 endpoint: https://notify.endpoint # notification endpoint to receive job completion status 60 token: Bearer xxxxx # optional authentication token for the notification endpoint 61 62 retry: 63 attempts: 10 # number of retries for the job before giving up 64 delay: 500ms # least amount of delay between each retry 65 ` 66 var job BatchJobRequest 67 err := yaml.UnmarshalStrict([]byte(expireYaml), &job) 68 if err != nil { 69 t.Fatal("Failed to parse batch-job-expire yaml", err) 70 } 71 }