Skip to content

Commit

Permalink
Cosmetics.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Oct 11, 2023
1 parent b15b803 commit a070f25
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 16 deletions.
35 changes: 24 additions & 11 deletions cmd/metal-api/internal/issues/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,33 @@ import (
type (
// Config contains configuration parameters for finding machine issues
Config struct {
Machines metal.Machines
EventContainers metal.ProvisioningEventContainers
Severity Severity
Only []Type
Omit []Type
// Machines are the machines to evaluate issues for
Machines metal.Machines
// EventContainers are the event containers of the machines to evaluate issues for
// if not provided the machines will have a no-event-container issue
EventContainers metal.ProvisioningEventContainers
// Severity filters issues for the given severity
Severity Severity
// Only includes only the given issue types
Only []Type
// Omit omits the given issue types, this has precedence over only
Omit []Type
// LastErrorThreshold specifies for how long in the past the last event error is counted as an error
LastErrorThreshold time.Duration
}

// Issue formulates an issue of a machine
Issue struct {
Type Type
Severity Severity
// Type specifies the issue type (id)
Type Type
// Severity specifies the severity of an issue
Severity Severity
// Description provides an issue description
Description string
RefURL string
Details string
// RefURL provides a link to a more detailed issue description in the metal-stack documentation
RefURL string
// Details may contain additional details on an evaluated issue
Details string
}

// Issues is a list of issues
Expand All @@ -38,6 +50,7 @@ type (
// MachineIssues is map of a machine response to a list of machine issues
MachineIssues []*MachineWithIssues

// MachineIssuesMap is a map of machine issues with the machine id as a map key
MachineIssuesMap map[string]*MachineWithIssues

issue interface {
Expand All @@ -59,7 +72,7 @@ type (
}
)

func AllIssues() Issues {
func All() Issues {
var res Issues

for _, t := range AllIssueTypes() {
Expand All @@ -84,7 +97,7 @@ func toIssue(i issue) Issue {
}
}

func FindIssues(c *Config) (MachineIssuesMap, error) {
func Find(c *Config) (MachineIssuesMap, error) {
if c.LastErrorThreshold == 0 {
c.LastErrorThreshold = DefaultLastErrorThreshold()
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/issues/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func TestFindIssues(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
ms := tt.machines()

got, err := FindIssues(&Config{
got, err := Find(&Config{
Machines: ms,
EventContainers: tt.eventContainers(),
Only: tt.only,
Expand All @@ -518,7 +518,7 @@ func TestFindIssues(t *testing.T) {

func TestAllIssues(t *testing.T) {
issuesTypes := map[Type]bool{}
for _, i := range AllIssues() {
for _, i := range All() {
issuesTypes[i.Type] = true
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/metal-api/internal/service/machine-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ func (r *machineResource) updateMachine(request *restful.Request, response *rest
}

func (r *machineResource) listIssues(request *restful.Request, response *restful.Response) {
issues := issues.AllIssues()
issues := issues.All()

var issueResponse []v1.MachineIssue
for _, issue := range issues {
Expand Down Expand Up @@ -593,7 +593,7 @@ func (r *machineResource) issues(request *restful.Request, response *restful.Res
return
}

machinesWithIssues, err := issues.FindIssues(&issues.Config{
machinesWithIssues, err := issues.Find(&issues.Config{
Machines: ms,
EventContainers: ecs,
Severity: severity,
Expand Down
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/service/partition-service.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ func (r *partitionResource) calcPartitionCapacity(pcr *v1.PartitionCapacityReque
return nil, fmt.Errorf("unable to fetch provisioning event containers: %w", err)
}

machinesWithIssues, err := issues.FindIssues(&issues.Config{
machinesWithIssues, err := issues.Find(&issues.Config{
Machines: ms,
EventContainers: ecs,
Only: issues.NotAllocatableIssueTypes(),
Expand Down

0 comments on commit a070f25

Please sign in to comment.