From 420e0e14a94435e3e98ba10432d1227cdbb27eda Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Tue, 13 Jan 2026 17:52:19 -0800 Subject: [PATCH] Suppress messages on needs-renewal commands This commit suppresses the message "certificate does not need renewal" on the `step certificate needs-renewal` and `step ssh needs-renewal` unless the `--verbose` flag is passed. --- CHANGELOG.md | 9 +++++++++ command/certificate/needsRenewal.go | 10 ++++++++-- command/ssh/needsRenewal.go | 8 +++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17f6350de..53b19dadc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. --- +## [x.y.z] - TBD + +### Changed + +- Suppress output messages for `step certificate needs-renewal` and `step ssh + needs-renewal` commands when certificates don't need renewal. Use the + `--verbose` flag to always show messages regardless of renewal status + (smallstep/cli#1548). + ## [0.29.0] - 2025-12-02 ### Added diff --git a/command/certificate/needsRenewal.go b/command/certificate/needsRenewal.go index 399ef0c32..d82afd2dc 100644 --- a/command/certificate/needsRenewal.go +++ b/command/certificate/needsRenewal.go @@ -60,7 +60,7 @@ $ step certificate needs-renewal ./certificate.crt --bundle ''' Check if the leaf certificate provided by smallstep.com has passed 66 percent -of its vlaidity period: +of its validity period: ''' $ step certificate needs-renewal https://smallstep.com ''' @@ -234,5 +234,11 @@ func isVerboseExit(needsRenewal, isVerbose bool) error { } return nil } - return errs.NewExitError(errors.Errorf("certificate does not need renewal"), 1) + + if isVerbose { + return errs.NewExitError(errors.Errorf("certificate does not need renewal"), 1) + } + + // urfave/cli won't show any message + return cli.NewExitError("", 1) } diff --git a/command/ssh/needsRenewal.go b/command/ssh/needsRenewal.go index 4145e9ab0..539f5ae4a 100644 --- a/command/ssh/needsRenewal.go +++ b/command/ssh/needsRenewal.go @@ -172,5 +172,11 @@ func isVerboseExit(needsRenewal, isVerbose bool) error { } return nil } - return errs.NewExitError(errors.Errorf("certificate does not need renewal"), 1) + + if isVerbose { + return errs.NewExitError(errors.Errorf("certificate does not need renewal"), 1) + } + + // urfave/cli won't show any message + return cli.NewExitError("", 1) }