Skip to content

Commit

Permalink
feat: move logs
Browse files Browse the repository at this point in the history
  • Loading branch information
CristhianF7 committed Nov 14, 2024
1 parent 9091e53 commit eeeb475
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
16 changes: 16 additions & 0 deletions internal/progress/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func DisplayLogHints(estimatedTime int) {

headerMessage := renderMessage(header)

printLine(headerMessage)

Progress.Send(headerMsg{
message: headerMessage,
})
Expand Down Expand Up @@ -141,6 +143,8 @@ func DisplaySuccessMessage(cluster types.Cluster) successMsg {

successMessage := renderMessage(success)

printLine(successMessage)

return successMsg{
message: successMessage,
}
Expand All @@ -165,6 +169,8 @@ func DisplayCredentials(cluster types.Cluster) {

headerMessage := renderMessage(header)

printLine(headerMessage)

Progress.Send(headerMsg{
message: headerMessage,
})
Expand All @@ -178,13 +184,15 @@ func AddStep(message string) {
}

func CompleteStep(message string) {
printLine(message)
Progress.Send(completeStep{
message: message,
})
}

func Success(success string) {
successMessage := renderMessage(success)
printLine(successMessage)

Progress.Send(
successMsg{
Expand All @@ -193,6 +201,8 @@ func Success(success string) {
}

func Error(message string) {
printLine(message)

renderedMessage := createErrorLog(message)
Progress.Send(renderedMessage)
}
Expand All @@ -204,3 +214,9 @@ func StartProvisioning(clusterName string) {

Progress.Send(provisioningMessage)
}

func printLine(message string) {
if isCiExecution {
fmt.Println(message)
}
}
11 changes: 0 additions & 11 deletions internal/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}

case headerMsg:
printLine(msg.message)
m.header = msg.message
return m, nil

case addStep:
printLine(msg.message)
m.nextStep = msg.message
return m, nil

Expand All @@ -67,12 +65,10 @@ func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil

case errorMsg:
printLine(msg.message)
m.error = msg.message
return m, tea.Quit

case successMsg:
printLine(msg.message)
m.successMessage = msg.message + "\n\n"
return m, tea.Quit

Expand All @@ -88,7 +84,6 @@ func (m progressModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {

if m.provisioningCluster.Status == "error" {
errorMessage := createErrorLog(m.provisioningCluster.LastCondition)
printLine(errorMessage.message)
m.error = errorMessage.message
return m, tea.Quit
}
Expand Down Expand Up @@ -132,9 +127,3 @@ func (m progressModel) View() string {

return m.successMessage
}

func printLine(message string) {
if isCiExecution {
fmt.Fprintln(os.Stdout, message)
}
}

0 comments on commit eeeb475

Please sign in to comment.