S3Mock icon indicating copy to clipboard operation
S3Mock copied to clipboard

bucket lifecycle configuration is not supported

Open jerry-cherry opened this issue 4 years ago • 4 comments

Bucket lifecycle configuration doesn't seem to be supported with the version 2.1.28. would it be possible to support it? This is the code snippet:

var lifeCycleConfig = s3Client.getBucketLifecycleConfiguration(bucketName);
lifeCycleConfig.getRules().add(new BucketLifecycleConfiguration.Rule()
    .withId("myRule")
    .withFilter(new LifecycleFilter(new LifecycleAndOperator(List.of(
        new LifecyclePrefixPredicate("myFolder/"),
        new LifecycleTagPredicate(new Tag("myKey", "myValue"))))))
    .addTransition(new Transition().withDays(0).withStorageClass(StorageClass.Glacier))
    .withStatus(BucketLifecycleConfiguration.ENABLED));
s3Client.setBucketLifecycleConfiguration(bucketName, lifeCycleConfig);
var updated = s3Client.getBucketLifecycleConfiguration(bucketName);
assertEquals(lifeCycleConfig , updated)

jerry-cherry avatar Oct 20 '21 18:10 jerry-cherry

Hi, any plan for this?

jerry-cherry avatar Aug 03 '22 21:08 jerry-cherry

Thanks for the bump. Yes, I am planning on implementing this, my main impediment is that I will have to refactor the S3Mock quite a bit to store this and other information with the bucket and objects (this is not the only API still to be implemented).

For people using the S3Mock directly in Java code / Unit tests, every public method and class could be in use. This makes refactorings hard, I will have to break quite a few things to get everything implemented. See also #418 for an explanation RE: refactorings.

The first implementation step here would be that the S3Mock API accepts, stores and returns the LifeCycleConfig for a bucket. Not sure if it makes sense to implement actions on objects like changing the storage class in your example.

afranken avatar Aug 10 '22 15:08 afranken

Thanks for explanation @afranken. For us, saving and retrieving the lifecycle configuration is necessary at this moment. Actions to objects might be good to have, but not required.

jerry-cherry avatar Aug 10 '22 15:08 jerry-cherry

A bit of good news: I refactored almost all of the S3Mock core in version 2.5.0, so it is now possible to store BucketLifeCycle and other information (LegalHold, ...) in the updated data structures. Not sure when I'll get around to this, but it should be soon-ish. Been looking at Object ACLs, LegalHold, Retention first since those requests are older than this one.

Thanks for your patience.

afranken avatar Sep 03 '22 11:09 afranken

Thanks a lot @afranken

jerry-cherry avatar Sep 30 '22 14:09 jerry-cherry

@jerry-cherry just released 2.8.0 containing this feature.

afranken avatar Sep 30 '22 16:09 afranken