Skip to content

Commit

Permalink
Merge pull request #189 from grisu48/tidy
Browse files Browse the repository at this point in the history
Tidy
  • Loading branch information
grisu48 authored Jan 15, 2025
2 parents c84c2e4 + c2afb0c commit 8807bb9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 52 deletions.
2 changes: 1 addition & 1 deletion cmd/openqa-mon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func strBool(text string) (bool, error) {
return false, nil
}
}
return true, fmt.Errorf("Illegal bool value")
return true, fmt.Errorf("illegal bool value")
}

func (cf *Config) SetDefaults() {
Expand Down
48 changes: 3 additions & 45 deletions cmd/openqa-mon/openqa-mon.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

var config Config
var tui TUI
var tui *TUI

// Remote instance
type Remote struct {
Expand Down Expand Up @@ -62,7 +62,7 @@ func printHelp() {
fmt.Println(" --config FILE Read additional config file FILE")
fmt.Println(" -i, --input FILE Read jobs from FILE (additionally to stdin)")
fmt.Println("")
fmt.Println("2024, https://github.com/os-autoinst/openqa-mon")
fmt.Println("https://github.com/os-autoinst/openqa-mon")
}

/** Try to match the url to be a test url. On success, return the remote and the job id */
Expand Down Expand Up @@ -121,17 +121,6 @@ func getFailedJobs(jobs []gopenqa.Job) []gopenqa.Job {
return ret
}

/** Check if the given job should not be displayed */
func hideJob(job gopenqa.Job, config Config) bool {
for _, s := range config.HideStates {
s = trimLower(s)
if trimLower(job.State) == s || trimLower(job.Result) == s {
return true
}
}
return false
}

/** Append the given remote by adding a job id to the existing remote or creating a new one */
func appendRemote(remotes []Remote, remote string, jobID int64) []Remote {
remote = homogenizeRemote(remote)
Expand Down Expand Up @@ -217,37 +206,6 @@ func expandArguments(args []string) ([]string, error) {
return ret, nil
}

func jobsContainId(jobs []gopenqa.Job, id int64) bool {
for _, job := range jobs {
if job.ID == id {
return true
}
}
return false
}

func getJobHierarchy(job gopenqa.Job, follow bool) ([]gopenqa.Job, error) {
jobs := make([]gopenqa.Job, 0)
// TODO: The prefix got missing ...
chained, err := job.FetchChildren(unique(job.Children.Chained), follow)
if err != nil {
return jobs, err
}
jobs = append(jobs, chained...)
directlyChained, err := job.FetchChildren(unique(job.Children.DirectlyChained), follow)
if err != nil {
return jobs, err
}
jobs = append(jobs, directlyChained...)
parallel, err := job.FetchChildren(unique(job.Children.Parallel), follow)
if err != nil {
return jobs, err
}
jobs = append(jobs, parallel...)

return jobs, nil
}

/** Try to update the job with the given status, if present. Returns the found job and true if the job was present */
func updateJobStatus(status gopenqa.JobStatus, openqaURI string) (gopenqa.Job, bool) {
if len(tui.Model.jobs) == 0 {
Expand Down Expand Up @@ -974,7 +932,7 @@ func continuousMonitoring(remotes []Remote) {
// Note: There are no messages that signal when a job is started
queue := []string{"#.job.done", "#.job.restart"}
remote := assembleRabbitMQRemote(rabbit.Remote, rabbit.Username, rabbit.Password)
rabbitmq, err := registerRabbitMQ(&tui, openqaURI, remote, queue)
rabbitmq, err := registerRabbitMQ(tui, openqaURI, remote, queue)
if err != nil {
fmt.Fprintf(os.Stderr, "Error establishing link to RabbitMQ %s: %s\n", rabbit.Remote, err)
config.Paused = false
Expand Down
4 changes: 2 additions & 2 deletions cmd/openqa-mon/tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func PrintLine(line string, maxWidth int) {
fmt.Println(line)
}

func CreateTUI() TUI {
func CreateTUI() *TUI {
var tui TUI
tui.done = make(chan bool, 1)
tui.Keypress = nil
Expand All @@ -103,7 +103,7 @@ func CreateTUI() TUI {
tui.hideEnable = true
tui.currentPage = 0
tui.totalPages = 1
return tui
return &tui
}

func bell() {
Expand Down
4 changes: 0 additions & 4 deletions cmd/openqa-mon/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ func trimSplit(s string, sep string) []string {
return split
}

func trimLower(s string) string {
return strings.ToLower(strings.TrimSpace(s))
}

func homeDir() string {
usr, err := user.Current()
if err != nil {
Expand Down

0 comments on commit 8807bb9

Please sign in to comment.