Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable --expire-all-object-versions #4840

Merged
merged 6 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/ilm-rule-add.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ var ilmAddFlags = []cli.Flag{
Name: "noncurrent-transition-tier",
Usage: "remote tier name to transition",
},
cli.BoolFlag{
Name: "expire-all-object-versions",
Usage: "expire all object versions",
},
}

type ilmAddMessage struct {
Expand Down
10 changes: 9 additions & 1 deletion cmd/ilm/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type LifecycleOptions struct {
NoncurrentVersionTransitionDays *int
NewerNoncurrentTransitionVersions *int
NoncurrentVersionTransitionStorageClass *string
ExpiredObjectAllversions *bool
}

// Filter returns lifecycle.Filter appropriate for opts
Expand Down Expand Up @@ -149,7 +150,7 @@ func (opts LifecycleOptions) ToILMRule() (lifecycle.Rule, *probe.Error) {
return "Enabled"
}()

expiry, err := parseExpiry(opts.ExpiryDate, opts.ExpiryDays, opts.ExpiredObjectDeleteMarker)
expiry, err := parseExpiry(opts.ExpiryDate, opts.ExpiryDays, opts.ExpiredObjectDeleteMarker, opts.ExpiredObjectAllversions)
if err != nil {
return lifecycle.Rule{}, err
}
Expand Down Expand Up @@ -241,6 +242,7 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) {
noncurrentVersionTransitionDays *int
newerNoncurrentTransitionVersions *int
noncurrentTier *string
expiredObjectAllversions *bool
)

id = ctx.String("id")
Expand Down Expand Up @@ -368,6 +370,9 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) {
if f := "noncurrent-transition-newer"; ctx.IsSet(f) {
newerNoncurrentTransitionVersions = intPtr(ctx.Int(f))
}
if ctx.IsSet("expire-all-object-versions") {
expiredObjectAllversions = boolPtr(ctx.Bool("expire-all-object-versions"))
}

return LifecycleOptions{
ID: id,
Expand All @@ -387,6 +392,7 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) {
NoncurrentVersionTransitionDays: noncurrentVersionTransitionDays,
NewerNoncurrentTransitionVersions: newerNoncurrentTransitionVersions,
NoncurrentVersionTransitionStorageClass: noncurrentTier,
ExpiredObjectAllversions: expiredObjectAllversions,
}, nil
}

Expand Down Expand Up @@ -429,6 +435,8 @@ func ApplyRuleFields(dest *lifecycle.Rule, opts LifecycleOptions) *probe.Error {
dest.Expiration.DeleteMarker = lifecycle.ExpireDeleteMarker(*opts.ExpiredObjectDeleteMarker)
dest.Expiration.Days = 0
dest.Expiration.Date = lifecycle.ExpirationDate{}
} else if opts.ExpiredObjectAllversions != nil {
dest.Expiration.DeleteAll = lifecycle.ExpirationBoolean(*opts.ExpiredObjectAllversions)
}

if opts.TransitionDate != nil {
Expand Down
6 changes: 5 additions & 1 deletion cmd/ilm/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func parseExpiryDays(expiryDayStr string) (lifecycle.ExpirationDays, *probe.Erro
}

// Returns lifecycleExpiration to be included in lifecycleRule
func parseExpiry(expiryDate, expiryDays *string, expiredDeleteMarker *bool) (lfcExp lifecycle.Expiration, err *probe.Error) {
func parseExpiry(expiryDate, expiryDays *string, expiredDeleteMarker, expiredObjectAllVersions *bool) (lfcExp lifecycle.Expiration, err *probe.Error) {
if expiryDate != nil {
date, err := parseExpiryDate(*expiryDate)
if err != nil {
Expand All @@ -263,5 +263,9 @@ func parseExpiry(expiryDate, expiryDays *string, expiredDeleteMarker *bool) (lfc
lfcExp.DeleteMarker = lifecycle.ExpireDeleteMarker(*expiredDeleteMarker)
}

if expiredObjectAllVersions != nil {
lfcExp.DeleteAll = lifecycle.ExpirationBoolean(*expiredObjectAllVersions)
}

return lfcExp, nil
}
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ require (
github.com/minio/colorjson v1.0.6
github.com/minio/filepath v1.0.0
github.com/minio/md5-simd v1.1.2 // indirect
github.com/minio/minio-go/v7 v7.0.66
github.com/minio/minio-go/v7 v7.0.67
github.com/minio/selfupdate v0.6.0
github.com/minio/sha256-simd v1.0.1
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/xattr v0.4.9
github.com/posener/complete v1.2.3
github.com/prometheus/client_golang v1.17.0
github.com/prometheus/prom2json v1.3.3
github.com/prometheus/prom2json v1.3.3 // indirect
github.com/rjeczalik/notify v0.9.3
github.com/rs/xid v1.5.0
github.com/shirou/gopsutil/v3 v3.23.11
Expand All @@ -51,7 +51,6 @@ require (
github.com/muesli/reflow v0.3.0
github.com/navidys/tvxwidgets v0.4.1
github.com/olekukonko/tablewriter v0.0.5
github.com/prometheus/client_model v0.5.0
github.com/rivo/tview v0.0.0-20231206124440-5f078138442e
github.com/vbauerster/mpb/v8 v8.7.1
golang.org/x/term v0.15.0
Expand All @@ -65,6 +64,7 @@ require (
github.com/kr/pretty v0.3.1 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/minio/mux v1.9.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/safchain/ethtool v0.3.0 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ github.com/minio/madmin-go/v3 v3.0.41 h1:9pU7xW51cn8Ixy8ftaRfp4SbHtnhEPlwU6mMA9K
github.com/minio/madmin-go/v3 v3.0.41/go.mod h1:4QN2NftLSV7MdlT50dkrenOMmNVHluxTvlqJou3hte8=
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
github.com/minio/minio-go/v7 v7.0.66 h1:bnTOXOHjOqv/gcMuiVbN9o2ngRItvqE774dG9nq0Dzw=
github.com/minio/minio-go/v7 v7.0.66/go.mod h1:DHAgmyQEGdW3Cif0UooKOyrT3Vxs82zNdV6tkKhRtbs=
github.com/minio/minio-go/v7 v7.0.67 h1:BeBvZWAS+kRJm1vGTMJYVjKUNoo0FoEt/wUWdUtfmh8=
github.com/minio/minio-go/v7 v7.0.67/go.mod h1:+UXocnUeZ3wHvVh5s95gcrA4YjMIbccT6ubB+1m054A=
github.com/minio/mux v1.9.0 h1:dWafQFyEfGhJvK6AwLOt83bIG5bxKxKJnKMCi0XAaoA=
github.com/minio/mux v1.9.0/go.mod h1:1pAare17ZRL5GpmNL+9YmqHoWnLmMZF9C/ioUCfy0BQ=
github.com/minio/pkg/v2 v2.0.7 h1:vJZ+XUTDeUe/cHpPZSyG/+54252dg6RQKU5K1jXfy/A=
Expand Down
Loading