Skip to content

Commit

Permalink
Merge pull request #184 from grisu48/tabs
Browse files Browse the repository at this point in the history
[openqa-revtui] Implements tabs for multiple configuration files
  • Loading branch information
grisu48 authored Dec 17, 2024
2 parents 4f65f2d + c3ce5d5 commit c5d5815
Show file tree
Hide file tree
Showing 5 changed files with 357 additions and 254 deletions.
14 changes: 12 additions & 2 deletions cmd/openqa-revtui/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type Group struct {

/* Program configuration parameters */
type Config struct {
Name string // Configuration name, if set
Instance string // Instance URL to be used
RabbitMQ string // RabbitMQ url to be used
RabbitMQTopic string // Topic to subscribe to
Expand All @@ -29,7 +30,12 @@ type Config struct {
RequestJobLimit int // Maximum number of jobs in a single request
}

var cf Config
func (cf Config) Validate() error {
if len(cf.Groups) == 0 {
return fmt.Errorf("no review groups defined")
}
return nil
}

func (cf *Config) LoadToml(filename string) error {
if _, err := toml.DecodeFile(filename, cf); err != nil {
Expand All @@ -54,7 +60,11 @@ func (cf *Config) LoadToml(filename string) error {
}
cf.Groups[i] = group
}
return nil
// Apply filename as name, if no name is set
if cf.Name == "" {
cf.Name = extractFilename(filename)
}
return cf.Validate()
}

/* Create configuration instance and set default vaules */
Expand Down
Loading

0 comments on commit c5d5815

Please sign in to comment.