Skip to content

Commit

Permalink
Issue types can be private as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit91 committed Oct 10, 2023
1 parent 5dce260 commit b15b803
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 81 deletions.
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/asn-uniqueness.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ const (
)

type (
IssueASNUniqueness struct {
issueASNUniqueness struct {
details string
}
)

func (i *IssueASNUniqueness) Spec() *spec {
func (i *issueASNUniqueness) Spec() *spec {
return &spec{
Type: TypeASNUniqueness,
Severity: SeverityMinor,
Expand All @@ -27,7 +27,7 @@ func (i *IssueASNUniqueness) Spec() *spec {
}
}

func (i *IssueASNUniqueness) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueASNUniqueness) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
var (
machineASNs = map[uint32]metal.Machines{}
overlaps []string
Expand Down Expand Up @@ -117,6 +117,6 @@ func (i *IssueASNUniqueness) Evaluate(m metal.Machine, ec metal.ProvisioningEven
return true
}

func (i *IssueASNUniqueness) Details() string {
func (i *issueASNUniqueness) Details() string {
return i.details
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-info-outdated.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ const (
)

type (
IssueBMCInfoOutdated struct {
issueBMCInfoOutdated struct {
details string
}
)

func (i *IssueBMCInfoOutdated) Details() string {
func (i *issueBMCInfoOutdated) Details() string {
return i.details
}

func (i *IssueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if m.IPMI.LastUpdated.IsZero() {
i.details = "machine ipmi has never been set"
return true
Expand All @@ -37,7 +37,7 @@ func (i *IssueBMCInfoOutdated) Evaluate(m metal.Machine, ec metal.ProvisioningEv
return false
}

func (*IssueBMCInfoOutdated) Spec() *spec {
func (*issueBMCInfoOutdated) Spec() *spec {
return &spec{
Type: TypeBMCInfoOutdated,
Severity: SeverityMajor,
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-without-ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const (
)

type (
IssueBMCWithoutIP struct{}
issueBMCWithoutIP struct{}
)

func (i *IssueBMCWithoutIP) Spec() *spec {
func (i *issueBMCWithoutIP) Spec() *spec {
return &spec{
Type: TypeBMCWithoutIP,
Severity: SeverityMajor,
Expand All @@ -19,10 +19,10 @@ func (i *IssueBMCWithoutIP) Spec() *spec {
}
}

func (i *IssueBMCWithoutIP) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueBMCWithoutIP) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return m.IPMI.Address == ""
}

func (i *IssueBMCWithoutIP) Details() string {
func (i *issueBMCWithoutIP) Details() string {
return ""
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/bmc-without-mac.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const (
)

type (
IssueBMCWithoutMAC struct{}
issueBMCWithoutMAC struct{}
)

func (i *IssueBMCWithoutMAC) Spec() *spec {
func (i *issueBMCWithoutMAC) Spec() *spec {
return &spec{
Type: TypeBMCWithoutMAC,
Severity: SeverityMajor,
Expand All @@ -19,10 +19,10 @@ func (i *IssueBMCWithoutMAC) Spec() *spec {
}
}

func (i *IssueBMCWithoutMAC) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueBMCWithoutMAC) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return m.IPMI.MacAddress == ""
}

func (i *IssueBMCWithoutMAC) Details() string {
func (i *issueBMCWithoutMAC) Details() string {
return ""
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/crash-loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const (
)

type (
IssueCrashLoop struct{}
issueCrashLoop struct{}
)

func (i *IssueCrashLoop) Spec() *spec {
func (i *issueCrashLoop) Spec() *spec {
return &spec{
Type: TypeCrashLoop,
Severity: SeverityMajor,
Expand All @@ -22,7 +22,7 @@ func (i *IssueCrashLoop) Spec() *spec {
}
}

func (i *IssueCrashLoop) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueCrashLoop) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if ec.CrashLoop {
if pointer.FirstOrZero(ec.Events).Event == metal.ProvisioningEventWaiting {
// Machine which are waiting are not considered to have issues
Expand All @@ -33,6 +33,6 @@ func (i *IssueCrashLoop) Evaluate(m metal.Machine, ec metal.ProvisioningEventCon
return false
}

func (i *IssueCrashLoop) Details() string {
func (i *issueCrashLoop) Details() string {
return ""
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/failed-machine-reclaim.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const (
)

type (
IssueFailedMachineReclaim struct{}
issueFailedMachineReclaim struct{}
)

func (i *IssueFailedMachineReclaim) Spec() *spec {
func (i *issueFailedMachineReclaim) Spec() *spec {
return &spec{
Type: TypeFailedMachineReclaim,
Severity: SeverityCritical,
Expand All @@ -22,7 +22,7 @@ func (i *IssueFailedMachineReclaim) Spec() *spec {
}
}

func (i *IssueFailedMachineReclaim) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueFailedMachineReclaim) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if ec.FailedMachineReclaim {
return true
}
Expand All @@ -36,6 +36,6 @@ func (i *IssueFailedMachineReclaim) Evaluate(m metal.Machine, ec metal.Provision
return false
}

func (i *IssueFailedMachineReclaim) Details() string {
func (i *issueFailedMachineReclaim) Details() string {
return ""
}
2 changes: 1 addition & 1 deletion cmd/metal-api/internal/issues/issues.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func FindIssues(c *Config) (MachineIssuesMap, error) {

ec, ok := ecs[m.ID]
if !ok {
res.add(m, toIssue(&IssueNoEventContainer{}))
res.add(m, toIssue(&issueNoEventContainer{}))
continue
}

Expand Down
28 changes: 14 additions & 14 deletions cmd/metal-api/internal/issues/issues_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueNoPartition{}),
toIssue(&issueNoPartition{}),
},
},
}
Expand Down Expand Up @@ -108,7 +108,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueLivelinessDead{}),
toIssue(&issueLivelinessDead{}),
},
},
}
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueLivelinessUnknown{}),
toIssue(&issueLivelinessUnknown{}),
},
},
}
Expand Down Expand Up @@ -166,7 +166,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueLivelinessNotAvailable{}),
toIssue(&issueLivelinessNotAvailable{}),
},
},
}
Expand Down Expand Up @@ -206,13 +206,13 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueFailedMachineReclaim{}),
toIssue(&issueFailedMachineReclaim{}),
},
},
{
Machine: &machines[2],
Issues: Issues{
toIssue(&IssueFailedMachineReclaim{}),
toIssue(&issueFailedMachineReclaim{}),
},
},
}
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueCrashLoop{}),
toIssue(&issueCrashLoop{}),
},
},
}
Expand Down Expand Up @@ -306,7 +306,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueBMCWithoutMAC{}),
toIssue(&issueBMCWithoutMAC{}),
},
},
}
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueBMCWithoutIP{}),
toIssue(&issueBMCWithoutIP{}),
},
},
}
Expand Down Expand Up @@ -430,15 +430,15 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueASNUniqueness{
toIssue(&issueASNUniqueness{
details: fmt.Sprintf("- ASN (100) not unique, shared with [%[1]s]\n- ASN (200) not unique, shared with [%[1]s]", machines[1].ID),
}),
},
},
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueASNUniqueness{
toIssue(&issueASNUniqueness{
details: fmt.Sprintf("- ASN (100) not unique, shared with [%[1]s]\n- ASN (200) not unique, shared with [%[1]s]", machines[0].ID),
}),
},
Expand Down Expand Up @@ -474,15 +474,15 @@ func TestFindIssues(t *testing.T) {
{
Machine: &machines[0],
Issues: Issues{
toIssue(&IssueNonDistinctBMCIP{
toIssue(&issueNonDistinctBMCIP{
details: fmt.Sprintf("BMC IP (127.0.0.1) not unique, shared with [%[1]s]", machines[1].ID),
}),
},
},
{
Machine: &machines[1],
Issues: Issues{
toIssue(&IssueNonDistinctBMCIP{
toIssue(&issueNonDistinctBMCIP{
details: fmt.Sprintf("BMC IP (127.0.0.1) not unique, shared with [%[1]s]", machines[0].ID),
}),
},
Expand All @@ -509,7 +509,7 @@ func TestFindIssues(t *testing.T) {
want = tt.want(ms)
}

if diff := cmp.Diff(want, got.ToList(), cmp.AllowUnexported(IssueLastEventError{}, IssueASNUniqueness{}, IssueNonDistinctBMCIP{})); diff != "" {
if diff := cmp.Diff(want, got.ToList(), cmp.AllowUnexported(issueLastEventError{}, issueASNUniqueness{}, issueNonDistinctBMCIP{})); diff != "" {
t.Errorf("diff (+got -want):\n %s", diff)
}
})
Expand Down
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/last-event-error.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const (
)

type (
IssueLastEventError struct {
issueLastEventError struct {
details string
}
)
Expand All @@ -21,7 +21,7 @@ func DefaultLastErrorThreshold() time.Duration {
return 7 * 24 * time.Hour
}

func (i *IssueLastEventError) Spec() *spec {
func (i *issueLastEventError) Spec() *spec {
return &spec{
Type: TypeLastEventError,
Severity: SeverityMinor,
Expand All @@ -30,7 +30,7 @@ func (i *IssueLastEventError) Spec() *spec {
}
}

func (i *IssueLastEventError) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueLastEventError) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
if c.LastErrorThreshold == 0 {
return false
}
Expand All @@ -46,6 +46,6 @@ func (i *IssueLastEventError) Evaluate(m metal.Machine, ec metal.ProvisioningEve
return false
}

func (i *IssueLastEventError) Details() string {
func (i *issueLastEventError) Details() string {
return i.details
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/liveliness-dead.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const (
)

type (
IssueLivelinessDead struct{}
issueLivelinessDead struct{}
)

func (i *IssueLivelinessDead) Spec() *spec {
func (i *issueLivelinessDead) Spec() *spec {
return &spec{
Type: TypeLivelinessDead,
Severity: SeverityMajor,
Expand All @@ -19,10 +19,10 @@ func (i *IssueLivelinessDead) Spec() *spec {
}
}

func (i *IssueLivelinessDead) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueLivelinessDead) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
return ec.Liveliness == metal.MachineLivelinessDead
}

func (i *IssueLivelinessDead) Details() string {
func (i *issueLivelinessDead) Details() string {
return ""
}
8 changes: 4 additions & 4 deletions cmd/metal-api/internal/issues/liveliness-not-available.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ const (
)

type (
IssueLivelinessNotAvailable struct{}
issueLivelinessNotAvailable struct{}
)

func (i *IssueLivelinessNotAvailable) Spec() *spec {
func (i *issueLivelinessNotAvailable) Spec() *spec {
return &spec{
Type: TypeLivelinessNotAvailable,
Severity: SeverityMinor,
Description: "the machine liveliness is not available",
}
}

func (i *IssueLivelinessNotAvailable) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
func (i *issueLivelinessNotAvailable) Evaluate(m metal.Machine, ec metal.ProvisioningEventContainer, c *Config) bool {
allowed := map[metal.MachineLiveliness]bool{
metal.MachineLivelinessAlive: true,
metal.MachineLivelinessDead: true,
Expand All @@ -28,6 +28,6 @@ func (i *IssueLivelinessNotAvailable) Evaluate(m metal.Machine, ec metal.Provisi
return !allowed[ec.Liveliness]
}

func (i *IssueLivelinessNotAvailable) Details() string {
func (i *issueLivelinessNotAvailable) Details() string {
return ""
}
Loading

0 comments on commit b15b803

Please sign in to comment.