From c5e0003b5923654b755051c49763b1a7eebef15e Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Mon, 10 Feb 2025 11:24:59 +0100 Subject: [PATCH] silence "cscli hub update" if noop in cron jobs (#3460) --- pkg/cwhub/hub.go | 4 +++- test/bats/20_hub.bats | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/cwhub/hub.go b/pkg/cwhub/hub.go index aeccb3268f7..2d432df67c3 100644 --- a/pkg/cwhub/hub.go +++ b/pkg/cwhub/hub.go @@ -165,7 +165,9 @@ func (h *Hub) Update(ctx context.Context, indexProvider IndexProvider, withConte } if !downloaded { - fmt.Println("Nothing to do, the hub index is up to date.") + // use logger and the message will be silenced in the cron job + // (no mail if nothing happened) + h.logger.Info("Nothing to do, the hub index is up to date.") } return nil diff --git a/test/bats/20_hub.bats b/test/bats/20_hub.bats index b03b58732fa..07b8be626df 100644 --- a/test/bats/20_hub.bats +++ b/test/bats/20_hub.bats @@ -109,7 +109,8 @@ teardown() { rune -0 cscli hub update assert_output "Downloading $INDEX_PATH" rune -0 cscli hub update - assert_output "Nothing to do, the hub index is up to date." + refute_output + assert_stderr 'level=info msg="Nothing to do, the hub index is up to date."' } @test "cscli hub upgrade (up to date)" {