From 2026aaa3f150806e9aedfeb6a90546b457b5bb75 Mon Sep 17 00:00:00 2001 From: Jillian Inapurapu Date: Wed, 25 Oct 2023 14:15:52 -0700 Subject: [PATCH 1/3] Added noncurrent-transition-newer to lifecycleOptions validation Cleanup --- cmd/ilm/options.go | 5 ++--- go.mod | 5 +---- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/cmd/ilm/options.go b/cmd/ilm/options.go index 6a0fdab823..ef3bf2f155 100644 --- a/cmd/ilm/options.go +++ b/cmd/ilm/options.go @@ -159,7 +159,6 @@ func (opts LifecycleOptions) ToILMRule() (lifecycle.Rule, *probe.Error) { StorageClass: nonCurrentVersionTransitionStorageClass, }, } - if err := validateILMRule(newRule); err != nil { return lifecycle.Rule{}, err } @@ -254,8 +253,8 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) { if tier != nil && !ctx.IsSet("transition-days") && !ctx.IsSet("transition-date") { return LifecycleOptions{}, probe.NewError(errors.New("transition-date or transition-days must be set")) } - if noncurrentTier != nil && !ctx.IsSet("noncurrentversion-transition-days") && !ctx.IsSet("noncurrent-transition-days") { - return LifecycleOptions{}, probe.NewError(errors.New("noncurrentversion-transition-days must be set")) + if noncurrentTier != nil && !ctx.IsSet("noncurrentversion-transition-days") && !ctx.IsSet("noncurrent-transition-days") && !ctx.IsSet("noncurrent-transition-newer") { + return LifecycleOptions{}, probe.NewError(errors.New("noncurrentversion-transition-days must be set or noncurrent version count must be set")) } // for MinIO transition storage-class is same as label defined on // `mc admin bucket remote add --service ilm --label` command diff --git a/go.mod b/go.mod index 1f62bbfaab..312de58800 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( gopkg.in/h2non/filetype.v1 v1.0.5 gopkg.in/yaml.v2 v2.4.0 ) - +replace github.com/minio/minio-go/v7 => /Users/jillii/minio-go require ( github.com/charmbracelet/bubbles v0.16.1 github.com/charmbracelet/lipgloss v0.8.0 @@ -53,14 +53,11 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/prometheus/client_model v0.4.0 github.com/rivo/tview v0.0.0-20230909130259-ba6a2a345459 - github.com/vbauerster/mpb/v8 v8.6.2 golang.org/x/term v0.13.0 ) require ( aead.dev/minisign v0.2.0 // indirect - github.com/VividCortex/ewma v1.2.0 // indirect - github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/minio/mux v1.9.0 // indirect From 8ad6597715772b54c434bdc04828b78440b11c72 Mon Sep 17 00:00:00 2001 From: Jillian Inapurapu Date: Wed, 25 Oct 2023 14:36:10 -0700 Subject: [PATCH 2/3] Replaced go.mod --- go.mod | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 312de58800..1f62bbfaab 100644 --- a/go.mod +++ b/go.mod @@ -39,7 +39,7 @@ require ( gopkg.in/h2non/filetype.v1 v1.0.5 gopkg.in/yaml.v2 v2.4.0 ) -replace github.com/minio/minio-go/v7 => /Users/jillii/minio-go + require ( github.com/charmbracelet/bubbles v0.16.1 github.com/charmbracelet/lipgloss v0.8.0 @@ -53,11 +53,14 @@ require ( github.com/olekukonko/tablewriter v0.0.5 github.com/prometheus/client_model v0.4.0 github.com/rivo/tview v0.0.0-20230909130259-ba6a2a345459 + github.com/vbauerster/mpb/v8 v8.6.2 golang.org/x/term v0.13.0 ) require ( aead.dev/minisign v0.2.0 // indirect + github.com/VividCortex/ewma v1.2.0 // indirect + github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect github.com/kr/pretty v0.3.1 // indirect github.com/minio/mux v1.9.0 // indirect From b39a492b8d1beb5655979164c5e7792a8b3a1714 Mon Sep 17 00:00:00 2001 From: Jillian Inapurapu Date: Thu, 26 Oct 2023 14:19:07 -0700 Subject: [PATCH 3/3] Remove noncurrentversion-transition-days, improve error wording for clarity --- cmd/ilm/options.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/ilm/options.go b/cmd/ilm/options.go index ef3bf2f155..49aa0a90fa 100644 --- a/cmd/ilm/options.go +++ b/cmd/ilm/options.go @@ -253,8 +253,8 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) { if tier != nil && !ctx.IsSet("transition-days") && !ctx.IsSet("transition-date") { return LifecycleOptions{}, probe.NewError(errors.New("transition-date or transition-days must be set")) } - if noncurrentTier != nil && !ctx.IsSet("noncurrentversion-transition-days") && !ctx.IsSet("noncurrent-transition-days") && !ctx.IsSet("noncurrent-transition-newer") { - return LifecycleOptions{}, probe.NewError(errors.New("noncurrentversion-transition-days must be set or noncurrent version count must be set")) + if noncurrentTier != nil && !ctx.IsSet("noncurrent-transition-days") && !ctx.IsSet("noncurrent-transition-newer") { + return LifecycleOptions{}, probe.NewError(errors.New("noncurrent-transition-days or noncurrent-transition-newer must be set")) } // for MinIO transition storage-class is same as label defined on // `mc admin bucket remote add --service ilm --label` command @@ -299,9 +299,6 @@ func GetLifecycleOptions(ctx *cli.Context) (LifecycleOptions, *probe.Error) { if f := "noncurrent-expire-newer"; ctx.IsSet(f) { newerNoncurrentExpirationVersions = intPtr(ctx.Int(f)) } - if ctx.IsSet("noncurrentversion-transition-days") { - noncurrentVersionTransitionDays = intPtr(ctx.Int("noncurrentversion-transition-days")) - } if f := "noncurrent-transition-days"; ctx.IsSet(f) { noncurrentVersionTransitionDays = intPtr(ctx.Int(f)) }