Skip to content

Commit

Permalink
make fileNotCollected an exported constant
Browse files Browse the repository at this point in the history
  • Loading branch information
laverya committed Oct 10, 2023
1 parent e84ff79 commit 5534b68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pkg/analyze/analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
"k8s.io/klog/v2"
)

const FILE_NOT_COLLECTED = "fileNotCollected"

type AnalyzeResult struct {
IsPass bool
IsFail bool
Expand Down
10 changes: 5 additions & 5 deletions pkg/analyze/host_filesystem_performance.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ func (a *AnalyzeHostFilesystemPerformance) Analyze(
contents, err := getCollectedFileContents(name)
if err != nil {
if len(hostAnalyzer.Outcomes) >= 1 {
// if the very first outcome is 'fileNotCollected', then use that outcome
// if the very first outcome is FILE_NOT_COLLECTED', then use that outcome
// otherwise, return the error
if hostAnalyzer.Outcomes[0].Fail != nil && hostAnalyzer.Outcomes[0].Fail.When == "fileNotCollected" {
if hostAnalyzer.Outcomes[0].Fail != nil && hostAnalyzer.Outcomes[0].Fail.When == FILE_NOT_COLLECTED {
result.IsFail = true
result.Message = renderFSPerfOutcome(hostAnalyzer.Outcomes[0].Fail.Message, collect.FSPerfResults{})
result.URI = hostAnalyzer.Outcomes[0].Fail.URI
return []*AnalyzeResult{result}, nil
}
if hostAnalyzer.Outcomes[0].Warn != nil && hostAnalyzer.Outcomes[0].Warn.When == "fileNotCollected" {
if hostAnalyzer.Outcomes[0].Warn != nil && hostAnalyzer.Outcomes[0].Warn.When == FILE_NOT_COLLECTED {
result.IsWarn = true
result.Message = renderFSPerfOutcome(hostAnalyzer.Outcomes[0].Warn.Message, collect.FSPerfResults{})
result.URI = hostAnalyzer.Outcomes[0].Warn.URI
return []*AnalyzeResult{result}, nil
}
if hostAnalyzer.Outcomes[0].Pass != nil && hostAnalyzer.Outcomes[0].Pass.When == "fileNotCollected" {
if hostAnalyzer.Outcomes[0].Pass != nil && hostAnalyzer.Outcomes[0].Pass.When == FILE_NOT_COLLECTED {
result.IsPass = true
result.Message = renderFSPerfOutcome(hostAnalyzer.Outcomes[0].Pass.Message, collect.FSPerfResults{})
result.URI = hostAnalyzer.Outcomes[0].Pass.URI
Expand Down Expand Up @@ -158,7 +158,7 @@ func (a *AnalyzeHostFilesystemPerformance) Analyze(
}

func compareHostFilesystemPerformanceConditionalToActual(conditional string, fsPerf collect.FSPerfResults) (res bool, err error) {
if conditional == "fileNotCollected" {
if conditional == FILE_NOT_COLLECTED {
return false, nil
}

Expand Down

0 comments on commit 5534b68

Please sign in to comment.