diff --git a/MODULE.bazel b/MODULE.bazel index 2182c2708b5e6..efa1f7724b474 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -190,6 +190,7 @@ use_repo( "com_github_hashicorp_go_multierror", "com_github_kballard_go_shellquote", "com_github_kr_pretty", + "com_github_kr_text", "com_github_lestrrat_go_jwx", "com_github_linkedin_goavro_v2", "com_github_lorenzosaino_go_sysctl", diff --git a/src/go/rpk/go.mod b/src/go/rpk/go.mod index 2919b0e1836da..23a7c9d510d61 100644 --- a/src/go/rpk/go.mod +++ b/src/go/rpk/go.mod @@ -26,6 +26,7 @@ require ( github.com/hamba/avro/v2 v2.25.2 github.com/hashicorp/go-multierror v1.1.1 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 + github.com/kr/text v0.2.0 github.com/lestrrat-go/jwx v1.2.30 github.com/linkedin/goavro/v2 v2.13.0 github.com/lorenzosaino/go-sysctl v0.3.1 diff --git a/src/go/rpk/go.sum b/src/go/rpk/go.sum index 0eb79316a5340..a2c0e4d575f31 100644 --- a/src/go/rpk/go.sum +++ b/src/go/rpk/go.sum @@ -43,6 +43,7 @@ github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3 github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY= github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= diff --git a/src/go/rpk/pkg/adminapi/BUILD b/src/go/rpk/pkg/adminapi/BUILD index c867e56f0d40b..1e9be30a56996 100644 --- a/src/go/rpk/pkg/adminapi/BUILD +++ b/src/go/rpk/pkg/adminapi/BUILD @@ -9,6 +9,8 @@ go_library( "//src/go/rpk/pkg/config", "//src/go/rpk/pkg/oauth", "//src/go/rpk/pkg/oauth/providers/auth0", + "@com_github_kr_text//:text", + "@com_github_moby_term//:term", "@com_github_redpanda_data_common_go_rpadmin//:rpadmin", "@com_github_spf13_afero//:afero", "@org_uber_go_zap//:zap", diff --git a/src/go/rpk/pkg/adminapi/admin.go b/src/go/rpk/pkg/adminapi/admin.go index 10273efd190c2..969e690f24802 100644 --- a/src/go/rpk/pkg/adminapi/admin.go +++ b/src/go/rpk/pkg/adminapi/admin.go @@ -19,6 +19,9 @@ import ( "strings" "time" + "github.com/kr/text" + mTerm "github.com/moby/term" + "go.uber.org/zap" "github.com/redpanda-data/common-go/rpadmin" @@ -178,6 +181,10 @@ func licenseFeatureChecks(ctx context.Context, fs afero.Fs, cl *rpadmin.AdminAPI } } } + if ws, err := mTerm.GetWinsize(0); err == nil { + // text.Wrap removes the newline from the text. We add it back. + msg = "\n" + text.Wrap(msg, int(ws.Width)) + "\n" + } return msg }