From f5d04499b30c2df4001afc0b44ba796b414b3ed8 Mon Sep 17 00:00:00 2001 From: Andrew Wittrock Date: Thu, 14 Jul 2022 15:47:54 -0700 Subject: [PATCH] Refresh token in logs is disabled for Korifi - Configured with `Config.IsCFOnK8s` Co-authored-by: Clint Yoshimura --- command/v7/logs_command.go | 23 +++++++++++++---------- command/v7/logs_command_test.go | 10 ++++++++++ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/command/v7/logs_command.go b/command/v7/logs_command.go index b2506240752..fea41976cc3 100644 --- a/command/v7/logs_command.go +++ b/command/v7/logs_command.go @@ -58,20 +58,23 @@ func (cmd LogsCommand) Execute(args []string) error { return cmd.displayRecentLogs() } - stop := make(chan struct{}) - stoppedRefreshing := make(chan struct{}) - stoppedOutputtingRefreshErrors := make(chan struct{}) - err = cmd.refreshTokenPeriodically(stop, stoppedRefreshing, stoppedOutputtingRefreshErrors) - if err != nil { - return err + if !cmd.Config.IsCFOnK8s() { + stop := make(chan struct{}) + stoppedRefreshing := make(chan struct{}) + stoppedOutputtingRefreshErrors := make(chan struct{}) + err = cmd.refreshTokenPeriodically(stop, stoppedRefreshing, stoppedOutputtingRefreshErrors) + if err != nil { + return err + } + defer func() { + close(stop) + <-stoppedRefreshing + <-stoppedOutputtingRefreshErrors + }() } err = cmd.streamLogs() - close(stop) - <-stoppedRefreshing - <-stoppedOutputtingRefreshErrors - return err } diff --git a/command/v7/logs_command_test.go b/command/v7/logs_command_test.go index ea188379989..034257bb707 100644 --- a/command/v7/logs_command_test.go +++ b/command/v7/logs_command_test.go @@ -248,6 +248,16 @@ var _ = Describe("logs command", func() { }) }) + When("isCFOnK8s is true", func() { + BeforeEach(func() { + fakeConfig.IsCFOnK8sReturns(true) + }) + + It("does not call ScheduleTokenRefresh", func() { + Expect(fakeActor.ScheduleTokenRefreshCallCount()).To(Equal(0)) + }) + }) + It("displays the error and all warnings", func() { Expect(executeErr).NotTo(HaveOccurred()) Expect(testUI.Err).To(Say("steve for all I care"))