From 76dec5a2b7efe241c476e06c5e3d8116f6aac778 Mon Sep 17 00:00:00 2001 From: r-vasquez Date: Tue, 29 Oct 2024 09:33:48 -0700 Subject: [PATCH] rpk: change expiry check for free_trial If it's a free trial license the expiry warning check threshold will be set to 15days instead of 30 for the rest of license types. Fixes DEVEX-36 --- src/go/rpk/pkg/cli/cluster/license/info.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/go/rpk/pkg/cli/cluster/license/info.go b/src/go/rpk/pkg/cli/cluster/license/info.go index 6aa58f7693ff2..be69b4fa489ba 100644 --- a/src/go/rpk/pkg/cli/cluster/license/info.go +++ b/src/go/rpk/pkg/cli/cluster/license/info.go @@ -3,6 +3,7 @@ package license import ( "fmt" "os" + "strings" "time" "github.com/redpanda-data/common-go/rpadmin" @@ -133,17 +134,21 @@ func printTextLicenseInfo(resp infoResponse) { if *resp.Expired { tw.Print("License expired:", *resp.Expired) } - checkLicenseExpiry(resp.ExpiresUnix) + checkLicenseExpiry(resp.ExpiresUnix, resp.Type) } out.Section("LICENSE INFORMATION") tw.Flush() } -func checkLicenseExpiry(expiresUnix int64) { +func checkLicenseExpiry(expiresUnix int64, licenseType string) { ut := time.Unix(expiresUnix, 0) daysLeft := int(time.Until(ut).Hours() / 24) - if daysLeft < 30 && !ut.Before(time.Now()) { + dayThreshold := 30 + if strings.EqualFold(licenseType, "free_trial") { + dayThreshold = 15 + } + if daysLeft < dayThreshold && !ut.Before(time.Now()) { fmt.Fprintf(os.Stderr, "WARNING: your license will expire soon.\n\n") } }