Skip to content

Commit

Permalink
Allow to set verbose flag
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudlena committed Jun 9, 2023
1 parent 6c7787f commit 4b689f6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
1 change: 0 additions & 1 deletion internal/livelint/check_can_access_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ func (n *Livelint) canPortForward(pod apiv1.Pod, port int32, checkFunc func(uint
handleConnectionError := func(err error) {
connectionSuccessful = false
}
// nolint:reassign
runtime.ErrorHandlers = append(runtime.ErrorHandlers, handleConnectionError)

// prepare the port forwarding
Expand Down
3 changes: 1 addition & 2 deletions internal/livelint/checks_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func (m Model) View() string {
return doc.String()
}

// nolint:ireturn
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
Expand Down Expand Up @@ -224,7 +223,7 @@ type check struct {
outcome summaryMsg
}

func initalizeStatus(context string) statusMsg {
func initializeStatus(context string) statusMsg {
return statusMsg{context: context, checks: []check{}}
}

Expand Down
7 changes: 6 additions & 1 deletion internal/livelint/interaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type UserInteraction interface {
DisplayCheckCompletion(completionMsg string, kind SummaryType)
DisplayError(errorMsg error)
AskYesNo(question string) bool
SetVerbose()
StartSpinner()
StopSpinner()
}
Expand All @@ -37,7 +38,7 @@ func (ui *BubbleteaUI) AskYesNo(question string) bool {
}

func (ui *BubbleteaUI) DisplayContext(contextMsg string) {
ui.statusMsg = initalizeStatus(contextMsg)
ui.statusMsg = initializeStatus(contextMsg)
ui.Send(ui.statusMsg)
}

Expand All @@ -60,6 +61,10 @@ func (ui *BubbleteaUI) DisplayError(errorMsg error) {
ui.Send(errMsg{err: errorMsg})
}

func (ui *BubbleteaUI) SetVerbose() {
ui.Send(verboseMsg{verbose: true})
}

func (ui *BubbleteaUI) StartSpinner() {
ui.Send(showSpinnerMsg{showing: true})
}
Expand Down
37 changes: 37 additions & 0 deletions internal/livelint/mock_ui_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions internal/livelint/run_checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@ import (
)

// RunChecks checks for potential issues with a deployment.
func (n *Livelint) RunChecks(namespace, deploymentName string, isVerbose bool) error {
func (n *Livelint) RunChecks(namespace, deploymentName string, verbose bool) error {
if namespace == "" {
return fmt.Errorf("error running checks: %w", errNamespaceUndefined)
}
if deploymentName == "" {
return errDeploymentNameUndefined
}

// nolint:govet
n.ui.DisplayContext(fmt.Sprintf("Checking Deployment %q in Namespace %q", deploymentName, namespace))
if verbose {
n.ui.SetVerbose()
}

n.ui.DisplayCheckStart("Checking Pods")

allPods, err := n.getDeploymentPods(namespace, deploymentName)
Expand Down

0 comments on commit 4b689f6

Please sign in to comment.