Files
troubleshoot/pkg/analyze/host_json_compare.go
Evans Mungai 1444c01725 feat: json compare host analyser (#1582)
* feat: json compore host analyser

Signed-off-by: Evans Mungai <evans@replicated.com>

* Add missing json compare host analyser file

Signed-off-by: Evans Mungai <evans@replicated.com>

* Generate schemas

Signed-off-by: Evans Mungai <evans@replicated.com>

* Fix failing tests

Signed-off-by: Evans Mungai <evans@replicated.com>

* Ensure json compare analyser always has a title

Signed-off-by: Evans Mungai <evans@replicated.com>

---------

Signed-off-by: Evans Mungai <evans@replicated.com>
2024-07-24 14:27:20 +01:00

29 lines
804 B
Go

package analyzer
import (
troubleshootv1beta2 "github.com/replicatedhq/troubleshoot/pkg/apis/troubleshoot/v1beta2"
)
type AnalyzeHostJsonCompare struct {
hostAnalyzer *troubleshootv1beta2.JsonCompare
}
func (a *AnalyzeHostJsonCompare) Title() string {
return jsonCompareTitle(a.hostAnalyzer)
}
func (a *AnalyzeHostJsonCompare) IsExcluded() (bool, error) {
return isExcluded(a.hostAnalyzer.Exclude)
}
func (a *AnalyzeHostJsonCompare) Analyze(
getCollectedFileContents func(string) ([]byte, error), findFiles getChildCollectedFileContents,
) ([]*AnalyzeResult, error) {
result, err := analyzeJsonCompare(a.hostAnalyzer, getCollectedFileContents, a.Title())
if err != nil {
return nil, err
}
result.Strict = a.hostAnalyzer.Strict.BoolOrDefaultFalse()
return []*AnalyzeResult{result}, nil
}