Skip to content

Commit

Permalink
rpk: check for empty profiles in license check.
Browse files Browse the repository at this point in the history
This is to avoid a panic in the edge case when the
user has a nameless profile (corrupted file)
  • Loading branch information
r-vasquez committed Oct 17, 2024
1 parent df9943e commit 44dfa80
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/go/rpk/pkg/adminapi/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ func licenseFeatureChecks(ctx context.Context, fs afero.Fs, cl *rpadmin.AdminAPI
}
if exists && y != nil {
actProfile := y.Profile(p.Name)
actProfile.LicenseCheck = licenseCheck
if err := y.Write(fs); err != nil {
zap.L().Sugar().Warnf("unable to save licensed enterprise features check cache to profile: %v", err)
if actProfile != nil {
actProfile.LicenseCheck = licenseCheck
if err := y.Write(fs); err != nil {
zap.L().Sugar().Warnf("unable to save licensed enterprise features check cache to profile: %v", err)
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion src/go/rpk/pkg/cli/cluster/license/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ func printTextLicenseInfo(resp infoResponse) {
if *resp.Expired {
tw.Print("License expired:", *resp.Expired)
}
// need to defer as we flush the table below.
checkLicenseExpiry(resp.ExpiresUnix)
}
out.Section("LICENSE INFORMATION")
Expand Down

0 comments on commit 44dfa80

Please sign in to comment.